leosongwei / mutagen

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

mutagen.File($filename), can't save changes #129

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I can get and set my tags for files and load them into my program no problem.

But, when I try to save changes i get the same error as issue 64.
http://code.google.com/p/mutagen/issues/detail?id=64

I can't find any information besides that issue.

This code recreates the issue, (just shortened mine to fit) it's happening with 
every file i try.

### CODE ###

import mutagen

current_files = ['/home/user/test.mp3', '/home/user/test1.mp3', 
'/home/user/test2.mp3']

for files in current_files:
    try:
        item = mutagen.File(files)
    except:
        print 'Tag error: ' + files
        item = None
        pass
    if item:
        # get the current tags
        current_title = str(item.get('TIT2'))  
        # set changes
        if 'example' != current_title:
            item['TIT2'] = 'example'
        ### id3.error ID3 already exists ###
        try:
            item.add_tags(mutagen.easyid3.EasyID3)
        except:
            pass
        ### AttributeError: 'str' object has no attribute '_writeData' ###
        item.save()

Original issue reported on code.google.com by Lachlan...@gmail.com on 13 Nov 2012 at 11:35

GoogleCodeExporter commented 9 years ago
Sorry for the late answer.

As pointed out in issue 64, you're not using EasyID3. Call 
mutagen.File(easy=True) to get an EasyID3 instance, or use EasyID3/EasyMP3 
directly.

ID3 only takes Frames as dict values, no strings (see 
https://mutagen.readthedocs.org/en/latest/tutorial.html#hard-examples-id3)

Original comment by reiter.christoph@gmail.com on 2 Apr 2013 at 2:28