Looking For mp3 ID Tag Module

T

Tim Daneliuk

I have DAGS and generally nosed around the net but cannot quite find what
I need. I am looking for a platform-independent Python module that would
permit me to write mp3 ID tags conformant to the latest spects. I am
currently calling 'mp3info' from my Python script, but that program is limited
to the older ID tags that are severely limited in length and thus truncate
the description strings I am providing.

Ideas anyone?
 
?

=?ISO-8859-1?Q?I=F1igo_Serna?=


This module is more-or-less exactly what I needed. However, I am running
into problems when the filenames or ID tags have unicode characters in them.

Typically, I do something like:

from mutagen.easyid3 import EasyID3

audio["title'] = Something based on the filename that has unicode chars in it

I then get this:

UnicodeDecodeError: 'ascii' codec can't decode byte 0xfc in position 56: ordinal not in range(128)
From the docs:
"""Mutagen has full Unicode support for all formats. When you assign
text strings, we strongly recommend using Python unicode objects
rather than str objects. If you use str objects, Mutagen will assume
they are in UTF-8."""

So I suppose the value you try to assign as title is not unicode,
check the encoding used in the file system.

Iñigo
 
T

Tim Daneliuk

Iñigo Serna said:
try mutagen.
http://www.sacredchao.net/quodlibet/wiki/Development/Mutagen

This module is more-or-less exactly what I needed. However, I am running
into problems when the filenames or ID tags have unicode characters in
them.

Typically, I do something like:

from mutagen.easyid3 import EasyID3

audio["title'] = Something based on the filename that has unicode
chars in it

I then get this:

UnicodeDecodeError: 'ascii' codec can't decode byte 0xfc in position
56: ordinal not in range(128)
From the docs:
"""Mutagen has full Unicode support for all formats. When you assign
text strings, we strongly recommend using Python unicode objects
rather than str objects. If you use str objects, Mutagen will assume
they are in UTF-8."""

So I suppose the value you try to assign as title is not unicode,
check the encoding used in the file system.

Iñigo

I am trying to set the title based on the filename. The file is in a Win32
NTFS filesystem, so it could have non-ASCII chars in it. What I am stumbling
on it how to coerce it into unicode. I have tried:

name = filename.split(....) blah blah blah
audio["title"] = unicode(name)

But I still get this error. I am not real up to speed on the whole unicode
end of things, so any kind suggestions would be most welcome.

By the way, I believe the offending string contains a German umlaut, at least in one
of the cases.


Similarly, when I just try to *read* a tag, I get these kinds of errors:

print audio["title"]

Will sometimes choke ...

Thanks for the help..
 
I

Iain King

Tim said:
Iñigo Serna said:
try mutagen.
http://www.sacredchao.net/quodlibet/wiki/Development/Mutagen

This module is more-or-less exactly what I needed. However, I am running
into problems when the filenames or ID tags have unicode characters in
them.

Typically, I do something like:

from mutagen.easyid3 import EasyID3

audio["title'] = Something based on the filename that has unicode
chars in it

I then get this:

UnicodeDecodeError: 'ascii' codec can't decode byte 0xfc in position
56: ordinal not in range(128)
From the docs:
"""Mutagen has full Unicode support for all formats. When you assign
text strings, we strongly recommend using Python unicode objects
rather than str objects. If you use str objects, Mutagen will assume
they are in UTF-8."""

So I suppose the value you try to assign as title is not unicode,
check the encoding used in the file system.

Iñigo

I am trying to set the title based on the filename. The file is in a Win32
NTFS filesystem, so it could have non-ASCII chars in it. What I am stumbling
on it how to coerce it into unicode. I have tried:

name = filename.split(....) blah blah blah
audio["title"] = unicode(name)

But I still get this error. I am not real up to speed on the whole unicode
end of things, so any kind suggestions would be most welcome.

By the way, I believe the offending string contains a German umlaut, at least in one
of the cases.

To get the MP3's name, use os.path.basename (I'm guessing that's what
your split() is for?)
Looking at the mutagen tutorial, most of the tags are lists of unicode
strings, so you might want to try audio["title"] = [unicode(name)],
instead of audio["title"] = unicode(name). This might be your problem
when reading the tags, too.

Iain
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top