[xiph-cvs] cvs commit: positron/positron MP3Info.py
Stan Seibert
volsung at xiph.org
Thu Sep 18 21:14:22 PDT 2003
volsung 03/09/19 00:14:22
Modified: positron MP3Info.py
Log:
Handle genre tags that consist of multiple genre numbers.
Revision Changes Path
1.13 +12 -3 positron/positron/MP3Info.py
Index: MP3Info.py
===================================================================
RCS file: /usr/local/cvsroot/positron/positron/MP3Info.py,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- MP3Info.py 3 Jul 2003 04:42:05 -0000 1.12
+++ MP3Info.py 19 Sep 2003 04:14:22 -0000 1.13
@@ -32,6 +32,7 @@
import struct
import string
import random
+import re
def _from_synch_safe(synchsafe):
if isinstance(synchsafe, type(1)):
@@ -512,6 +513,9 @@
self._parse_xing(file, 0, seeklimit)
class MP3Info:
+
+ num_regex = re.compile("\d+")
+
def __init__(self, file):
self.valid = 0
@@ -562,9 +566,14 @@
elif tag == 'TCO' or tag == 'TCON':
self.genre = self.id3.tags[tag]
if self.genre and self.genre[0] == '(' and self.genre[-1] == ')':
- try:
- self.genre = _genres[int(self.genre[1:-1])]
- except IndexError:
+ genres = self.num_regex.findall(self.genre)
+ if len(genres) > 0:
+ try:
+ # Force to single valued even if multiple
+ self.genre = _genres[int(genres[0])]
+ except IndexError:
+ self.genre = ""
+ else:
self.genre = ""
elif tag == 'TEN' or tag == 'TENC':
self.encoder = self.id3.tags[tag]
<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