From 59f1250f2f6969a2cca9153a6e0c06a067ed0ffe Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Sat, 26 Feb 2022 11:40:07 +0000 Subject: [PATCH] dvdrip: Abolish the affordances for using `dvdbackup'. --- dvdrip | 114 ++++++++++++++++------------------------------------------------- 1 file changed, 28 insertions(+), 86 deletions(-) diff --git a/dvdrip b/dvdrip index c64487f..4137495 100755 --- a/dvdrip +++ b/dvdrip @@ -7,26 +7,19 @@ archive=${DVDRIP_ARCHIVE-jem.distorted.org.uk:/mnt/dvd/archive} : ${DVD_SECTOR_COPY=dvd-sector-copy} : ${DVDRIP_UPLOAD=dvdrip-upload} backup=nil eject=nil force=nil retry=nil verbose=nil bogus=nil -unset dir sub n label usage () { cat <&2 "$prog: must specify both directory and disc number, or neither" - exit 2 - ;; -esac - -hack_label () { - tr "[:lower:]" "[:upper:]" | - tr -Cs "[:alnum:]_\n" "[-*]" | - sed 's/^-//; s/-$//' -} +tag=${title//\//_} -case $backup in - t) - case ${label+t},${dir+t} in - t,*) ;; - ,) label=$(printf "%s" "$title" | hack_label) ;; - ,t) label=$(printf "%s_%s" "$dir" "$n" | hack_label) ;; - esac - len=$(printf "%s" "$label" | wc -c) - if [ $len -gt 32 ]; then echo >&2 "$prog: label too long"; exit 2; fi - ;; - nil) - case ${label+t} in - t) echo >&2 "$prog: label only meaningful to \`dvdbackup'"; exit 2 ;; - esac - ;; -esac - -case ${dir+t} in - t) tag="${dir}_${n}_${title}" out="$dir/$n. $title" ;; - *) tag=$title out=$title ;; -esac -tag=${tag//\//_} - -archdo run_setrc test -f "$archpath${sub+/$sub}/$out.iso" +archdo run_setrc test -f "$archpath/$title.iso" case $rc,$force in 0,nil) fail "output file already exists" ;; 0,t) warn "output file already exists; will overwrite" ;; @@ -136,50 +92,36 @@ for i in "$tmp/$tag/dest.new" "$tmp/$tag/dest" "$tmp/$tag/dest.seen"; do if [ -f "$tmp/$tag/dest.new" ]; then any=t; fi done case $any in - nil) printf "%s\n" "${sub+$sub/}$out.iso" >"$tmp/$tag/dest.new" ;; + nil) printf "%s\n" "$title.iso" >"$tmp/$tag/dest.new" ;; esac -case $backup in + +accumulate_badblocks +case $retry in t) - if [ ! -d "$tmp/$tag/rip" ]; then - rm -rf "$tmp/$tag/rip.new" - run dvdbackup -Mp -i"$dev" -o"$tmp/$tag" -n"rip.new" - run mv "$tmp/$tag/rip.new" "$tmp/$tag/rip" + if [ -f "$tmp/$tag/badblocks.retry" ]; then + : + elif [ -f "$tmp/$tag/badblocks" ]; then + run mv "$tmp/$tag/badblocks" "$tmp/$tag/badblocks.retry" + else + fail "no blocks to retry" fi - if [ ! -f "$tmp/$tag/iso" ]; then - run genisoimage -quiet -dvd-video -udf -V "$label" \ - -o "$tmp/$tag/iso.new" "$tmp/$tag/rip" - run mv "$tmp/$tag/iso.new" "$tmp/$tag/iso" - fi - ;; - nil) - accumulate_badblocks - case $retry in - t) - if [ -f "$tmp/$tag/badblocks.retry" ]; then - : - elif [ -f "$tmp/$tag/badblocks" ]; then - run mv "$tmp/$tag/badblocks" "$tmp/$tag/badblocks.retry" - else - fail "no blocks to retry" - fi - set -- "$@" -R"$tmp/$tag/badblocks.retry" - if [ -f "$tmp/$tag/iso" ]; then - mv "$tmp/$tag/iso" "$tmp/$tag/iso.new" - fi - ;; - esac - if [ ! -f "$tmp/$tag/iso" ]; then - run "$DVD_SECTOR_COPY" -c -b"$tmp/$tag/badblocks.new" "$@" \ - "$dev" "$tmp/$tag/iso.new" - run mv "$tmp/$tag/iso.new" "$tmp/$tag/iso" - accumulate_badblocks - case $retry in t) rm -f "$tmp/$tag/badblocks.retry" ;; esac - if [ -f "$tmp/$tag/badblocks" ]; then - fail "bad sectors found: check \`$tmp/$tag/iso', run again if ok" - fi + set -- "$@" -R"$tmp/$tag/badblocks.retry" + if [ -f "$tmp/$tag/iso" ]; then + mv "$tmp/$tag/iso" "$tmp/$tag/iso.new" fi ;; esac +if [ ! -f "$tmp/$tag/iso" ]; then + run "$DVD_SECTOR_COPY" -cs -b"$tmp/$tag/badblocks.new" "$@" \ + "$dev" "$tmp/$tag/iso.new" + run mv "$tmp/$tag/iso.new" "$tmp/$tag/iso" + accumulate_badblocks + case $retry in t) rm -f "$tmp/$tag/badblocks.retry" ;; esac + if [ -f "$tmp/$tag/badblocks" ]; then + fail "bad sectors found: check \`$tmp/$tag/iso', run again if ok" + fi +fi + run mv "$tmp/$tag/dest.new" "$tmp/$tag/dest" run "$DVDRIP_UPLOAD" case $eject in t) run eject "$dev" ;; esac -- 2.11.0