Question

I have the following python script in a folder with a mp3 file:

import os
import eyed3

def track(file):
    tag = eyed3.load(file)
    tag.tag.comment = u"teststring"
    tag.tag.genre = u"Pop"
    tag.tag.save()

for fn in os.listdir('.'):
    print fn[-3:]
    if fn[-3:] == 'mp3':
        track(fn)

The 'genre' is set or changed correctly, but my comment is just adding some garbage. I added a 'Test' in winamp to the comment, and after I run my script and output the ID3 info from the commandline, I see this:

ys3(01).mp3 [ 3.86 MB ]
-------------------------------------------------------------------------------
Time: 03:02 MPEG1, Layer III    [ ~177 kb/s @ 48000 Hz - Joint stereo ]
-------------------------------------------------------------------------------
ID3 v2.3:
title: WANDERERS FROM YS    - ?
artist: 
album: 
track:      genre: Pop (id 13)
Comment: [Description: ] [Lang: eng]
Test
Comment: [Description: ÿþÿ] [Lang: eng]
þ
-------------------------------------------------------------------------------

Am I passing the 'Comment' in the wrong way?

Was it helpful?

Solution

I don't pretend to understand why this is the way it is, but check out how comments are set in the handy example file:

from eyed3.id3 import Tag

t = Tag()
t.comments.set(u"Gritty, yo!")

I believe this has to do with comments being placed into frames, but others may have to chime in with corrections on that. Note that this will fail unless you pass it unicode.

This works on version:

↪ eyeD3 --version
eyeD3 0.7.4-beta (C) Copyright 2002-2013 Travis Shirk

OTHER TIPS

Your approach seems correct, but the comment property of tag in the eyed3 library is not a simple attribute, but one which uses a setter function:

audiofile.tag.comments.set(comment)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top