]> code.delx.au - transcoding/blob - rip-dvd
rip-dvd: don't extract iso to directory
[transcoding] / rip-dvd
1 #!/bin/bash -e
2
3 DVD_DEVICE="${DVD_DEVICE:-/dev/dvd}"
4
5 if [ -z "$1" ]; then
6 echo "Usage: $0 NAME [num]"
7 exit 1
8 fi
9
10
11 # Calculate the name for ripping
12 base="$1"
13 last="$(find . -maxdepth 1 -type f -name "${base}*.iso" | sort -n | tail -n 1)"
14 if [ -n "$2" ]; then
15 num="$2"
16 elif [ -z "$last" ]; then
17 num="1"
18 else
19 num="${last##./${base}}"
20 num="${num%%.iso}"
21 num="$(($num + 1))"
22 fi
23 output="${base}${num}.iso"
24
25
26 # Sometimes the cached keys are wrong, since it only takes a few seconds to
27 # recrack I prefer to do it each time
28 rm -rf ~/.dvdcss
29
30 # Need to use libdvdread/libdvdcss to unlock the drive before copying
31 identify-disc --dvd-device "$DVD_DEVICE"
32
33
34 echo
35 echo
36 echo "Will rip to '$output'"
37 for i in $(seq 3 -1 1); do
38 echo " $i..."
39 sleep 1
40 done
41
42
43 # Rip to ISO skipping bad sectors then decrypt to VIDEO_TS directory
44 set -x
45 rm -f "$output"
46 ddrescue -n -b 2048 "$DVD_DEVICE" "$output"
47 identify-disc --dvd-device "$output"
48 eject "$DVD_DEVICE"
49