leosongwei / mutagen

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

TypeError: 'property' object has no attribute '__getitem__' #154

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Made my own tag editor using Mutagen. Worked fine so far but now I get a python 
error from Mutagen. Most likely I've done something wrong but perhaps it's more 
interesting.

    audio.save()
  File "/usr/lib/python2.7/dist-packages/mutagen/id3.py", line 362, in save
    frames.sort(lambda a, b: cmp(order.get(a[0][:4], last),
  File "/usr/lib/python2.7/dist-packages/mutagen/id3.py", line 362, in <lambda>
    frames.sort(lambda a, b: cmp(order.get(a[0][:4], last),
TypeError: 'property' object has no attribute '__getitem__'

This happened when writing files from an album called "Quinta Essentia" from an 
artist called "TAT". Reading the file was no problem.

The album is available (for free) from the artist's website: 
http://www.tat-music.com/  (see bottom of that site).

Original issue reported on code.google.com by CaesarTj...@gmail.com on 1 Jun 2013 at 11:53

GoogleCodeExporter commented 9 years ago
It seems to have something to do with the COMM tag in MP3, perhaps when there's 
more than 1 present. A workaround appears to be to use delall('COMM') prior to 
setting COMM tags.

Original comment by CaesarTj...@gmail.com on 4 Jun 2013 at 9:16

GoogleCodeExporter commented 9 years ago
Do you have a code example that triggers the error? save() works here with the 
above album...

Original comment by reiter.christoph@gmail.com on 4 Jun 2013 at 11:40

GoogleCodeExporter commented 9 years ago
It gets triggered with the save() in my code. Clearly, I'm doing something 
wrong and I've already found a way to do it better. My python cleverness isn't 
good enough to grok the mutagen code, so trial and error pulls me through.

http://pastebin.com/dqinHaT2

So I guess my way of setting the COMM tag is an example of how not to do it 
(perhaps in more ways than one) but it does trigger that exception in mutagen. 
I'm very happy with mutagen, works beautifully.

Original comment by CaesarTj...@gmail.com on 5 Jun 2013 at 8:51

GoogleCodeExporter commented 9 years ago
You are passing in a COMM class instead of an instance.

dummy = mutagen.id3.COMM(encoding=..., text=..., desc=..., lang=...)

Original comment by reiter.christoph@gmail.com on 6 Jun 2013 at 2:07

GoogleCodeExporter commented 9 years ago
Thank you.

My code was developed organically, or code-as-I-went. The mutagen layer gave me 
very few headaches so I hadn't revisited since coding it. Will do that now.

Original comment by CaesarTj...@gmail.com on 7 Jun 2013 at 2:03