]> code.delx.au - transcoding/blobdiff - rip-dvd
rip-dvd: don't extract iso to directory
[transcoding] / rip-dvd
diff --git a/rip-dvd b/rip-dvd
index aeee4d72be6bc311f97b165206ab2445b7d9f5c5..35032ff5b069e154843949f3874168b1bd6c9d0e 100755 (executable)
--- a/rip-dvd
+++ b/rip-dvd
@@ -3,23 +3,24 @@
 DVD_DEVICE="${DVD_DEVICE:-/dev/dvd}"
 
 if [ -z "$1" ]; then
-       echo "Usage: $0 NAME [num]"
-       exit 1
+    echo "Usage: $0 NAME [num]"
+    exit 1
 fi
 
 
 # Calculate the name for ripping
 base="$1"
-last="$(find . -maxdepth 1 -type d -name "${base}*" | sort -n | tail -n 1)"
-if [ -z "$last" ]; then
-       num="1"
-elif [ -n "$2" ]; then
-       num="$2"
+last="$(find . -maxdepth 1 -type f -name "${base}*.iso" | sort -n | tail -n 1)"
+if [ -n "$2" ]; then
+    num="$2"
+elif [ -z "$last" ]; then
+    num="1"
 else
-       num="${last##./${base}}"
-       num="$(($num + 1))"
+    num="${last##./${base}}"
+    num="${num%%.iso}"
+    num="$(($num + 1))"
 fi
-next="${base}${num}"
+output="${base}${num}.iso"
 
 
 # Sometimes the cached keys are wrong, since it only takes a few seconds to
@@ -27,24 +28,22 @@ next="${base}${num}"
 rm -rf ~/.dvdcss
 
 # Need to use libdvdread/libdvdcss to unlock the drive before copying
-identify-dvd "$DVD_DEVICE"
+identify-disc --dvd-device "$DVD_DEVICE"
 
 
 echo
 echo
-echo "Will rip to '$next'"
+echo "Will rip to '$output'"
 for i in $(seq 3 -1 1); do
-       echo "    $i..."
-       sleep 1
+    echo "    $i..."
+    sleep 1
 done
 
 
 # Rip to ISO skipping bad sectors then decrypt to VIDEO_TS directory
 set -x
-rm -rf "${next}" "${next}.iso"
-ddrescue -n -b 2048 "$DVD_DEVICE" "${next}.iso"
-dvdbackup -n "$next" -M -i "${next}.iso" || true
-identify-dvd "$next"
-rm "${next}.iso"
+rm -f "$output"
+ddrescue -n -b 2048 "$DVD_DEVICE" "$output"
+identify-disc --dvd-device "$output"
 eject "$DVD_DEVICE"