Added new AID audio track id override command line option -l <aid>
[rip_dvd/.git] / rip_dvd.wrap
1 #!/bin/bash
2
3 ##############################################
4 # COMMAND LINE PROCESSING
5
6 # get the dvdtype from the command line
7 dvdtype=$1
8
9 # remove the dvdtype from the args, and interpret the rest
10 # of the args to be passed directly to the rip_dvd script.
11 shift 1
12
13 ##############################################
14 if [ -z "$dvdtype" ]; then
15   echo "-E- $0 <dvdtype>' is a required option"
16   usage
17 fi
18
19 ##############################################################################
20 # Local Machine Settings:
21 # Sources both the "default" conf file tracked by GIT (rip_dvd.conf.dist)
22 # and the local conf file created by each local machine (rip_dvd.conf)
23 # Copy the rip_dvd.conf.dist file to rip_dvd.conf and edit the later.
24 # This will allow you to override all the default values to meet your needs
25 # in a way that won't get clobbered when you pull updates from my GIT repo.
26 ##############################################################################
27 config="${0%/*}/rip_dvd.conf"
28
29 # The config file will be searched for in the following location order:
30 found_config=0
31
32 # 1) /path/to/rip_dvd/script/rip_dvd.conf.dist
33 [ -e "${config}.dist" ] && found_config=1 && . "${config}.dist"
34
35 # 2) /path/to/rip_dvd/script/rip_dvd.conf
36 [ -e "${config}" ] && found_config=1 && . "${config}"
37
38 # 3) /etc/rip_dvd.conf
39 [ -e "/etc/rip_dvd.conf" ] && found_config=1 && . "/etc/rip_dvd.conf"
40
41 # 4) $PWD/rip_dvd.conf
42 [ -e "$PWD/rip_dvd.conf" ] && found_config=1 && . "$PWD/rip_dvd.conf"
43
44 # Check to make sure we found the config file
45 if [ $found_config -eq 0 ]; then
46   echo "-E- Unable to find the rip_dvd.conf file: $config"
47   exit 1
48 fi
49
50 ##############################################
51 # get the name of the DVD from the DVD disk
52 dvdname=`volname $dev | awk '{ print $1 }'`
53 dvdname=${dvdname%.} # remove trailing '.' character
54
55 ##############################################
56 # Find out what type of DVD we are ripping
57 # And set our destination directory appropriately
58 # dvdtype parameter:
59 # - netflix = DVD ripped as an entire ISO image
60 #   since these are only kept around until we watch them,
61 #   there is no need to do anything less than full iso.
62 # - collection = Only DVD main feature is ripped
63 # - childrens = Only DVD main feature is ripped
64 # - church = Only DVD main feature is ripped
65 rip_opts="$* -j 2"
66 if [ "$dvdtype" == "netflix" ]; then
67   echo "-> Ripping Netflix DVD"
68   dest=/myth/video/DVDs/Netflix
69   rip_opts="$rip_opts"
70 elif [ "$dvdtype" == "collection" ]; then
71   echo "-> Ripping Personal Collection DVD"
72   dest=/myth/video/DVDs/Collection
73   rip_opts="$rip_opts"
74 elif [ "$dvdtype" == "childrens" ]; then
75   echo "-> Ripping Children's DVD"
76   dest=/myth/video/DVDs/Childrens
77   rip_opts="$rip_opts"
78 elif [ "$dvdtype" == "church" ]; then
79   echo "-> Ripping Church DVD"
80   dest=/myth/video/DVDs/Church
81   rip_opts="$rip_opts"
82 else
83   echo '-E- Must specify dvdtype as "netflix" or "collection" or "childrens" or "church"'
84   usage
85 fi
86
87 ##############################################
88 # Display progress window
89
90 # Pop up an xterm window and run the script inside of it
91 echo "xterm -T \"Ripping->$dvdname\" -geometry 72x15+20+10 -bg black -fg white -e \"/bin/bash\" -c \"$ripcmd -d $dest $rip_opts\" &"
92 xterm -T "Ripping->$dvdname" -geometry 72x15+20+10 -bg black -fg white -e "/bin/bash" -c "$ripcmd -d $dest $rip_opts" &
93
94 ##############################################
95 # OR display the script output directly in the terminal it's called from
96 #$ripcmd -d $dest $rip_opts
97
98 ##############################################