Accessing mp3 Meta-Data with Python
<p>What is the best way to retrieve mp3 metadata in python?  I've seen a couple frameworks out there, but I'm unsure as to which would be the best to use.... Any ideas?</p>

<p>I used <a href="http://eyed3.nicfit.net/">eyeD3</a> 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 download the tar and execute <code>python setup.py install</code> from the source folder.  </p>

<p>Relevant examples from the website are below.</p>

<p>Reading the contents of an mp3 file containing either v1 or v2 tag info:</p>

<pre><code> import eyeD3
 tag = eyeD3.Tag()
 tag.link("/some/file.mp3")
 print tag.getArtist()
 print tag.getAlbum()
 print tag.getTitle()
</code></pre>

<p>Read an mp3 file (track length, bitrate, etc.) and access it's tag:</p>

<pre><code>if eyeD3.isMp3File(f):
     audioFile = eyeD3.Mp3AudioFile(f)
     tag = audioFile.getTag()
</code></pre>

<p>Specific tag versions can be selected:</p>

<pre><code> tag.link("/some/file.mp3", eyeD3.ID3_V2)
 tag.link("/some/file.mp3", eyeD3.ID3_V1)
 tag.link("/some/file.mp3", eyeD3.ID3_ANY_VERSION)  # The default.
</code></pre>

<p>Or you can iterate over the raw frames:</p>

<pre><code> tag = eyeD3.Tag()
 tag.link("/some/file.mp3")
 for frame in tag.frames:
    print frame
</code></pre>

<p>Once a tag is linked to a file it can be modified and saved:</p>

<pre><code> tag.setArtist(u"Cro-Mags")
 tag.setAlbum(u"Age of Quarrel")
 tag.update()
</code></pre>

<p>If the tag linked in was v2 and you'd like to save it as v1:</p>

<pre><code> tag.update(eyeD3.ID3_V1_1)
</code></pre>

<p>Read in a tag and remove it from the file:</p>

<pre><code> tag.link("/some/file.mp3")
 tag.remove()
 tag.update()
</code></pre>

<p>Add a new tag:</p>

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