diff --git a/whipper/command/cd.py b/whipper/command/cd.py index eb61ef2..037d9c6 100644 --- a/whipper/command/cd.py +++ b/whipper/command/cd.py @@ -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( diff --git a/whipper/program/cdrdao.py b/whipper/program/cdrdao.py index ffab516..e0da15c 100644 --- a/whipper/program/cdrdao.py +++ b/whipper/program/cdrdao.py @@ -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. diff --git a/whipper/result/logger.py b/whipper/result/logger.py index 6ab9f55..6a4b0bc 100644 --- a/whipper/result/logger.py +++ b/whipper/result/logger.py @@ -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 diff --git a/whipper/result/result.py b/whipper/result/result.py index 2bae046..f7250a7 100644 --- a/whipper/result/result.py +++ b/whipper/result/result.py @@ -93,6 +93,7 @@ class RipResult: offset = 0 overread = None + isCdr = None logger = None table = None artist = None