H.v.M.
H.v.M.

Reputation: 1659

ID3-mp3 editing in python - up-to-date package?

Edit: Trying to get these libraries to work in python 3.3 was clearly the wrong approach, and my problem now is entirely different so I'll just re-ask it in a new question.

I want to be able to edit ID3 tags of mp3 files with python commands, for example something like setAlbumName("folderPath\song.mp3", "albumname"). So far I've tried Mutagen, PyID3, pytagger, eyeD3, and they all seem to be outdated because the installation fails due to syntax errors. I tried to fix it in eyeD3, but I hit a dead end: http://i41.tinypic.com/o6zklv.png (second screenshot from after I had fixed all the prints and "except Error, e" and so on).

I tried the same with Mutagen, but I ran into a wall there as well when replacing "raise KeyError, key" with "raise KeyError as key" didn't work.

I didn't even know what to make of this one (pytagger): http://i41.tinypic.com/29fz7mh.png

It seems to suggest that there's something wrong with my python installation? Not getting into that.

So, would anyone like to point me to an ID3 package that works, or have a go at fixing an outdated one?

(Also, I tried both "python setup.py install" and "setup.py install" and it seemed to make no difference. I'm on windows 8.)

Edit: From the screenshot below, plus the source code (mutagen with python 2.7.5)

from mutagen.mp3 import MP3
p = "E:\\Musik\\Aeon\\2005 Bleeding the False\\01 Cenobites - Copy.mp3"
audio = MP3(p)
audio["title"] = "An example"
audio.pprint()
audio.save()

_

Traceback (most recent call last):
  File "id3tag.py", line 5, in <module>
    audio.pprint()
  File "C:\Python27\lib\site-packages\mutagen\__init__.py", line 138, in pprint
    try: tags = self.tags.pprint()
  File "C:\Python27\lib\site-packages\mutagen\id3.py", line 190, in pprint
    frames = list(map(Frame.pprint, self.values()))
TypeError: unbound method pprint() must be called with Frame instance as first a
rgument (got str instance instead)

_

from mutagen.mp3 import MP3
p = "E:\\Musik\\Aeon\\2005 Bleeding the False\\01 Cenobites - Copy.mp3"
audio = MP3(p)
audio["title"] = "An example"
audio.save()

_

Traceback (most recent call last):
  File "id3tag.py", line 7, in <module>
    audio.save()
  File "C:\Python27\lib\site-packages\mutagen\__init__.py", line 132, in save
    return self.tags.save(filename, **kwargs)
  File "C:\Python27\lib\site-packages\mutagen\id3.py", line 370, in save
    framedata = [self.__save_frame(frame) for (key, frame) in frames]
  File "C:\Python27\lib\site-packages\mutagen\id3.py", line 461, in __save_frame

    framedata = frame._writeData()
AttributeError: 'str' object has no attribute '_writeData'

Upvotes: 1

Views: 1181

Answers (2)

LuizAngioletti
LuizAngioletti

Reputation: 296

Mutagen also has an EasyID3 tool, which handles simple tasks like changing the file's title:

from mutagen.easyid3 import EasyID3
f = EasyID3("file.mp3")
f["title"] = u"Some title"
f.save()

Works like a charm. But it has very restricted functionality. See more examples at http://code.google.com/p/mutagen/wiki/Tutorial

Upvotes: 1

Corey Goldberg
Corey Goldberg

Reputation: 60604

mutagen works great for me with Python 2.7.

examples: https://code.google.com/p/mutagen/wiki/Tutorial

from mutagen.mp3 import MP3

audio = MP3("example.mp3")
audio["title"] = "An example"
audio.pprint()
audio.save()

p.s. please post code samples so people can help.. not links to screenshots.

p.p.s. it looks like you are trying to install Python2 libs into Python3.

Upvotes: 1

Related Questions