Last active
August 1, 2018 00:27
-
-
Save chrisallick/0f82ffac164313c05cc592d5fd8d0569 to your computer and use it in GitHub Desktop.
Pipe what is playing on spotify into a file for BUTT (broadcast using this tool)
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
#!/usr/bin/env ruby | |
require 'rubygems' | |
# usage | |
# ./currently_playing.rb > currently_playing.txt | |
def osascript(script) | |
system 'osascript', *script.split(/\n/).map { |line| ['-e', line] }.flatten | |
end | |
osascript <<-END | |
on getCurrentTrack() | |
tell application "Spotify" | |
set currentArtist to artist of current track as string | |
set currentTitle to name of current track as string | |
return currentArtist & " - " & currentTitle | |
end tell | |
end getCurrentTrack | |
getCurrentTrack() | |
END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment