superrip: fix manifest validation
authorColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Sat, 3 Apr 2010 20:36:45 +0000 (13:36 -0700)
committerColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Sat, 3 Apr 2010 20:36:45 +0000 (13:36 -0700)
Fix manifest validation.

Also, fix parsing of cdda2wav output for discs with fewer than 10
tracks.

superrip.rb

index bdf7512..d9ab7d7 100755 (executable)
@@ -44,8 +44,8 @@ def get_number_of_tracks_on_cd
         look_for_tracks = true
       elsif (look_for_tracks == true) then
         look_for_tracks = false
-        line =~ /[ \t]*1-([1234567890][1234567890]*)[^1234567890]/ \
-          or raise "couldn't understand cdda2wav output!"
+        line =~ /[ \t]*1-([ 1234567890][1234567890]*)[^1234567890]/ \
+          or raise "couldn't understand cdda2wav output! (line:#{line})"
         return $1.to_i
       end
     end
@@ -184,11 +184,10 @@ class Manifest
     if (@t.empty?) then
       raise "you must define some tracks"
     end
-    @t.each { |t| t.validate }
     if (not $opts.partial) then
-      (1..num_tracks).each do |t|
-        if not @t[t].defined?
-          raise "don't know what to do with track #{t}"
+      (1..num_tracks).each do |tnum|
+        if not @t.has_key?(tnum)
+          raise "don't know what to do with track #{tnum}"
         end
       end
     end
@@ -235,6 +234,7 @@ manifest = Manifest.new($opts.manifest_file)
 puts manifest.inspect
 num_tracks = get_number_of_tracks_on_cd()
 puts "found #{num_tracks} tracks"
+manifest.validate(num_tracks)
 manifest.rip(num_tracks)
 puts "*** FINISHED ***"
 exit 0