* morituri/program/cdparanoia.py:
* morituri/program/cdrdao.py: * morituri/rip/cd.py: * morituri/rip/offset.py: Add device argument to ripping/scanning tasks.
This commit is contained in:
@@ -1,3 +1,11 @@
|
|||||||
|
2009-05-23 Thomas Vander Stichele <thomas at apestaart dot org>
|
||||||
|
|
||||||
|
* morituri/program/cdparanoia.py:
|
||||||
|
* morituri/program/cdrdao.py:
|
||||||
|
* morituri/rip/cd.py:
|
||||||
|
* morituri/rip/offset.py:
|
||||||
|
Add device argument to ripping/scanning tasks.
|
||||||
|
|
||||||
2009-05-23 Thomas Vander Stichele <thomas at apestaart dot org>
|
2009-05-23 Thomas Vander Stichele <thomas at apestaart dot org>
|
||||||
|
|
||||||
* morituri/common/accurip.py:
|
* morituri/common/accurip.py:
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ class ReadTrackTask(task.Task):
|
|||||||
description = "Reading Track"
|
description = "Reading Track"
|
||||||
|
|
||||||
|
|
||||||
def __init__(self, path, table, start, stop, offset=0):
|
def __init__(self, path, table, start, stop, offset=0, device=None):
|
||||||
"""
|
"""
|
||||||
Read the given track.
|
Read the given track.
|
||||||
|
|
||||||
@@ -97,6 +97,8 @@ class ReadTrackTask(task.Task):
|
|||||||
@type stop: int
|
@type stop: int
|
||||||
@param offset: read offset, in samples
|
@param offset: read offset, in samples
|
||||||
@type offset: int
|
@type offset: int
|
||||||
|
@param device: the device to rip from
|
||||||
|
@type device: str
|
||||||
"""
|
"""
|
||||||
self.path = path
|
self.path = path
|
||||||
self._table = table
|
self._table = table
|
||||||
@@ -104,6 +106,7 @@ class ReadTrackTask(task.Task):
|
|||||||
self._stop = stop
|
self._stop = stop
|
||||||
self._offset = offset
|
self._offset = offset
|
||||||
self._parser = ProgressParser()
|
self._parser = ProgressParser()
|
||||||
|
self._device = device
|
||||||
|
|
||||||
self._buffer = "" # accumulate characters
|
self._buffer = "" # accumulate characters
|
||||||
self._errors = []
|
self._errors = []
|
||||||
@@ -130,13 +133,14 @@ class ReadTrackTask(task.Task):
|
|||||||
self.debug('Stopping at track %d, offset %d', stopTrack, stopOffset)
|
self.debug('Stopping at track %d, offset %d', stopTrack, stopOffset)
|
||||||
|
|
||||||
bufsize = 1024
|
bufsize = 1024
|
||||||
argv = ["cdparanoia",
|
argv = ["cdparanoia", "--stderr-progress",
|
||||||
"--sample-offset=%d" % self._offset,
|
"--sample-offset=%d" % self._offset, ]
|
||||||
"--stderr-progress",
|
if self._device:
|
||||||
"%d[%s]-%d[%s]" % (
|
argv.extend(["--force-cdrom-device", self._device, ])
|
||||||
|
argv.extend(["%d[%s]-%d[%s]" % (
|
||||||
startTrack, common.framesToHMSF(startOffset),
|
startTrack, common.framesToHMSF(startOffset),
|
||||||
stopTrack, common.framesToHMSF(stopOffset)),
|
stopTrack, common.framesToHMSF(stopOffset)),
|
||||||
self.path]
|
self.path])
|
||||||
self.debug('Running %s' % (" ".join(argv), ))
|
self.debug('Running %s' % (" ".join(argv), ))
|
||||||
self._popen = asyncsub.Popen(argv,
|
self._popen = asyncsub.Popen(argv,
|
||||||
bufsize=bufsize,
|
bufsize=bufsize,
|
||||||
@@ -224,7 +228,7 @@ class ReadVerifyTrackTask(task.MultiSeparateTask):
|
|||||||
@ivar checksum: the checksum of the track.
|
@ivar checksum: the checksum of the track.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, path, table, start, stop, offset=0):
|
def __init__(self, path, table, start, stop, offset=0, device=None):
|
||||||
"""
|
"""
|
||||||
@param path: where to store the ripped track
|
@param path: where to store the ripped track
|
||||||
@type path: str
|
@type path: str
|
||||||
@@ -236,6 +240,8 @@ class ReadVerifyTrackTask(task.MultiSeparateTask):
|
|||||||
@type stop: int
|
@type stop: int
|
||||||
@param offset: read offset, in samples
|
@param offset: read offset, in samples
|
||||||
@type offset: int
|
@type offset: int
|
||||||
|
@param device: the device to rip from
|
||||||
|
@type device: str
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self.path = path
|
self.path = path
|
||||||
@@ -247,9 +253,9 @@ class ReadVerifyTrackTask(task.MultiSeparateTask):
|
|||||||
|
|
||||||
self.tasks = []
|
self.tasks = []
|
||||||
self.tasks.append(
|
self.tasks.append(
|
||||||
ReadTrackTask(tmppath, table, start, stop, offset))
|
ReadTrackTask(tmppath, table, start, stop, offset, device))
|
||||||
self.tasks.append(checksum.CRC32Task(tmppath))
|
self.tasks.append(checksum.CRC32Task(tmppath))
|
||||||
t = ReadTrackTask(tmppath, table, start, stop, offset)
|
t = ReadTrackTask(tmppath, table, start, stop, offset, device)
|
||||||
t.description = 'Verifying track...'
|
t.description = 'Verifying track...'
|
||||||
self.tasks.append(t)
|
self.tasks.append(t)
|
||||||
self.tasks.append(checksum.CRC32Task(tmppath))
|
self.tasks.append(checksum.CRC32Task(tmppath))
|
||||||
|
|||||||
@@ -198,10 +198,10 @@ class CDRDAOTask(task.Task):
|
|||||||
task.Task.start(self, runner)
|
task.Task.start(self, runner)
|
||||||
|
|
||||||
bufsize = 1024
|
bufsize = 1024
|
||||||
self._popen = asyncsub.Popen(["cdrdao"] + self.options,
|
self._popen = asyncsub.Popen(["cdrdao", ] + self.options,
|
||||||
bufsize=bufsize,
|
bufsize=bufsize,
|
||||||
stdin=subprocess.PIPE, stdout=subprocess.PIPE,
|
stdin=subprocess.PIPE, stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.PIPE, close_fds=True)
|
stderr=subprocess.PIPE, close_fds=True)
|
||||||
self.debug('Started cdrdao with pid %d and options %r',
|
self.debug('Started cdrdao with pid %d and options %r',
|
||||||
self._popen.pid, self.options)
|
self._popen.pid, self.options)
|
||||||
|
|
||||||
@@ -263,15 +263,21 @@ class ReadTableTask(CDRDAOTask):
|
|||||||
description = "Scanning indexes..."
|
description = "Scanning indexes..."
|
||||||
table = None
|
table = None
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self, device=None):
|
||||||
|
"""
|
||||||
|
@param device: the device to rip from
|
||||||
|
@type device: str
|
||||||
|
"""
|
||||||
CDRDAOTask.__init__(self)
|
CDRDAOTask.__init__(self)
|
||||||
self.parser = OutputParser(self)
|
self.parser = OutputParser(self)
|
||||||
(fd, self._tocfilepath) = tempfile.mkstemp(suffix='.morituri')
|
(fd, self._tocfilepath) = tempfile.mkstemp(suffix='.morituri')
|
||||||
os.close(fd)
|
os.close(fd)
|
||||||
os.unlink(self._tocfilepath)
|
os.unlink(self._tocfilepath)
|
||||||
|
|
||||||
self.options = ['read-toc', '--session', '9',
|
self.options = ['read-toc', ]
|
||||||
self._tocfilepath, ]
|
if device:
|
||||||
|
self.options.extend(['--device', device, ])
|
||||||
|
self.options.extend(['--session', '9', self._tocfilepath, ])
|
||||||
|
|
||||||
def readbytes(self, bytes):
|
def readbytes(self, bytes):
|
||||||
self.parser.read(bytes)
|
self.parser.read(bytes)
|
||||||
@@ -312,7 +318,11 @@ class ReadTOCTask(CDRDAOTask):
|
|||||||
description = "Reading TOC..."
|
description = "Reading TOC..."
|
||||||
table = None
|
table = None
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self, device=None):
|
||||||
|
"""
|
||||||
|
@param device: the device to rip from
|
||||||
|
@type device: str
|
||||||
|
"""
|
||||||
CDRDAOTask.__init__(self)
|
CDRDAOTask.__init__(self)
|
||||||
self.parser = OutputParser(self)
|
self.parser = OutputParser(self)
|
||||||
|
|
||||||
@@ -322,8 +332,10 @@ class ReadTOCTask(CDRDAOTask):
|
|||||||
|
|
||||||
# Reading a non-existent session gives you output for all sessions
|
# Reading a non-existent session gives you output for all sessions
|
||||||
# 9 should be a safe number
|
# 9 should be a safe number
|
||||||
self.options = ['read-toc', '--fast-toc', '--session', '9',
|
self.options = ['read-toc', '--fast-toc', ]
|
||||||
self._toc, ]
|
if device:
|
||||||
|
self.options.extend(['--device', device, ])
|
||||||
|
self.options.extend(['--session', '9', self._toc, ])
|
||||||
|
|
||||||
def readbytes(self, bytes):
|
def readbytes(self, bytes):
|
||||||
self.parser.read(bytes)
|
self.parser.read(bytes)
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ import shutil
|
|||||||
import gobject
|
import gobject
|
||||||
gobject.threads_init()
|
gobject.threads_init()
|
||||||
|
|
||||||
from morituri.common import logcommand, task, checksum, common, accurip
|
from morituri.common import logcommand, task, checksum, common, accurip, drive
|
||||||
from morituri.image import image, cue, table
|
from morituri.image import image, cue, table
|
||||||
from morituri.program import cdrdao, cdparanoia
|
from morituri.program import cdrdao, cdparanoia
|
||||||
|
|
||||||
@@ -195,7 +195,7 @@ class Rip(logcommand.LogCommand):
|
|||||||
# first, read the normal TOC, which is fast
|
# first, read the normal TOC, which is fast
|
||||||
ptoc = common.Persister(self.options.toc_pickle or None)
|
ptoc = common.Persister(self.options.toc_pickle or None)
|
||||||
if not ptoc.object:
|
if not ptoc.object:
|
||||||
t = cdrdao.ReadTOCTask()
|
t = cdrdao.ReadTOCTask(device=self.parentCommand.options.device)
|
||||||
function(runner, t)
|
function(runner, t)
|
||||||
ptoc.persist(t.table)
|
ptoc.persist(t.table)
|
||||||
ittoc = ptoc.object
|
ittoc = ptoc.object
|
||||||
@@ -214,7 +214,7 @@ class Rip(logcommand.LogCommand):
|
|||||||
# now, read the complete index table, which is slower
|
# now, read the complete index table, which is slower
|
||||||
ptable = common.Persister(self.options.table_pickle or None)
|
ptable = common.Persister(self.options.table_pickle or None)
|
||||||
if not ptable.object:
|
if not ptable.object:
|
||||||
t = cdrdao.ReadTableTask()
|
t = cdrdao.ReadTableTask(device=self.parentCommand.options.device)
|
||||||
function(runner, t)
|
function(runner, t)
|
||||||
ptable.persist(t.table)
|
ptable.persist(t.table)
|
||||||
itable = ptable.object
|
itable = ptable.object
|
||||||
@@ -250,7 +250,8 @@ class Rip(logcommand.LogCommand):
|
|||||||
print 'Ripping track %d: %s' % (0, os.path.basename(htoapath))
|
print 'Ripping track %d: %s' % (0, os.path.basename(htoapath))
|
||||||
t = cdparanoia.ReadVerifyTrackTask(htoapath, ittoc,
|
t = cdparanoia.ReadVerifyTrackTask(htoapath, ittoc,
|
||||||
start, stop - 1,
|
start, stop - 1,
|
||||||
offset=int(self.options.offset))
|
offset=int(self.options.offset),
|
||||||
|
device=self.parentCommand.options.device)
|
||||||
function(runner, t)
|
function(runner, t)
|
||||||
if t.checksum:
|
if t.checksum:
|
||||||
print 'Checksums match for track %d' % 0
|
print 'Checksums match for track %d' % 0
|
||||||
@@ -272,7 +273,8 @@ class Rip(logcommand.LogCommand):
|
|||||||
t = cdparanoia.ReadVerifyTrackTask(path, ittoc,
|
t = cdparanoia.ReadVerifyTrackTask(path, ittoc,
|
||||||
ittoc.getTrackStart(i + 1),
|
ittoc.getTrackStart(i + 1),
|
||||||
ittoc.getTrackEnd(i + 1),
|
ittoc.getTrackEnd(i + 1),
|
||||||
offset=int(self.options.offset))
|
offset=int(self.options.offset),
|
||||||
|
device=self.parentCommand.options.device)
|
||||||
t.description = 'Reading Track %d' % (i + 1)
|
t.description = 'Reading Track %d' % (i + 1)
|
||||||
function(runner, t)
|
function(runner, t)
|
||||||
if t.checksum:
|
if t.checksum:
|
||||||
@@ -385,3 +387,17 @@ class CD(logcommand.LogCommand):
|
|||||||
summary = "handle CD's"
|
summary = "handle CD's"
|
||||||
|
|
||||||
subCommandClasses = [Rip, ]
|
subCommandClasses = [Rip, ]
|
||||||
|
|
||||||
|
def addOptions(self):
|
||||||
|
self.parser.add_option('-d', '--device',
|
||||||
|
action="store", dest="device",
|
||||||
|
help="CD-DA device")
|
||||||
|
|
||||||
|
def handleOptions(self, options):
|
||||||
|
if not options.device:
|
||||||
|
drives = drive.getAllDevicePaths()
|
||||||
|
if not drives:
|
||||||
|
self.error('No CD-DA drives found!')
|
||||||
|
return 3
|
||||||
|
|
||||||
|
self.options.device = drives[0]
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ CD in the AccurateRip database."""
|
|||||||
try:
|
try:
|
||||||
handle = urllib2.urlopen(url)
|
handle = urllib2.urlopen(url)
|
||||||
data = handle.read()
|
data = handle.read()
|
||||||
responses = image.getAccurateRipResponses(data)
|
responses = accurip.getAccurateRipResponses(data)
|
||||||
except urllib2.HTTPError, e:
|
except urllib2.HTTPError, e:
|
||||||
if e.code == 404:
|
if e.code == 404:
|
||||||
print 'Album not found in AccurateRip database.'
|
print 'Album not found in AccurateRip database.'
|
||||||
|
|||||||
Reference in New Issue
Block a user