* 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.
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user