Skip to content

Instantly share code, notes, and snippets.

@grubernaut
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grubernaut/630957e1a7c726553604 to your computer and use it in GitHub Desktop.
Save grubernaut/630957e1a7c726553604 to your computer and use it in GitHub Desktop.
Applescript to copy Spotify Now Playing to clipboard
tell application "System Events"
set myList to (name of every process)
end tell
if myList contains "Spotify" then
tell application "Spotify"
if player state is stopped then
set output to "Stopped"
else
set trackname to name of current track
set artistname to artist of current track
set albumname to album of current track
set track_id to id of current track
set AppleScript's text item delimiters to ":"
set track_id to third text item of track_id
set AppleScript's text item delimiters to {""}
set spotifyurl to "http://open.spotify.com/track/" & track_id
if player state is playing then
set output to "#NowPlaying=> " & trackname & " | " & artistname & " => " & spotifyurl
end if
end if
end tell
else
set output to "Spotify is not running"
end if
set the clipboard to output
@grubernaut
Copy link
Author

Copies Now Playing Track, Album, and Spotify URI to clipboard.
#NowPlaying=> Just Like Heaven | The Cure => http://open.spotify.com/track/7C6NcqS3fNDXLgP5L2Kbgp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment