Created
February 14, 2010 12:43
-
-
Save badboy/303993 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/env ruby | |
require 'optparse' | |
require 'rubygems' | |
require 'id3lib' | |
Version = '0.0.1' | |
options = [] | |
ARGV.options do |o| | |
o.banner = 'usage: id3tag [options] mp3file' | |
o.separator('id3tag - show id3 info') | |
o.separator('') | |
o.on('-A', '--all', 'all infos') do |u| | |
options = [:title, :artist, :album, :year] | |
end | |
o.on('-t', '--title', 'title') do |u| | |
options << :title | |
end | |
o.on('-a', '--artist', 'artist') do |u| | |
options << :artist | |
end | |
o.on('-l', '--album', 'album') do |u| | |
options << :album | |
end | |
o.on('-y', '--year', 'year') do |u| | |
options << :year | |
end | |
o.on_tail('-V', '--version', 'Show version') do | |
puts o.ver | |
puts 'Written by BadBoy_' | |
puts | |
puts 'Copyright (C) 2008 BadBoy_ <http://badboy.pytalhost.de/>' | |
puts 'This is free software released under Creative Common License' | |
puts '<http://creativecommons.org/licenses/by-nc-sa/3.0/de/>' | |
exit | |
end | |
end | |
ARGV.parse! | |
file = ARGV.shift | |
if file | |
if options.size == 0 | |
STDERR.puts "no option given! use #{$0} -h for more" | |
exit 1 | |
end | |
tag = ID3Lib::Tag.new file | |
options.each do |val| | |
puts "#{val}: #{tag.send(val)}" | |
end | |
else | |
STDERR.puts "no file given! use #{$0} -h for more" | |
exit 1 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment