Skip to content

Instantly share code, notes, and snippets.

@steshaw
Created March 23, 2010 01:39
Show Gist options
  • Save steshaw/340760 to your computer and use it in GitHub Desktop.
Save steshaw/340760 to your computer and use it in GitHub Desktop.
#!/usr/bin/ruby
require 'rubygems'
require 'id3lib'
def usage()
scriptName = File.basename($0)
STDERR.puts "Usage: #{scriptName} <mp3-file>"
exit 1
end
if ARGV.length != 1 then
usage
end
file = ARGV[0]
if !File.readable? ARGV[0] then
STDERR.puts "Error: Cannot read the file you provided. [#{file}]"
usage
end
tags = ID3Lib::Tag.new(file)
uitsFaq = "http://uits.umusic.com/faq.htm"
uitsPrivFrame = tags.find{|frame| frame[:id] == :PRIV && frame[:owner] = uitsFaq}
if uitsPrivFrame == nil then
STDERR.puts "Cannot find UITS PRIV frame with owner attribute of #{uitsFaq}"
exit 1
end
uitsXml = uitsPrivFrame[:data].sub(/\000+$/, "")
puts uitsXml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment