Skip to content
Browse files

eval {} hack due to issue I reported upstream in eyeD3

Issue below:

Here's a problem I had with a file in the wild. I can send the file on
request but the problem should be easy to fix:

   $ eyeD3 --to-v2.3
"/home/avar/Podcasts/History/Dan_Carlins_Hardcore_History/Show_33_-_BLITZ_Old_School_Toughness.mp3"

   Show_33_-_BLITZ_Old_School_Toughness.mp3        [ 43.27 MB ]
   -------------------------------------------------------------------------------
   Time: 01:03:02  MPEG1, Layer III        [ 96 kb/s @ 44100 Hz - Mono ]
   -------------------------------------------------------------------------------
   No conversion necessary, tag is already version v2.3
   Writing tag...
   ID3 v2.3:
   title: dchha33 (BLITZ) Old School Toughness             artist: Dan Carlin
   album: dancarlin.com            year: 2704
   track:          genre: Podcast (id None)
   Uncaught exception: invalid literal for float(): na
   Traceback (most recent call last):
     File "/usr/bin/eyeD3", line 1215, in <module>
       retval = main();
     File "/usr/bin/eyeD3", line 1192, in main
       retval = app.handleFile(f);
     File "/usr/bin/eyeD3", line 566, in handleFile
       self.printTag(self.tag);
     File "/usr/bin/eyeD3", line 969, in printTag
       bpm = tag.getBPM();
     File "/usr/lib/pymodules/python2.6/eyeD3/tag.py", line 986, in getBPM
       bpm = int(float(bpm[0].text) + 0.5)
   ValueError: invalid literal for float(): na

The problem is the int(float(... conversion here:

  def getBPM(self):
     bpm = self.frames[BPM_FID];
     if bpm:
         # Round floats since the spec says this is an integer
         bpm = int(float(bpm[0].text) + 0.5)
         return bpm
     else:
         return None;

It needs to catch the float() exception. The spec says it's an int,
but evidently people put garbage like "na" in it in the wild.
  • Loading branch information...
1 parent 85e35b1 commit 92f0c594aa26a890026046c50553b864b69cf49b @avar committed Apr 30, 2010
Showing with 3 additions and 1 deletion.
  1. +3 −1 fix-podcast-tags.pl
View
4 fix-podcast-tags.pl
@@ -42,7 +42,9 @@
#say "Setting ALBUM='$album', was ALBUM='$l' on $file";
my $cmd = qq[eyeD3 --to-v2.3 "$file" && eyeD3 --album="$album" "$file"];
say $cmd;
- system $cmd;
+ eval {
+ system $cmd;
+ };
}
# Set track numbers

0 comments on commit 92f0c59

Please sign in to comment.
Something went wrong with that request. Please try again.