Pytagger
Pure Python ID3v1/ID3v2 Reader/Writer Library. More info visit: http://www.liquidx.net/pytagger/
Check out from SVN:
svn co http://svn.liquidx.net/svn/python/pytagger/trunk pytagger
Browse the source via the web interface here: /pytagger/trunk
Example
Snippet of code to extract pictures from MP3s.
id3 = ID3v2(filename)
if not id3.tag_exists():
return "No ID3 Tag Found"
apicfid = 'APIC'
if id3.version == 2.2:
apicfid = 'PIC'
try:
apicframe = [frame for frame in id3.frames if frame.fid == apicfid][0]
except IndexError:
return "No APIC frame found"
print "APIC: encoding: %s type: %d" % (apicframe.encoding, apicframe.picttype)
open('test.png', 'w').write(apicframe.pict)
Example to replace an image in an MP#3
id3 = ID3v2(filename)
apicfid = 'APIC'
if id3.version == 2.2:
apicfid = 'PIC'
apic = id3.new_frame(fid = apicfid)
apic.encoding = 'latin_1'
apic.mimetype = 'image/png'
apic.picttype = 0
apic.desc = ''
apic.pict = open('liquidx.png').read()
# replace apic frame
id3.frames = [frame for frame in id3.frames if frame.fid != apicfid]
id3.frames.append(apic)
id3.commit()
Check out the code in /pytagger/trunk/apic.py
Questions
* tagcreation? - Please! Can someone help me out with a problem regarding id3v2 tag creation.




Atom Feed for the Blog Entries