* 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>
|
2009-06-07 Thomas Vander Stichele <thomas at apestaart dot org>
|
||||||
|
|
||||||
* morituri/common/program.py:
|
* morituri/common/program.py:
|
||||||
|
|||||||
@@ -127,21 +127,26 @@ class Program(object):
|
|||||||
|
|
||||||
@ivar metadata:
|
@ivar metadata:
|
||||||
@type metadata: L{DiscMetadata}
|
@type metadata: L{DiscMetadata}
|
||||||
|
@ivar result: the rip's result
|
||||||
|
@type result: L{result.RipResult}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
cuePath = None
|
cuePath = None
|
||||||
logPath = None
|
logPath = None
|
||||||
metadata = None
|
metadata = None
|
||||||
outdir = None
|
outdir = None
|
||||||
|
result = None
|
||||||
def __init__(self):
|
|
||||||
self.result = result.RipResult()
|
|
||||||
|
|
||||||
def _getTableCachePath(self):
|
def _getTableCachePath(self):
|
||||||
path = os.path.join(os.path.expanduser('~'), '.morituri', 'cache',
|
path = os.path.join(os.path.expanduser('~'), '.morituri', 'cache',
|
||||||
'table')
|
'table')
|
||||||
return path
|
return path
|
||||||
|
|
||||||
|
def _getResultCachePath(self):
|
||||||
|
path = os.path.join(os.path.expanduser('~'), '.morituri', 'cache',
|
||||||
|
'result')
|
||||||
|
return path
|
||||||
|
|
||||||
def unmountDevice(self, device):
|
def unmountDevice(self, device):
|
||||||
"""
|
"""
|
||||||
Unmount the given device if it is mounted, as happens with automounted
|
Unmount the given device if it is mounted, as happens with automounted
|
||||||
@@ -174,6 +179,32 @@ class Program(object):
|
|||||||
|
|
||||||
return itable
|
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):
|
def getPath(self, outdir, template, mbdiscid, i):
|
||||||
"""
|
"""
|
||||||
Based on the template, get a complete path for the given track,
|
Based on the template, get a complete path for the given track,
|
||||||
|
|||||||
@@ -93,6 +93,7 @@ class Rip(logcommand.LogCommand):
|
|||||||
assert ittoc.hasTOC()
|
assert ittoc.hasTOC()
|
||||||
|
|
||||||
# already show us some info based on this
|
# already show us some info based on this
|
||||||
|
prog.getRipResult(ittoc.getCDDBDiscId())
|
||||||
print "CDDB disc id", ittoc.getCDDBDiscId()
|
print "CDDB disc id", ittoc.getCDDBDiscId()
|
||||||
mbdiscid = ittoc.getMusicBrainzDiscId()
|
mbdiscid = ittoc.getMusicBrainzDiscId()
|
||||||
print "MusicBrainz disc id", mbdiscid
|
print "MusicBrainz disc id", mbdiscid
|
||||||
@@ -135,6 +136,7 @@ class Rip(logcommand.LogCommand):
|
|||||||
profile = encode.PROFILES[self.options.profile]()
|
profile = encode.PROFILES[self.options.profile]()
|
||||||
|
|
||||||
# result
|
# result
|
||||||
|
|
||||||
prog.result.offset = int(self.options.offset)
|
prog.result.offset = int(self.options.offset)
|
||||||
prog.result.artist = prog.metadata and prog.metadata.artist or 'Unknown Artist'
|
prog.result.artist = prog.metadata and prog.metadata.artist or 'Unknown Artist'
|
||||||
prog.result.title = prog.metadata and prog.metadata.title or 'Unknown Title'
|
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
|
# FIXME: turn this into a method
|
||||||
def ripIfNotRipped(number):
|
def ripIfNotRipped(number):
|
||||||
trackResult = result.TrackResult()
|
# we can have a previous result
|
||||||
prog.result.tracks.append(trackResult)
|
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,
|
path = prog.getPath(prog.outdir, self.options.track_template,
|
||||||
mbdiscid, number) + '.' + profile.extension
|
mbdiscid, number) + '.' + profile.extension
|
||||||
@@ -186,6 +191,8 @@ class Rip(logcommand.LogCommand):
|
|||||||
itable.setFile(number, 1, path, ittoc.getTrackLength(number),
|
itable.setFile(number, 1, path, ittoc.getTrackLength(number),
|
||||||
number)
|
number)
|
||||||
|
|
||||||
|
prog.saveRipResult()
|
||||||
|
|
||||||
|
|
||||||
# check for hidden track one audio
|
# check for hidden track one audio
|
||||||
htoa = prog.getHTOA()
|
htoa = prog.getHTOA()
|
||||||
|
|||||||
Reference in New Issue
Block a user