Created
April 18, 2015 16:56
-
-
Save yene/6301574a1e8862fc69a7 to your computer and use it in GitHub Desktop.
Write current Spotify song to file for OBS
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
set oldTrack to "" | |
set current_user to do shell script "whoami" | |
set the_file to "/Users/" & current_user & "/NowPlaying.txt" | |
do shell script "touch " & POSIX path of the_file -- create file | |
repeat | |
if application "Spotify" is not running then | |
say "spotify is not running" | |
return | |
end if | |
tell application "Spotify" | |
try | |
if player state is playing then | |
set theTrack to name of the current track | |
set theArtist to artist of the current track | |
set theAlbum to album of the current track | |
if oldTrack is not equal to theTrack then | |
set oldTrack to theTrack | |
tell application "Finder" | |
try | |
set eof of the_file to 0 | |
-- Nicecast set theSong to "Artist: " & theArtist & return & "Title: " & theTrack | |
set theSong to "\"" & theTrack & "\"" & " by " & theArtist | |
write (theSong) to the_file | |
end try | |
end tell | |
end if | |
end if | |
end try | |
end tell | |
delay 10 | |
end repeat |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment