Skip to content

Instantly share code, notes, and snippets.

@freman
Created December 16, 2015 07:02
Show Gist options
  • Save freman/f055f614d5fcbfe96ff1 to your computer and use it in GitHub Desktop.
Save freman/f055f614d5fcbfe96ff1 to your computer and use it in GitHub Desktop.
Spotify blacklist script.
repeat
if application "Spotify" is running then
tell application "Spotify"
set seenTrack to ""
repeat while player state is playing
if player state is playing then
set theAlbum to album of the current track
set theTrack to name of the current track
set theArtist to artist of the current track
set trackLength to duration of current track
set currentPos to player position as integer
end if
try
if theTrack & " - " & theArtist is not seenTrack then
set seenTrack to theTrack & " - " & theArtist
my logit(seenTrack, "TestDrive")
set stringContainsName to false
set tString to "This text contains the names John, George, and Bob."
set tNames to paragraphs of (read POSIX file "/Users/shannon/.SpotifyBlacklist")
repeat with aName in tNames
if contents of aName is not "" then
if aName is in theArtist then
set stringContainsName to true
exit repeat
end if
end if
end repeat
if stringContainsName then
tell application "Spotify" to next track
end if
end if
on error e number n
my logit("oh hai: " & e, "TestDrive")
end try
delay 0.5
end repeat
end tell
end if
delay 30
end repeat
to logit(log_string, log_file)
do shell script ¬
"echo `date '+%Y-%m-%d %T: '`\"" & log_string & ¬
"\" >> /tmp/" & log_file & ".log"
end logit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment