[SCM] morituri/master: * morituri/common/program.py: * morituri/rip/cd.py: Serialize the rip result after every rip, so we can pick up where we left off with all result data.
js at users.alioth.debian.org
js at users.alioth.debian.org
Sun Oct 19 20:09:08 UTC 2014
The following commit has been merged in the master branch:
commit 1efa2d7b201c685e36006e3e2bf9a9cc7aca81cb
Author: Thomas Vander Stichele <thomas (at) apestaart (dot) org>
Date: Tue Jun 9 19:39:59 2009 +0000
* morituri/common/program.py:
* morituri/rip/cd.py:
Serialize the rip result after every rip, so we can pick up
where we left off with all result data.
diff --git a/ChangeLog b/ChangeLog
index 4c2e5f3..38a8eaa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2009-06-09 Thomas Vander Stichele <thomas at apestaart dot org>
+
+ * morituri/common/program.py:
+ * morituri/rip/cd.py:
+ Serialize the rip result after every rip, so we can pick up
+ where we left off with all result data.
+
2009-06-07 Thomas Vander Stichele <thomas at apestaart dot org>
* morituri/common/program.py:
diff --git a/morituri/common/program.py b/morituri/common/program.py
index e4b98e6..48df85b 100644
--- a/morituri/common/program.py
+++ b/morituri/common/program.py
@@ -127,21 +127,26 @@ class Program(object):
@ivar metadata:
@type metadata: L{DiscMetadata}
+ @ivar result: the rip's result
+ @type result: L{result.RipResult}
"""
cuePath = None
logPath = None
metadata = None
outdir = None
-
- def __init__(self):
- self.result = result.RipResult()
+ result = None
def _getTableCachePath(self):
path = os.path.join(os.path.expanduser('~'), '.morituri', 'cache',
'table')
return path
+ def _getResultCachePath(self):
+ path = os.path.join(os.path.expanduser('~'), '.morituri', 'cache',
+ 'result')
+ return path
+
def unmountDevice(self, device):
"""
Unmount the given device if it is mounted, as happens with automounted
@@ -174,6 +179,32 @@ class Program(object):
return itable
+ def getRipResult(self, cddbdiscid):
+ """
+ Retrieve the persistable RipResult either from our cache (from a
+ previous, possibly aborted rip), or return a new one.
+
+ @rtype: L{result.RipResult}
+ """
+ assert self.result is None
+
+ path = self._getResultCachePath()
+
+ pcache = common.PersistedCache(path)
+ presult = pcache.get(cddbdiscid)
+
+ if not presult.object:
+ presult.object = result.RipResult()
+ presult.persist(self.result)
+
+ self.result = presult.object
+ self._presult = presult
+
+ return self.result
+
+ def saveRipResult(self):
+ self._presult.persist()
+
def getPath(self, outdir, template, mbdiscid, i):
"""
Based on the template, get a complete path for the given track,
diff --git a/morituri/rip/cd.py b/morituri/rip/cd.py
index 23cbb21..de2666c 100644
--- a/morituri/rip/cd.py
+++ b/morituri/rip/cd.py
@@ -93,6 +93,7 @@ class Rip(logcommand.LogCommand):
assert ittoc.hasTOC()
# already show us some info based on this
+ prog.getRipResult(ittoc.getCDDBDiscId())
print "CDDB disc id", ittoc.getCDDBDiscId()
mbdiscid = ittoc.getMusicBrainzDiscId()
print "MusicBrainz disc id", mbdiscid
@@ -135,6 +136,7 @@ class Rip(logcommand.LogCommand):
profile = encode.PROFILES[self.options.profile]()
# result
+
prog.result.offset = int(self.options.offset)
prog.result.artist = prog.metadata and prog.metadata.artist or 'Unknown Artist'
prog.result.title = prog.metadata and prog.metadata.title or 'Unknown Title'
@@ -149,8 +151,11 @@ class Rip(logcommand.LogCommand):
# FIXME: turn this into a method
def ripIfNotRipped(number):
- trackResult = result.TrackResult()
- prog.result.tracks.append(trackResult)
+ # we can have a previous result
+ trackResult = prog.result.getTrackResult(number)
+ if not trackResult:
+ trackResult = result.TrackResult()
+ prog.result.tracks.append(trackResult)
path = prog.getPath(prog.outdir, self.options.track_template,
mbdiscid, number) + '.' + profile.extension
@@ -186,6 +191,8 @@ class Rip(logcommand.LogCommand):
itable.setFile(number, 1, path, ittoc.getTrackLength(number),
number)
+ prog.saveRipResult()
+
# check for hidden track one audio
htoa = prog.getHTOA()
--
morituri packaging
More information about the pkg-multimedia-commits
mailing list