Skip to content

Instantly share code, notes, and snippets.

@joemay
Forked from elliottkember/spotify.applescript
Created October 10, 2013 00:18
Show Gist options
  • Select an option

  • Save joemay/6910911 to your computer and use it in GitHub Desktop.

Select an option

Save joemay/6910911 to your computer and use it in GitHub Desktop.
property baseURL : "http://statusboard.dev/song?"
if application "Spotify" is running then
tell application "Spotify"
set theTrack to name of the current track
set theArtist to artist of the current track
set theAlbum to album of the current track
set theurl to spotify url of the current track
try
do shell script "/usr/local/bin/wget --delete-after \"" & baseURL & "&t=" & theTrack & "&a=" & theArtist & "&al=" & theAlbum & "\""
on error err
end try
end tell
end if
-- Paths and stuff
set ArtworkFromSpotify to ((path to home folder) as text) & ¬
"Sites:statusboard:public:images:albumArt1.tiff" as alias
set SpotifyArtwork to ((path to home folder) as text) & ¬
"Sites:statusboard:public:images:albumArt1.tiff"
set DefaultArtwork to ((path to home folder) as text) & ¬
"Sites:statusboard:public:images:albumArt.tiff"
set displayArtwork to ((path to home folder) as text) & ¬
"Sites:statusboard:public:images:albumArt.tiff"
-- Unix versions of the above path strings
set unixSpotifyArtwork to the quoted form of POSIX path of SpotifyArtwork
set unixDefaultArtwork to the quoted form of POSIX path of DefaultArtwork
set unixDisplayArtwork to the quoted form of POSIX path of displayArtwork
set whichArt to "blank"
tell application "System Events"
if exists process "Spotify" then -- Spotify is running
tell application "Spotify"
if player state is playing then -- Spotify is playing
set aTrack to current track
set aTrackArtwork to null
set aTrackArtwork to artwork of aTrack
set fileRef to ¬
(open for access ArtworkFromSpotify with write permission)
try
write aTrackArtwork to fileRef
close access fileRef
on error errorMsg
try
close access fileRef
end try
error errorMsg
end try
tell application "Finder" to ¬
set creator type of ArtworkFromSpotify to "????"
set whichArt to "Spotify"
end if
end tell
end if
end tell
if whichArt is "Spotify" then
do shell script "ditto -rsrc " & unixSpotifyArtwork & space & unixDisplayArtwork
else
do shell script "ditto -rsrc " & unixDefaultArtwork & space & unixDisplayArtwork
end if
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment