Package: morituri
Version: 0.1.2-2

Coin,

Ripping releases with multiple medium is broken, see:
  http://thomas.apestaart.org/morituri/trac/ticket/67

As this is not a rare situation and the main goal of this program, i do not consider this a wish but a bug (thus the severity).

Unfortunately, the next version is probably not coming soon. This bug was closed 4 months ago, not so much activity recently, and there is still much to do:
  http://thomas.apestaart.org/morituri/trac/query?group=status&milestone=0.1.3

Moreover, there is no way to properly solve the situation using python-musicbrainz2 because the new MusicBrainZ's API is necessary to compute which tracks are in the selected medium.

I made a patch to work around this problem. For the first and last medium the track offset can be guessed, and in all other cases the user is asked to manually enter the track offset. I'm not a Python developper, so my patch is probably not the most beautiful ever, but it seems to work nicely.

I think applying this patch would be nice for Wheezy, because the next version will clearly not be ready for it. When the next version is released, this patch would be obsolete and you'd just have to remove it, so there should be no maintenance work.

Regards.

--
Marc Dequènes (Duck)
--- /usr/share/pyshared/morituri/common/program.py.orig	2012-05-15 00:54:00.193503421 +0200
+++ /usr/share/pyshared/morituri/common/program.py	2012-05-17 15:01:24.072825041 +0200
@@ -56,12 +56,25 @@
     mbid = None
     mbidArtist = None
 
+    mbrelease = None
+
     def __init__(self):
         self.tracks = []
 
 def filterForPath(text):
     return "-".join(text.split("/"))
 
+# borrowed from http://kraehen.org/isrcsubmit.py
+# Copyright (C) 2010-2012 Johannes Dewender
+# GPL-3+
+def askForOffset(release, discTrackCount, releaseTrackCount):
+    print
+    print "Could not determine starting track."
+    print "Please look at the following URL: %s" % release.id
+    print "How many tracks are on the previous (actual) discs altogether?"
+    num = raw_input("[0-%d] " % (releaseTrackCount - discTrackCount))
+    return int(num)
+
 def getMetadata(release):
     """
     @rtype: L{DiscMetadata}
@@ -78,10 +91,40 @@
     metadata.mbid = urlparse.urlparse(release.id)[2].split("/")[-1]
     metadata.mbidArtist = urlparse.urlparse(release.artist.id)[2].split("/")[-1]
 
+    metadata.mbrelease = release
+
+    return metadata
+
+def getTracksMetadata(metadata, discid, ittoc):
+    release = metadata.mbrelease
 
-    for t in release.tracks:
+    disc = None
+    discId = 1
+    for d in release.discs:
+        if d.id == discid:
+            disc = d
+            break
+        discId += 1
+    # should never happen
+    if disc is None:
+        raise MusicBrainzException("wanted disc cannot be found in release")
+    print 'Disc ID: %u' % discId
+
+    discTrackCount = ittoc.getAudioTracks()
+    releaseTrackCount = len(release.tracks)
+
+    if discId == 1:
+        trackOffset = 0
+    elif discId == len(release.discs):
+        trackOffset = releaseTrackCount - discTrackCount
+    else:
+        trackOffset = askForOffset(release, discTrackCount, releaseTrackCount)
+    print 'Track Offset: %u' % trackOffset
+
+    for i in range(trackOffset, trackOffset + discTrackCount):
+        t = release.tracks[i]
         track = TrackMetadata()
-        if isSingleArtist or t.artist == None:
+        if not metadata.various or t.artist == None:
             track.artist = metadata.artist
             track.sortName = metadata.sortName
             track.mbidArtist = metadata.mbidArtist
@@ -95,9 +138,6 @@
         track.mbid = urlparse.urlparse(t.id)[2].split("/")[-1]
         metadata.tracks.append(track)
 
-    return metadata
-
-
 def musicbrainz(discid):
     """
     @rtype: list of L{DiscMetadata}
@@ -134,7 +174,7 @@
         # The returned release object only contains title and artist, but no
         # tracks.  Query the web service once again to get all data we need.
         try:
-            inc = mbws.ReleaseIncludes(artist=True, tracks=True,
+            inc = mbws.ReleaseIncludes(artist=True, tracks=True, discs=True,
                 releaseEvents=True)
             # Arid - Under the Cold Street Lights has getId() None
             if release.getId():
@@ -340,6 +380,7 @@
 
             # Select one of the returned releases. We just pick the first one.
             ret = metadatas[0]
+            getTracksMetadata(ret, mbdiscid, ittoc)
         else:
             print 'Submit this disc to MusicBrainz at:'
             print ittoc.getMusicBrainzSubmitURL()

Attachment: pgp4wIP2LE7Kt.pgp
Description: PGP Digital Signature

Reply via email to