leosongwei / mutagen

Automatically exported from code.google.com/p/mutagen
GNU General Public License v2.0
0 stars 0 forks source link

Failure opening MP3 files without ID3 tags #57

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Opening an MP3 file without tags raises ID3UnsupportedVersionError

The file I am trying to open is http://www.spanishpodcast.org/archivos/
episodios/EP31/31primertiempo.mp3 (16.8MB)

The code to reproduce the issue is:

================================
import os
from mutagen.id3 import ID3

os.system('wget http://www.spanishpodcast.org/archivos/episodios/
EP31/31primertiempo.mp3 -O -c /tmp/31primertiempo.mp3')

id3 = ID3('/tmp/31primertiempo.mp3')
=================================

And this is the exception I get:

/usr/lib/python2.6/dist-packages/mutagen/id3.pyc in __load_header(self)
209                                                                
210         if id3 != 'ID3':                                       
--> 211     raise ID3NoHeaderError("'%s' doesn't start with an ID3 tag" % 
fn)
212         if vmaj not in [2, 3, 4]:
213             raise ID3UnsupportedVersionError("'%s' ID3v2.%d not 
supported"

ID3NoHeaderError: '/var/es/spanishpodcast.org/31primertiempo.mp3' doesn't 
start with an ID3 tag

I am  attaching the first 32K of the file, and the last chunk since I 
noticed that it contained the Lame signature and thought that there is a 
change that some info might be in the tail.

Original issue reported on code.google.com by vri...@gmail.com on 27 Feb 2010 at 1:14

Attachments:

GoogleCodeExporter commented 9 years ago
It is probably worth mentioning that the MP3 file is identified by `file` as:
MPEG ADTS, layer III, v2,  64 kbps, 24 kHz, JntStereo

Original comment by vri...@gmail.com on 27 Feb 2010 at 1:24

GoogleCodeExporter commented 9 years ago
FAQ.

Original comment by joe.wreschnig@gmail.com on 27 Feb 2010 at 1:49

GoogleCodeExporter commented 9 years ago
Sorry I brought it up. Apparently there was no bug, and there is nothing wrong 
with 
the file. I managed to get it to work by doing something like this:

    try:
        tag = ID3(mp3file)
    except mutagen.id3.error:
        tag = ID3()
        tag.save(mp3file)

And then all the rest worked. For some reason I assumed that mutagen will 
create the 
tag if it does not exist, and all examples in the docs were about *modifying* 
the 
tags, not creating them. 

Maybe it will help other people to add code on creating tags to the main 
tutorial.

Thanks for you work, and I guess the issue can be considered closed.

Original comment by vri...@gmail.com on 27 Feb 2010 at 1:55

GoogleCodeExporter commented 9 years ago
I agree with the reporter.

Either ID3/EasyID3 should automatically create tags if they don't exist, or 
this example should be in the docs.

Original comment by zbuh...@gmail.com on 6 Jul 2011 at 11:20

GoogleCodeExporter commented 9 years ago
There are only four questions in the FAQ, and this is one of them.

Original comment by joe.wreschnig@gmail.com on 7 Jul 2011 at 3:39

GoogleCodeExporter commented 9 years ago
Couldn't that information show up if you do help(mutagen)? Seems like it would 
save a lot of people a lot of time. 

Original comment by tens...@gmail.com on 22 Aug 2013 at 10:13

GoogleCodeExporter commented 9 years ago
I agree. It should create tags if they don't exist.

Original comment by makobu.mwambiriro@gmail.com on 9 Mar 2014 at 3:43