[SCM] morituri/master: * morituri/image/image.py: Add an object to parse the response of AccurateRip. * morituri/test/test_image_image.py: * morituri/test/dBAR-011-0010e284-009228a3-9809ff0b.bin (added): Add a test for it, based on my Kings Of Leon CD.
js at users.alioth.debian.org
js at users.alioth.debian.org
Sun Oct 19 20:08:46 UTC 2014
The following commit has been merged in the master branch:
commit 362d835829d82c27e8a0ad94598edefc6a8e9af5
Author: Thomas Vander Stichele <thomas (at) apestaart (dot) org>
Date: Mon Apr 13 18:13:32 2009 +0000
* morituri/image/image.py:
Add an object to parse the response of AccurateRip.
* morituri/test/test_image_image.py:
* morituri/test/dBAR-011-0010e284-009228a3-9809ff0b.bin (added):
Add a test for it, based on my Kings Of Leon CD.
diff --git a/ChangeLog b/ChangeLog
index d1302ff..848bf76 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,14 @@
2009-04-13 Thomas Vander Stichele <thomas at apestaart dot org>
* morituri/image/image.py:
+ Add an object to parse the response of AccurateRip.
+ * morituri/test/test_image_image.py:
+ * morituri/test/dBAR-011-0010e284-009228a3-9809ff0b.bin (added):
+ Add a test for it, based on my Kings Of Leon CD.
+
+2009-04-13 Thomas Vander Stichele <thomas at apestaart dot org>
+
+ * morituri/image/image.py:
Add the 150 frames for the leadin only to the CDDB calculation.
Add methods to calculate AccurateRip id's and URL.
* morituri/test/test_image_image.py:
diff --git a/morituri/image/image.py b/morituri/image/image.py
index 45f5193..bdd36e8 100644
--- a/morituri/image/image.py
+++ b/morituri/image/image.py
@@ -25,6 +25,7 @@ Wrap on-disk CD images based on the .cue file.
"""
import os
+import struct
import gst
@@ -307,3 +308,32 @@ class ImageVerifyTask(MultiTask):
self.lengths[trackIndex] = end - offset
MultiTask.stop(self)
+
+class AccurateRipResponse(object):
+ """
+ I represent the response of the AccurateRip online database.
+ """
+
+ trackCount = None
+ discId1 = ""
+ discId2 = ""
+ cddbDiscId = ""
+ confidences = None
+ crcs = None
+
+ def __init__(self, data):
+ self.trackCount = struct.unpack("B", data[0])[0]
+ self.discId1 = "%08x" % struct.unpack("<L", data[1:5])[0]
+ self.discId2 = "%08x" % struct.unpack("<L", data[5:9])[0]
+ self.cddbDiscId = "%08x" % struct.unpack("<L", data[9:13])[0]
+
+ self.confidences = []
+ self.crcs = []
+
+ pos = 13
+ for i in range(self.trackCount):
+ confidence = struct.unpack("B", data[pos])[0]
+ crc = "%08x" % struct.unpack("<L", data[pos + 1:pos + 5])[0]
+ pos += 9
+ self.confidences.append(confidence)
+ self.crcs.append(crc)
diff --git a/morituri/test/dBAR-011-0010e284-009228a3-9809ff0b.bin b/morituri/test/dBAR-011-0010e284-009228a3-9809ff0b.bin
new file mode 100644
index 0000000..a1053ca
Binary files /dev/null and b/morituri/test/dBAR-011-0010e284-009228a3-9809ff0b.bin differ
diff --git a/morituri/test/test_image_image.py b/morituri/test/test_image_image.py
index 9a872f5..d803fca 100644
--- a/morituri/test/test_image_image.py
+++ b/morituri/test/test_image_image.py
@@ -82,6 +82,20 @@ class AudioLengthTestCase(unittest.TestCase):
runner = task.SyncRunner()
runner.run(t, verbose=False)
self.assertEquals(t.length, 5880)
-
-
+class AccurateRipResponseTestCase(unittest.TestCase):
+ def testResponse(self):
+ path = os.path.join(os.path.dirname(__file__),
+ 'dBAR-011-0010e284-009228a3-9809ff0b.bin')
+ data = open(path, "rb").read()
+ response = image.AccurateRipResponse(data)
+
+ self.assertEquals(response.trackCount, 11)
+ self.assertEquals(response.discId1, "0010e284")
+ self.assertEquals(response.discId2, "009228a3")
+ self.assertEquals(response.cddbDiscId, "9809ff0b")
+
+ for i in range(11):
+ self.assertEquals(response.confidences[i], 35)
+ self.assertEquals(response.crcs[0], "beea32c8")
+ self.assertEquals(response.crcs[10], "acee98ca")
--
morituri packaging
More information about the pkg-multimedia-commits
mailing list