[SCM] morituri/master: * morituri/image/table.py: * morituri/test/test_image_table.py: Correctly calculate MusicBrainz disc id for enhanced cd's.

js at users.alioth.debian.org js at users.alioth.debian.org
Sun Oct 19 20:08:58 UTC 2014


The following commit has been merged in the master branch:
commit 54d4cecd3445ee8fb51e6af4b963725a795898d2
Author: Thomas Vander Stichele <thomas (at) apestaart (dot) org>
Date:   Thu May 7 15:06:37 2009 +0000

    	* morituri/image/table.py:
    	* morituri/test/test_image_table.py:
    	  Correctly calculate MusicBrainz disc id for enhanced cd's.

diff --git a/ChangeLog b/ChangeLog
index d1b14e0..452b5fa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2009-05-07  Thomas Vander Stichele  <thomas at apestaart dot org>
 
+	* morituri/image/table.py:
+	* morituri/test/test_image_table.py:
+	  Correctly calculate MusicBrainz disc id for enhanced cd's.
+
+2009-05-07  Thomas Vander Stichele  <thomas at apestaart dot org>
+
 	* morituri/common/task.py:
 	  Log on runners too.
 	* morituri/program/cdrdao.py:
diff --git a/morituri/image/table.py b/morituri/image/table.py
index e4e8dfb..d8b019a 100644
--- a/morituri/image/table.py
+++ b/morituri/image/table.py
@@ -147,6 +147,13 @@ class IndexTable(object, log.Loggable):
         """
         return len([t for t in self.tracks if t.audio])
 
+    def hasDataTracks(self):
+        """
+        @returns: whether this disc contains data tracks
+        """
+        return len([t for t in self.tracks if not t.audio]) > 0
+
+
     def _cddbSum(self, i):
         ret = 0
         while i > 0:
@@ -202,8 +209,16 @@ class IndexTable(object, log.Loggable):
         # number of last track
         sha1.update("%02X" % self.getAudioTracks())
 
+        leadout = self.leadout
+        # if the disc is multi-session, last track is the data track,
+        # and we should subtract 11250 + 150 from the last track's offset
+        # for the leadout
+        if self.hasDataTracks():
+            assert not self.tracks[-1].audio
+            leadout = self.tracks[-1].getIndex(1).absolute - 11250 - 150
+
         # treat leadout offset as track 0 offset
-        sha1.update("%08X" % (150 + self.leadout))
+        sha1.update("%08X" % (150 + leadout))
 
         # offsets of tracks
         for i in range(1, 100):
diff --git a/morituri/test/test_image_table.py b/morituri/test/test_image_table.py
index 42014db..9a82135 100644
--- a/morituri/test/test_image_table.py
+++ b/morituri/test/test_image_table.py
@@ -40,10 +40,9 @@ class LadyhawkeTestCase(unittest.TestCase):
         self.assertEquals(self.table.getCDDBDiscId(), "c60af50d")
 
     def testMusicBrainz(self):
-        # FIXME: doesn't seem to be the correct id, so try the example on this
         # track
-        #print self.table.getMusicBrainzDiscId()
-        pass
+        self.assertEquals(self.table.getMusicBrainzDiscId(),
+            "qrJJkrLvXz5Nkvym3oZM4KI9U4A-")
 
     def testAccurateRip(self):
         self.assertEquals(self.table.getAccurateRipIds(), (

-- 
morituri packaging



More information about the pkg-multimedia-commits mailing list