2 # The purpose of this script is to encapsulate the calls
3 # made to the rip_dvd script. This is done to help distribute
4 # the resulting ripped files to the proper folders. This
5 # script is called from the mythtv menus for example with a
6 # smaller set of options.
8 ##############################################
9 # Don't run if a previous rip attempt is still running
10 SCRIPT_NAME1="rip_dvd.wrap"
11 SCRIPT_NAME2="xterm -T Ripping"
14 ps -ef | grep -e "$SCRIPT_NAME1" -e "$SCRIPT_NAME2" | grep -v grep | grep -v $MY_PID | grep -v $PARENT_PID
15 if [[ $? == 0 ]]; then
16 echo -e "-E- Found an instance of this script already running. Aborting this additional attempt to rip...\n"
20 ##############################################
21 # COMMAND LINE PROCESSING
23 # get the dvdtype from the command line
26 # remove the dvdtype from the args, and interpret the rest
27 # of the args to be passed directly to the rip_dvd script.
30 ##############################################
31 if [ -z "$dvdtype" ]; then
32 echo "-E- $0 <dvdtype>' is a required option"
36 mydir=$(cd $(dirname $0) && pwd)
39 if [ -x "$mydir/rip_dvd" ]
41 ripcmd="$mydir/rip_dvd"
43 echo >&2 "Cannot find your rip_dvd command!"
48 ##############################################################################
49 # Local Machine Settings:
50 # Sources both the "default" conf file tracked by GIT (rip_dvd.conf.dist)
51 # and the local conf file created by each local machine (rip_dvd.conf)
52 # Copy the rip_dvd.conf.dist file to rip_dvd.conf and edit the later.
53 # This will allow you to override all the default values to meet your needs
54 # in a way that won't get clobbered when you pull updates from my GIT repo.
55 ##############################################################################
56 config="${0%/*}/rip_dvd.conf"
58 # The config file will be searched for in the following location order:
61 # 1) /path/to/rip_dvd/script/rip_dvd.conf.dist
62 [ -e "${config}.dist" ] && found_config=1 && . "${config}.dist"
64 # 2) /path/to/rip_dvd/script/rip_dvd.conf
65 [ -e "${config}" ] && found_config=1 && . "${config}"
67 # 3) /etc/rip_dvd.conf
68 [ -e "/etc/rip_dvd.conf" ] && found_config=1 && . "/etc/rip_dvd.conf"
70 # 4) $PWD/rip_dvd.conf
71 [ -e "$PWD/rip_dvd.conf" ] && found_config=1 && . "$PWD/rip_dvd.conf"
73 # Check to make sure we found the config file
74 if [ $found_config -eq 0 ]; then
75 echo "-E- Unable to find the rip_dvd.conf file: $config"
79 ##############################################
80 # get the name of the DVD from the DVD disk
81 dvdname=`volname $dev | awk '{ print $1 }'`
82 dvdname=${dvdname%.} # remove trailing '.' character
84 ##############################################
85 # Find out what type of DVD we are ripping
86 # And set our destination directory appropriately
88 # - netflix = DVD ripped as an entire ISO image
89 # since these are only kept around until we watch them,
90 # there is no need to do anything less than full iso.
91 # - collection = Only DVD main feature is ripped
92 # - childrens = Only DVD main feature is ripped
93 # - church = Only DVD main feature is ripped
95 if [ "$dvdtype" == "netflix" ]; then
96 echo "-> Ripping Netflix DVD"
97 dest=/myth/video/DVDs/Netflix
99 elif [ "$dvdtype" == "collection" ]; then
100 echo "-> Ripping Personal Collection DVD"
101 dest=/myth/video/DVDs/Collection
103 elif [ "$dvdtype" == "childrens" ]; then
104 echo "-> Ripping Children's DVD"
105 dest=/myth/video/DVDs/Childrens
107 elif [ "$dvdtype" == "church" ]; then
108 echo "-> Ripping Church DVD"
109 dest=/myth/video/DVDs/Church
112 echo '-E- Must specify dvdtype as "netflix" or "collection" or "childrens" or "church"'
116 ##############################################
117 # Display progress window
119 # Pop up an xterm window and run the script inside of it
120 echo "xterm -T \"Ripping->$dvdname\" -geometry 72x15+20+10 -bg black -fg white -e \"/bin/bash\" -c \"$ripcmd -d $dest $rip_opts\" &"
121 xterm -T "Ripping->$dvdname" -geometry 72x15+20+10 -bg black -fg white -e "/bin/bash" -c "$ripcmd -d $dest $rip_opts" &
123 ##############################################
124 # OR display the script output directly in the terminal it's called from
125 #$ripcmd -d $dest $rip_opts
127 ##############################################