Created
December 6, 2012 09:12
-
-
Save dkordik/4223157 to your computer and use it in GitHub Desktop.
Sniff network for iTunes Store updateNowPlaying requests via ngrep. Expand to do interesting things based on what you're playing.
This file contains hidden or 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
require 'cgi' | |
match = 'track.updateNowPlaying' | |
ngrep_command = "ngrep -W byline '#{match}'" | |
puts "Watching network for iTunes Store now playing previews..." | |
IO.popen(ngrep_command).each do |line| | |
if line.match(/\=#{match}/) | |
nowplaying = CGI::parse(line) | |
puts | |
puts "Artist: #{nowplaying["artist"][0]}" | |
puts "Album: #{nowplaying["album"][0]}" | |
puts "Title: #{nowplaying["track"][0]}" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment