-
-
Save chrislloyd/15698 to your computer and use it in GitHub Desktop.
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/ruby | |
# Just splits up the queries into 20 tracks at a time, so I don't inundate the service, and so I can see what's happening. | |
# Its pretty slow on average. | |
# I'll need to parse the XML and reapply to the tags. | |
# | |
# get a MusicDNS key + genpuid & friends at http://www.musicip.com/ | |
require 'rubygems' | |
require 'escape' # gem install escape | |
MUSICDNS_KEY = 'you have to sign up and get a key, blah. http://www.musicip.com/' | |
ITUNES_DIR = ENV['ITUNES_DIR'] || "#{ENV['HOME']}/Music/iTunes/iTunes Music" | |
$stdout.sync = false | |
open("#{ENV['HOME']}/tracksfound.xml",'w') do |f| | |
trx = [] | |
Dir[File.join(ITUNES_DIR, '**/**/*.mp3')].each_with_index do |track, i| | |
trx << track | |
if i % 20 == 0 | |
trx_cmd = Escape.shell_command(trx) | |
puts "asking mdns about #{trx_cmd}" | |
f.puts %x! genpuid #{MUSICDNS_KEY} -rmd=2 -r -xml #{trx_cmd}! | |
f.flush | |
trx = [] | |
puts "OK MOAR!" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment