Detect and handle CD-R discs (#154)
* Use cdrdao to detect CD-Rs and continue ripping only if the argument --cdr is passed. * Get and display disc format from MusicBrainz. * Add info about CD-R detection to logger * Remove Musicbrainz medium format info * add cdrdao command to logger * Fix for PEP8 * Fix line break
This commit is contained in:
@@ -143,6 +143,13 @@ class _CD(BaseCommand):
|
||||
"--unknown not passed")
|
||||
return -1
|
||||
|
||||
self.program.result.isCdr = cdrdao.DetectCdr(self.device)
|
||||
if (self.program.result.isCdr and
|
||||
not getattr(self.options, 'cdr', False)):
|
||||
logger.critical("inserted disc seems to be a CD-R, "
|
||||
"--cdr not passed")
|
||||
return -1
|
||||
|
||||
# FIXME ?????
|
||||
# Hackish fix for broken commit
|
||||
offset = 0
|
||||
@@ -300,6 +307,11 @@ Log files will log the path to tracks relative to this directory.
|
||||
action="store_true", dest="unknown",
|
||||
help="whether to continue ripping if "
|
||||
"the CD is unknown", default=False)
|
||||
self.parser.add_argument('--cdr',
|
||||
action="store_true", dest="cdr",
|
||||
help="whether to continue ripping if "
|
||||
"the disc is a CD-R",
|
||||
default=False)
|
||||
|
||||
def handle_arguments(self):
|
||||
self.options.output_directory = os.path.expanduser(
|
||||
|
||||
@@ -47,6 +47,19 @@ def read_toc(device, fast_toc=False):
|
||||
return toc
|
||||
|
||||
|
||||
def DetectCdr(device):
|
||||
"""
|
||||
Return whether cdrdao detects a CD-R for 'device'.
|
||||
"""
|
||||
cmd = [CDRDAO, 'disk-info', '-v1', '--device', device]
|
||||
logger.debug("executing %r", cmd)
|
||||
p = Popen(cmd, stdout=PIPE, stderr=PIPE)
|
||||
if 'CD-R medium : n/a' in p.stdout.read():
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
|
||||
def version():
|
||||
"""
|
||||
Return cdrdao version as a string.
|
||||
|
||||
@@ -54,6 +54,11 @@ class WhipperLogger(result.Logger):
|
||||
# Next one fully works only using the patched cdparanoia package
|
||||
# lines.append("Fill up missing offset samples with silence: Yes")
|
||||
lines.append(" Gap detection: cdrdao %s" % ripResult.cdrdaoVersion)
|
||||
if ripResult.isCdr:
|
||||
isCdr = "Yes"
|
||||
else:
|
||||
isCdr = "No"
|
||||
lines.append(" CD-R detected: %s" % isCdr)
|
||||
lines.append("")
|
||||
|
||||
# CD metadata
|
||||
|
||||
@@ -93,6 +93,7 @@ class RipResult:
|
||||
|
||||
offset = 0
|
||||
overread = None
|
||||
isCdr = None
|
||||
logger = None
|
||||
table = None
|
||||
artist = None
|
||||
|
||||
Reference in New Issue
Block a user