Skip to content

Instantly share code, notes, and snippets.

@lachie
Created October 9, 2008 04:28
Show Gist options
  • Save lachie/15694 to your computer and use it in GitHub Desktop.
Save lachie/15694 to your computer and use it in GitHub Desktop.
#!/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/'
$stdout.sync = false
open("#{ENV['HOME']}/tracksfound.xml",'w') do |f|
i = 1
trx = []
Dir['*'].each do |track|
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 -xml #{trx_cmd}!
f.flush
trx = []
puts "OK MOAR!"
end
i += 1
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment