dvdrip: Abolish the affordances for using `dvdbackup'.
authorMark Wooding <mdw@distorted.org.uk>
Sat, 26 Feb 2022 11:40:07 +0000 (11:40 +0000)
committerMark Wooding <mdw@distorted.org.uk>
Sat, 26 Feb 2022 12:00:48 +0000 (12:00 +0000)
dvdrip

diff --git a/dvdrip b/dvdrip
index c64487f..4137495 100755 (executable)
--- 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 <<EOF
-usage: $prog [-befrv] [-D DEV] [-a ARCH] [-d DIR]
-       [-l LABEL] [-n N] [-s SUB] [-t TMP] TITLE
+usage: $prog [-efrv] [-D DEV] [-a ARCH] [-t TMP] TITLE
 EOF
 }
-while getopts "hD:a:bd:efl:n:rs:t:v" opt; do
+while getopts "hD:a:efrt:v" opt; do
   case $opt in
     h) usage; exit 0 ;;
     D) dev=$OPTARG ;;
     a) archive=$OPTARG ;;
-    b) backup=t ;;
-    d) dir=$OPTARG ;;
     e) eject=t ;;
     f) force=t ;;
-    l) label=$OPTARG ;;
-    n) n=$OPTARG ;;
     r) retry=t ;;
-    s) sub=$OPTARG ;;
     t) tmp=$OPTARG ;;
     v) verbose=t ;;
     *) bogus=t ;;
@@ -74,46 +67,9 @@ archdo () {
 }
 archrun () { archdo run "$@"; }
 
-case ${dir+t},${n+t} in
-  t,t | ,)
-    n=$(printf "%02d" "$n")
-    ;;
-  *)
-    echo >&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