summaryrefslogtreecommitdiff
path: root/debian/patches/93_extd_parsing.patch
blob: 7eec713d062b94e706d0bfac183bb529725df3fb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
Make the parsing of year and genre in EXTD less restrictive.  Now it will
recognize the year even if there is no genre and if there is space instead
of newline between year and EXTD.  Debian #341891.

Depends on 84_dyear_dgenre.patch

diff -urN jack-3.1.1~/jack_freedb.py jack-3.1.1/jack_freedb.py
--- jack-3.1.1~/jack_freedb.py	2005-12-03 21:50:24.000000000 +0000
+++ jack-3.1.1/jack_freedb.py	2005-12-03 21:57:59.000000000 +0000
@@ -449,22 +449,22 @@
                 genre = [x.upper() for x in id3genres].index(freedb['DGENRE'].upper())
         else:
             warning("DGENRE should be a string, not an integer.")
+    if freedb.has_key('EXTD') and not freedb.has_key('DYEAR'):
+        extra_tag_pos = string.find(freedb['EXTD'], "YEAR:")
+        if extra_tag_pos >= 0:
+            arg = freedb['EXTD'][extra_tag_pos + 5:].lstrip().split()[0]
+            if arg.isdigit():
+                year = int(arg)
+    if freedb.has_key('EXTD') and not freedb.has_key('DGENRE'):
+        extra_tag_pos = string.find(freedb['EXTD'], "ID3G:")
+        if extra_tag_pos >= 0:
+            arg = freedb['EXTD'][extra_tag_pos + 5:].lstrip().split()[0]
+            if arg.isdigit():
+                genre = int(arg)
     if genre != -1:
         names[0].extend([year, genre])
     elif year != -1:
         names[0].extend([year])
-    if freedb.has_key('EXTD') and not(freedb.has_key('DYEAR') or freedb.has_key('DGENRE')):
-        extra_tag_pos = string.find(freedb['EXTD'], "\\nYEAR:")
-        if extra_tag_pos >= 0:
-            try:
-                extd_info = freedb['EXTD'][extra_tag_pos + 7:]
-                extd_year, extd_id3g = string.split(extd_info, "ID3G:", 1)
-                extd_year, extd_id3g = int(extd_year), int(extd_id3g)
-            except:
-                print "can't handle '%s'." % freedb['EXTD']
-            else:
-                names = [string.split(dtitle, "/", 1)]
-                names[0].extend([extd_year, extd_id3g])
     if names[0][0] == "(unknown artist)":
         if verb:
             warning("the disc's title must be set to \"artist / title\" (\"DTITLE\").")