* morituri/common/encode.py:
* morituri/program/cdparanoia.py: * morituri/rip/cd.py: Clean up the temporary unencoded file. Pass profile as objects to tasks, so that temp files have the right extension.
This commit is contained in:
@@ -1,3 +1,12 @@
|
||||
2009-06-01 Thomas Vander Stichele <thomas at apestaart dot org>
|
||||
|
||||
* morituri/common/encode.py:
|
||||
* morituri/program/cdparanoia.py:
|
||||
* morituri/rip/cd.py:
|
||||
Clean up the temporary unencoded file.
|
||||
Pass profile as objects to tasks, so that temp files have the right
|
||||
extension.
|
||||
|
||||
2009-06-01 Thomas Vander Stichele <thomas at apestaart dot org>
|
||||
|
||||
* morituri/common/encode.py:
|
||||
|
||||
@@ -81,6 +81,8 @@ class EncodeTask(task.Task):
|
||||
|
||||
def __init__(self, inpath, outpath, profile, taglist=None):
|
||||
"""
|
||||
@param profile: encoding profile
|
||||
@type profile: L{Profile}
|
||||
"""
|
||||
self._inpath = inpath
|
||||
self._outpath = outpath
|
||||
@@ -88,7 +90,7 @@ class EncodeTask(task.Task):
|
||||
|
||||
self._level = None
|
||||
self._peakdB = None
|
||||
self._profile = PROFILES[profile]
|
||||
self._profile = profile
|
||||
|
||||
def start(self, runner):
|
||||
task.Task.start(self, runner)
|
||||
@@ -186,5 +188,4 @@ class EncodeTask(task.Task):
|
||||
self.debug('set state to NULL')
|
||||
task.Task.stop(self)
|
||||
|
||||
|
||||
self.peak = math.pow(10, self._peakdB / 10.0)
|
||||
|
||||
@@ -231,6 +231,9 @@ class ReadVerifyTrackTask(task.MultiSeparateTask):
|
||||
@ivar peak: the peak level of the track
|
||||
"""
|
||||
|
||||
_tmpwavpath = None
|
||||
_tmppath = None
|
||||
|
||||
def __init__(self, path, table, start, stop, offset=0, device=None, profile=None):
|
||||
"""
|
||||
@param path: where to store the ripped track
|
||||
@@ -246,7 +249,7 @@ class ReadVerifyTrackTask(task.MultiSeparateTask):
|
||||
@param device: the device to rip from
|
||||
@type device: str
|
||||
@param profile: the encoding profile
|
||||
@type profile: str
|
||||
@type profile: L{encode.Profile}
|
||||
"""
|
||||
task.MultiSeparateTask.__init__(self)
|
||||
|
||||
@@ -255,7 +258,7 @@ class ReadVerifyTrackTask(task.MultiSeparateTask):
|
||||
# FIXME: choose a dir on the same disk/dir as the final path
|
||||
fd, tmppath = tempfile.mkstemp(suffix='.morituri.wav')
|
||||
os.close(fd)
|
||||
self._tmppath = tmppath
|
||||
self._tmpwavpath = tmppath
|
||||
|
||||
self.tasks = []
|
||||
self.tasks.append(
|
||||
@@ -266,8 +269,8 @@ class ReadVerifyTrackTask(task.MultiSeparateTask):
|
||||
self.tasks.append(t)
|
||||
self.tasks.append(checksum.CRC32Task(tmppath))
|
||||
|
||||
# FIXME: clean this up
|
||||
fd, tmpoutpath = tempfile.mkstemp(suffix='.morituri.flac')
|
||||
fd, tmpoutpath = tempfile.mkstemp(suffix='.morituri.%s' %
|
||||
profile.extension)
|
||||
os.close(fd)
|
||||
self._tmppath = tmpoutpath
|
||||
self.tasks.append(encode.EncodeTask(tmppath, tmpoutpath, profile))
|
||||
@@ -290,6 +293,10 @@ class ReadVerifyTrackTask(task.MultiSeparateTask):
|
||||
|
||||
if self.tasks[5].checksum != self.checksum:
|
||||
self.error('Encoding failed, checksum does not match')
|
||||
|
||||
# delete the unencoded file
|
||||
os.unlink(self._tmpwavpath)
|
||||
|
||||
try:
|
||||
shutil.move(self._tmppath, self.path)
|
||||
self.checksum = checksum
|
||||
|
||||
@@ -286,7 +286,7 @@ class Rip(logcommand.LogCommand):
|
||||
start, stop - 1,
|
||||
offset=int(self.options.offset),
|
||||
device=self.parentCommand.options.device,
|
||||
profile=self.options.profile)
|
||||
profile=profile)
|
||||
function(runner, t)
|
||||
|
||||
if t.checksum is not None:
|
||||
@@ -314,13 +314,14 @@ class Rip(logcommand.LogCommand):
|
||||
|
||||
# FIXME: optionally allow overriding reripping
|
||||
if not os.path.exists(path):
|
||||
print 'Ripping track %d: %s' % (i + 1, os.path.basename(path))
|
||||
print 'Ripping track %d of %d: %s' % (
|
||||
i + 1, len(itable.tracks), os.path.basename(path))
|
||||
t = cdparanoia.ReadVerifyTrackTask(path, ittoc,
|
||||
ittoc.getTrackStart(i + 1),
|
||||
ittoc.getTrackEnd(i + 1),
|
||||
offset=int(self.options.offset),
|
||||
device=self.parentCommand.options.device,
|
||||
profile=self.options.profile)
|
||||
profile=profile)
|
||||
t.description = 'Reading Track %d' % (i + 1)
|
||||
function(runner, t)
|
||||
if t.checksum:
|
||||
|
||||
Reference in New Issue
Block a user