#!/usr/bin/env rubyargs = ARGV.reverseparanoia = truef_tags = "./lst"def usage() puts "usage: #{__FILE__} [-x] [filename] -x: don't use cdparanoia filename: the file where to find the tags the tag file must be formated in order to contain a soundfile group of tags per line as this: <tag>: <data> the accepted tags are: artist, album, year, comment and style, plus the track number for the title infos. e.g.: artist: roger album: the musette big back 1: acordeon hardcore 2: psychimamie etc." exitendclass F_tags attr_reader :infos def initialize(filename) begin f_tags = File.open(filename) rescue puts "error while opening the tag file:" puts $! exit end tracks = [] artist = album = year = comment = style = "unknown" track_count = 0 while (line = f_tags.gets) if not line[/^ *$/] case line[/^\w+: /] when "artist: ", "artiste: " then artist = $'.chomp when "album: " then album = $'.chomp when "year: ", "année: " then year = $'.chomp when "comment: ", "commentaire: " then comment = $'.chomp when "style: " then style = $'.chomp else tag, data = $&, $' if tag[/^\d{2}/] tracks << $& track_count += 1 else puts "invalid tag: #{tag}" exit end end end end f_tags.close @infos = { "artist" => artist, "album" => album, "year" => year, "comment" => comment, "style" => style, "count" => track_count, "tracks" => tracks } endendwhile args != [] argument = args[args.length - 1] case argument when "-x" then paranoia = false else File.exist?(argument) ? f_tags = argument : usage end args.popendtags = F_tags.new(f_tags)%x(cdparanoia -B) if paranoiafichiers = Dir.new('.').entries.delete_if { |f| ! f[/\.wav/] }if fichiers.length != tags.infos['count'] and tags.infos['count'] != 0 puts "error: the number of extracted tracks and the one get from the tagsfile do not match" exitendfichiers.each { |fichier| numero = fichier[/\d{2}/] %x(oggenc -q8 -N #{numero} -a "#{tags.infos['artist']}" -G "#{tags.infos['style']}" -d "#{tags.infos['year']}" -l "#{tags.infos['album']}" -c "#{tags.infos['comment']}" #{printf("-t '%s'", tags.infos['tracks'][numero.to_i-1]) if tags.infos['count'] != 0} #{fichier})}