[Tutor] MP3Info class usage

Lie Ryan lie.1296 at gmail.com
Wed Dec 10 15:55:20 CET 2008


On Wed, 10 Dec 2008 04:48:38 -0800, Gareth at Serif wrote:

> Has anyone ever used MP3Info to retrieve the ID3 tags from an MP3?  It
> seems to be a well written class that can access ID3 tags in v.1 or v.2,
> but I've not used classes before and I'm struggling to figure out how to
> use it.
> 
> Given that, for testing purposses, I have a property called 'testfile'
> set to the path of a valid MP3 file, I then try to output the artist
> name with the following, where ID3v2 is a class defined in MP3Info: song
> = ID3v2(testfile)
> print '\nArtist is: %s' % (song.artist)
> 
> When I execute this script I get an error, "AttributeError: 'str' object
> has no attribute 'seek'".  Is this a bug in the class or am I not using
> it correctly?  Has anyone any better suggestions for retreiving ID3 tags
> from an MP3 file using python?
> 
> Regards,
> Gareth

You need to know about file interface. The testfile you gave is neither a 
file object nor a file-like object but a string while the function ID3v2 
expects a file or file-like object. In short, ID3v2 tries to call 
testfile.seek() which doesn't exists.



More information about the Tutor mailing list