Package: mc-foo Version: 0.0.13 Severity: minor The attached patch makes mc-foo use the Mutagen ID3 reader (in python-mutagen) instead of ID3.py (in python-id3). Switching to Mutagen allows mc-foo to read ID3v2 tags of all versions, have proper Unicode support, and read multiple values and an extended date format in a way similar to Vorbis tags. Mutagen has no external dependencies on other libraries.
Two notes about the patch: * c["GENRE"] was being set to a string rather than a list of strings (like the other tags, and the Vorbis code). I understood this to be a bug; the Mutagen code currently sets it to a list of strings * c["YEAR"] is being set instead of c["DATE"], but the latter is much more common. I didn't fix this, but the TDRC frame Mutagen reads is capable of a full date, as opposed to the ID3v1 year. If there are any problems with the patch, I'll be happy to fix them. -- Joe Wreschnig <[EMAIL PROTECTED]>
--- file.py.old 2006-03-11 12:07:38.000000000 -0600
+++ file.py 2006-03-11 12:52:11.000000000 -0600
@@ -1,9 +1,9 @@
-import ID3
import string
import exceptions
import os.path
from errno import ENOENT
+from mutagen.id3 import ID3, error as ID3Error
McFooBackendFileUnknownFormat='McFooBackendFileUnknownFormat'
McFooBackendFileDoesNotExist='McFooBackendFileDoesNotExist'
@@ -91,25 +91,21 @@
return (buf, len(buf), 0)
def comment(self):
try:
- id3=ID3.ID3(self.filename)
- except ID3.InvalidTagError:
+ id3 = ID3(self.filename)
+ except ID3Error:
return {}
c={}
- c['TITLE']=[string.strip(id3.title)]
- c['ARTIST']=[string.strip(id3.artist)]
- c['ALBUM']=[string.strip(id3.album)]
- c['YEAR']=[string.strip(id3.year)]
- genre=id3.genre
- try:
- genre=id3.genres[genre]
- except IndexError:
- genre=str(genre)
- c['GENRE']=genre
- c['COMMENT']=[string.strip(id3.comment)]
- for key in c.keys():
- if len(c[key])==1 and c[key][0]=='':
- del c[key]
+ for frame, name in [
+ ("TIT2", "TITLE"),
+ ("TPE1", "ARTIST"),
+ ("TALB", "ALBUM"),
+ ("TDRC", "YEAR")]:
+ try: c[name] = list(id3[name])
+ except KeyError: pass
+ if "TCON" in id3: self["GENRE"] = id3["TCON"].genres
+ comments = id3.getall("COMM")
+ if comments: c["COMMENT"] = sum([list(c) for c in comments], [])
return c
def time_total(self):
return 0
signature.asc
Description: This is a digitally signed message part

