Skip to content

Commit 1a541d9

Browse files
committed
Add option to keep unverified tracks. Fixes #612.
Add a -u/--keep-unverified option that keeps the most recent attempt of ripping a track that failed verification. The logging might be inconsistent in that the unverifiable track is mentioned as being skipped in some log messages. Signed-off-by: leper <leper4@protonmail.com>
1 parent 420d81b commit 1a541d9

File tree

4 files changed

+31
-6
lines changed

4 files changed

+31
-6
lines changed

man/whipper-cd-rip.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ Options
7373
| continue ripping further tracks instead of giving up if a track can't be
7474
| ripped
7575
76+
| **-u** | **--keep-unverified**
77+
| keep unverified tracks instead of deleting the data if a track can't be
78+
| verified
79+
7680
Template schemes
7781
================
7882

whipper/command/cd.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,11 @@ def add_arguments(self):
326326
help="continue ripping further tracks "
327327
"instead of giving up if a track "
328328
"can't be ripped")
329+
self.parser.add_argument('-u', '--keep-unverified',
330+
action='store_true',
331+
help="keep unverified (partial) results "
332+
"instead of deleleting the data if a track "
333+
"can't be verified")
329334

330335
def handle_arguments(self):
331336
self.options.output_directory = os.path.expanduser(
@@ -481,7 +486,8 @@ def _ripIfNotRipped(number):
481486
number,
482487
len(self.itable.tracks),
483488
extra),
484-
coverArtPath=self.coverArtPath)
489+
coverArtPath=self.coverArtPath,
490+
keep=self.options.keep_unverified)
485491
break
486492
# FIXME: catching too general exception (Exception)
487493
except Exception as e:
@@ -492,7 +498,15 @@ def _ripIfNotRipped(number):
492498
tries -= 1
493499
logger.critical('giving up on track %d after %d times',
494500
number, tries)
495-
if self.options.keep_going:
501+
if self.options.keep_unverified and not number == 0:
502+
logger.warning("track %d failed to rip. keeping unverified file.", number)
503+
logger.debug("adding %s to skipped_tracks",
504+
trackResult)
505+
self.skipped_tracks.append(trackResult)
506+
logger.debug("skipped_tracks = %s",
507+
self.skipped_tracks)
508+
trackResult.skipped = True
509+
elif self.options.keep_going:
496510
logger.warning("track %d failed to rip.", number)
497511
logger.debug("adding %s to skipped_tracks",
498512
trackResult)

whipper/common/program.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ def verifyTrack(runner, trackResult):
562562
return ret
563563

564564
def ripTrack(self, runner, trackResult, offset, device, taglist,
565-
overread, what=None, coverArtPath=None):
565+
overread, what=None, coverArtPath=None, keep=False):
566566
"""
567567
Rip and store a track of the disc.
568568
@@ -606,7 +606,8 @@ def ripTrack(self, runner, trackResult, offset, device, taglist,
606606
device=device,
607607
taglist=taglist,
608608
what=what,
609-
coverArtPath=coverArtPath)
609+
coverArtPath=coverArtPath,
610+
keep=keep)
610611

611612
runner.run(t)
612613

whipper/program/cdparanoia.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -439,8 +439,10 @@ class ReadVerifyTrackTask(task.MultiSeparateTask):
439439
_tmpwavpath = None
440440
_tmppath = None
441441

442+
_keep = False
443+
442444
def __init__(self, path, table, start, stop, overread, offset=0,
443-
device=None, taglist=None, what="track", coverArtPath=None):
445+
device=None, taglist=None, what="track", coverArtPath=None, keep=False):
444446
"""
445447
Init ReadVerifyTrackTask.
446448
@@ -471,6 +473,8 @@ def __init__(self, path, table, start, stop, overread, offset=0,
471473
os.close(fd)
472474
self._tmpwavpath = tmppath
473475

476+
self._keep = keep
477+
474478
from whipper.common import checksum
475479

476480
self.tasks = []
@@ -547,9 +551,11 @@ def stop(self):
547551
# delete the unencoded file
548552
os.unlink(self._tmpwavpath)
549553

550-
if not self.exception:
554+
if not self.exception or self._keep:
551555
try:
552556
logger.debug('moving to final path %r', self.path)
557+
if self.exception:
558+
logger.debug('keeping unverified result')
553559
shutil.move(self._tmppath, self.path)
554560
# FIXME: catching too general exception (Exception)
555561
except Exception as e:

0 commit comments

Comments
 (0)