X-Git-Url: https://git.distorted.org.uk/~mdw/dvdrip/blobdiff_plain/822ac8a86682d421a76abad84a3235cdd17b58ea..f82e4cd7e57df2071f281ebdc9553f5970658c6d:/dvdrip diff --git a/dvdrip b/dvdrip index 3dc1053..9634fe0 100755 --- a/dvdrip +++ b/dvdrip @@ -5,18 +5,22 @@ dev=${DVDRIP_DEVICE-/dev/dvd} tmp=${DVDRIP_TMPDIR-${HOME?}/tmp/dvdrip} archive=${DVDRIP_ARCHIVE-jem.distorted.org.uk:/mnt/dvd/archive} : ${DVD_SECTOR_COPY=dvd-sector-copy} +: ${DVD_ID=dvd-id} : ${DVDRIP_UPLOAD=dvdrip-upload} -backup=nil eject=nil force=nil retry=nil verbose=nil bogus=nil +backup=nil ding=nil eject=nil force=nil retry=nil verbose=nil bogus=nil +unset params usage () { cat <"$tmp/$tag/discid.new" +mv "$tmp/$tag/discid.new" "$tmp/$tag/discid" + +if [ -b "$dev" ]; then msz=$(blockdev --getsize64 "$dev") +else msz=nil; fi + +echo "$dev" >"$tmp/$tag/device.new" +mv "$tmp/$tag/device.new" "$tmp/$tag/device" + accumulate_badblocks () { if [ -f "$tmp/$tag/badblocks.new" ]; then if [ ! -f "$tmp/$tag/badblocks" ]; then @@ -83,7 +113,6 @@ accumulate_badblocks () { } set -- -mkdir -p "$tmp/$tag" any=nil 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 @@ -91,6 +120,14 @@ done case $any in nil) printf "%s\n" "$title.iso" >"$tmp/$tag/dest.new" ;; esac +case $eject in + t) touch "$tmp/$tag/eject" ;; + nil) rm -f "$tmp/$tag/eject" ;; +esac +case $ding in + t) touch "$tmp/$tag/ding" ;; + nil) rm -f "$tmp/$tag/ding" ;; +esac accumulate_badblocks case $retry in @@ -109,17 +146,40 @@ case $retry in ;; esac if [ ! -f "$tmp/$tag/iso" ]; then - run "$DVD_SECTOR_COPY" -cs -b"$tmp/$tag/badblocks.new" "$@" \ - "$dev" "$tmp/$tag/iso.new" + run "$DVD_SECTOR_COPY" -cs ${params+"-B$params"} \ + -b"$tmp/$tag/badblocks.new" "$@" "$dev" "$tmp/$tag/iso.new" run mv "$tmp/$tag/iso.new" "$tmp/$tag/iso" accumulate_badblocks + rm -f "$tmp/$tag/device" 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 + case $msz in + nil) ;; + *) + newmsz=$(blockdev --getsize64 "$dev") + case $newmsz in + $msz) ;; + *) fail "medium size changed ($msz -> $newmsz): try again" ;; + esac + ;; + esac fi +rm -f "$tmp/$tag/device" run mv "$tmp/$tag/dest.new" "$tmp/$tag/dest" +if [ -f "$tmp/$tag/eject" ]; then eject=t; else eject=nil; fi +if [ -f "$tmp/$tag/ding" ]; then ding=t; else ding=nil; fi run "$DVDRIP_UPLOAD" case $eject in t) run eject "$dev" ;; esac -printf "\a" +case $ding in + t) + if [ -t 1 ]; then exec 3>&1 + elif [ -t 2 ]; then exec 3>&2 + else exec 3>/dev/tty + fi + printf "\a" >&3 + exec 3>&- + ;; +esac