quodlibet / mutagen

Python module for handling audio metadata
https://mutagen.readthedocs.io
GNU General Public License v2.0
1.54k stars 158 forks source link

id3: Document ID3 frame keys #212

Open lazka opened 9 years ago

lazka commented 9 years ago

Originally reported by: Anonymous


I am running mutagen 1.2. When I run the code on Windows I get a different result than on Linux. The key of the COMM frame in the dictionary of frames is different. Here is example code:

#!python

from mutagen.id3 import ID3, COMM

def creat(file):
    audio = ID3(file)
    audio.add(COMM(desc="iTunNORM", lang="eng", text="000", encoding=3))
    audio.save()

file = 'muta.mp3'
creat(file)
audio = ID3(file)
print(audio)

# on Windows this outputs:
# {u'COMM:iTunNORM:eng': COMM(encoding=3, lang='eng', desc=u'iTunNORM', text=[u'000']), 'TIT2': TIT2(encoding=0, text=[u'test'])}

# on Linux this outputs:
# {u"COMM:iTunNORM:'eng'": COMM(encoding=3, lang='eng', desc=u'iTunNORM', text=[u'000']), 'TIT2': TIT2(encoding=0, text=[u'test'])}

# in the key, there are single quotes around eng for Linux but not for Windows

if audio.get(u"COMM:iTunNORM:'eng'"):
    print('on linux')
if audio.get(u"COMM:iTunNORM:eng"):
    print('on windows')

lazka commented 8 years ago

Original comment by Christoph Reiter (Bitbucket: lazka, GitHub: lazka):


Thanks for the added info.

There should be some documentation about frame keys, so leaving this open for now.

lazka commented 8 years ago

Original comment by Daniel Plachotich (Bitbucket: danpla, GitHub: danpla):


Mutagen 1.2 is very outdated. It uses %r to represent lang (f580734) while newer versions use %s. That's why you got extra quotes. Simply update mutagen to the recent version on Linux.

I think the issue can be closed.

lazka commented 9 years ago

Original comment by Christoph Reiter (Bitbucket: lazka, GitHub: lazka):


That's probably due to different mutagen versions and some fallout from the Python3 porting.

You can use audio.getall('COMM:iTunNORM') to get a list of COMM frames with a "iTunNORM" description.