From 54d4cecd3445ee8fb51e6af4b963725a795898d2 Mon Sep 17 00:00:00 2001 From: Thomas Vander Stichele Date: Thu, 7 May 2009 15:06:37 +0000 Subject: [PATCH] * morituri/image/table.py: * morituri/test/test_image_table.py: Correctly calculate MusicBrainz disc id for enhanced cd's. --- ChangeLog | 6 ++++++ morituri/image/table.py | 17 ++++++++++++++++- morituri/test/test_image_table.py | 5 ++--- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index d1b14e0..452b5fa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2009-05-07 Thomas Vander Stichele + + * 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 * morituri/common/task.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(), (