[xiph-cvs] cvs commit: positron/positron audiofile.py
Stan Seibert
volsung at xiph.org
Thu Sep 18 21:13:29 PDT 2003
volsung 03/09/19 00:13:29
Modified: positron audiofile.py
Log:
Deal with UTF-8 problems in tags gracefully.
Revision Changes Path
1.6 +20 -12 positron/positron/audiofile.py
Index: audiofile.py
===================================================================
RCS file: /usr/local/cvsroot/positron/positron/audiofile.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- audiofile.py 6 Sep 2003 23:02:55 -0000 1.5
+++ audiofile.py 19 Sep 2003 04:13:29 -0000 1.6
@@ -85,20 +85,28 @@
"genre" : None,
"tracknumber" : None}
- actual_keys = map(string.lower, vc.keys())
-
+ actual_keys = []
+ for tag in vc.keys():
+ try:
+ actual_keys.append(tag.lower())
+ except UnicodeError:
+ pass # Don't let bad tags stop us
+
for tag in ("title","artist","album","genre","tracknumber"):
if tag in actual_keys:
- value = vc[tag]
- # Force these to be single valued
- if type(value) == ListType or type(value) == TupleType:
- value = value[0]
-
- # Convert from Unicode to ASCII since the Neuros can't
- # do Unicode anyway.
- #
- # I will probably burn in i18n hell for this.
- info[tag] = value.encode('ascii','replace')
+ try:
+ value = vc[tag]
+ # Force these to be single valued
+ if type(value) == ListType or type(value) == TupleType:
+ value = value[0]
+
+ # Convert from Unicode to ASCII since the Neuros can't
+ # do Unicode anyway.
+ #
+ # I will probably burn in i18n hell for this.
+ info[tag] = value.encode('ascii','replace')
+ except UnicodeError:
+ pass
except ogg.vorbis.VorbisError:
return None
<p><p>--- >8 ----
List archives: http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body. No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.
More information about the commits
mailing list