Accessing MP3 metadata with Python

Question :

Accessing MP3 metadata with Python,

Answer :

Is there a maintained package I can use to retrieve and set MP3 ID3 metadata using Python?


I used  the other day with a lot of success. I found that it could add artwork to the ID3 tag which the other modules I looked at couldn’t. You’ll have to install using pip or download the tar and execute python install from the source folder.

Relevant examples from the website are below.

Reading the contents of an mp3 file containing either v1 or v2 tag info:

 import eyeD3   tag = eyeD3.Tag()"/some/file.mp3")   print tag.getArtist()   print tag.getAlbum()   print tag.getTitle()  

Read an mp3 file (track length, bitrate, etc.) and access it’s tag:

if eyeD3.isMp3File(f):       audioFile = eyeD3.Mp3AudioFile(f)       tag = audioFile.getTag()  

Specific tag versions can be selected:"/some/file.mp3", eyeD3.ID3_V2)"/some/file.mp3", eyeD3.ID3_V1)"/some/file.mp3", eyeD3.ID3_ANY_VERSION)  # The default.  

Or you can iterate over the raw frames:

 tag = eyeD3.Tag()"/some/file.mp3")   for frame in tag.frames:      print frame  

Once a tag is linked to a file it can be modified and saved:

 tag.setArtist(u"Cro-Mags")   tag.setAlbum(u"Age of Quarrel")   tag.update()  

If the tag linked in was v2 and you’d like to save it as v1:


Read in a tag and remove it from the file:"/some/file.mp3")   tag.remove()   tag.update()  

Add a new tag:

 tag = eyeD3.Tag()'/some/file.mp3')    # no tag in this file, link returned False   tag.header.setVersion(eyeD3.ID3_V2_3)   tag.setArtist('Fugazi')   tag.update()  

That’s the answer Accessing MP3 metadata with Python, Hope this helps those looking for an answer. Then we suggest to do a search for the next question and find the answer only on our site.

Read More  Getting accurate ticks from a timer in C#

Disclaimer :

The answers provided above are only to be used to guide the learning process. The questions above are open-ended questions, meaning that many answers are not fixed as above. I hope this article can be useful, Thank you