summaryrefslogtreecommitdiff
path: root/debian/patches/52_cdparanoia_toc.patch
blob: d3decb49082dfa146fe7228a1ecb0d49f0c5decf (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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
Make the cdparanoia TOC parsing more robust (and clean up the code while
we're at it).  Debian #361164.


This is jack 3.1.1 (C)2004 Arne Zellentin <zarne@users.sf.net>
Traceback (most recent call last):
  File "/usr/bin/jack", line 134, in ?
    jack_prepare.filter_tracks(toc_just_read, status)
  File "/usr/lib/python2.3/site-packages/jack_prepare.py", line 216, in
filter_tracks
    ripper_tracks = jack_functions.gettoc(cf['_ripper'])
  File "/usr/lib/python2.3/site-packages/jack_functions.py", line 125, in
gettoc    exec(jack_helpers.helpers[toc_prog]['toc_fkt'])
  File "<string>", line 10, in ?
ValueError: invalid literal for int(): 401: Invalid track number



diff -urN jack-3.1.1+cvs20050801~/jack_helpers.py jack-3.1.1+cvs20050801/jack_helpers.py
--- jack-3.1.1+cvs20050801~/jack_helpers.py	2006-04-07 03:58:48.000000000 +0200
+++ jack-3.1.1+cvs20050801/jack_helpers.py	2006-04-07 04:25:28.000000000 +0200
@@ -297,19 +297,38 @@
 """,
         #'toc': 1,  # we can't generate correct freedb IDs with cdparanoia.
         'toc_cmd': "cdparanoia -d %d -Q 2>&1",
+# The output from cdparanoia which we parse looks like this:
+
+# cdparanoia III release 9.8 (March 23, 2001)
+# (C) 2001 Monty <monty@xiph.org> and Xiphophorus
+# ...
+# track        length               begin        copy pre ch
+# ===========================================================
+#   1.    13584 [03:01.09]        0 [00:00.00]    no   no  2
+#   2.    13769 [03:03.44]    13584 [03:01.09]    no   no  2
+# ...
+# TOTAL  121128 [26:55.03]    (audio only)
+
+# That is, we look for a line only consisting of === signs as the start,
+# for a line starting with "TOTAL" as the end, and take everything
+# inbetween (to be precise: the first number on each line)
         'toc_fkt': r"""
-while l:
+for l in p.readlines():
     l = string.rstrip(l)
-    if l and l[0:5] == "TOTAL":
+    if not l:
+        continue
+    if l.startswith("TOTAL"):
         start = 0
-    if l and l == '=' * (len(l)):
+    elif l == ('=' * len(l)):
         start = 1
-    elif l and start:
-        l = string.split(l, '.', 1)
-        num = int(l[0])
-        l = string.split(l[1])
-        erg.append([num, int(l[0]), int(l[2]), l[4] == 'OK', l[5] == 'yes', int(l[6]), 1, cf['_bitrate'], cf['_name'] % num])
-    l = p.readline()
+    elif start:
+        l = l.split('.', 1)
+        if l[0].lstrip().isdigit():
+            num = int(l[0])
+            l = l[1].split()
+            erg.append([num, int(l[0]), int(l[2]), l[4] == 'OK', l[5] == 'yes', int(l[6]), 1, cf['_bitrate'], cf['_name'] % num])
+        else:
+            warning("Cannot parse cdrecord TOC line: " + ". ".join(l))
 """,
     },