Last active
August 29, 2015 14:06
-
-
Save grubernaut/630957e1a7c726553604 to your computer and use it in GitHub Desktop.
Applescript to copy Spotify Now Playing to clipboard
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Copies Now Playing Track, Album, and Spotify URI to clipboard.
#NowPlaying=> Just Like Heaven | The Cure => http://open.spotify.com/track/7C6NcqS3fNDXLgP5L2Kbgp