Skip to content

Instantly share code, notes, and snippets.

@chrisallick
Last active August 1, 2018 00:27
Show Gist options
  • Save chrisallick/0f82ffac164313c05cc592d5fd8d0569 to your computer and use it in GitHub Desktop.
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)
#!/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