From: Alan J. Pippin Date: Wed, 20 May 2009 22:14:53 +0000 (-0600) Subject: Added ability to deal with iso files given via the -n option X-Git-Tag: 1_0~22 X-Git-Url: http://git.pippins.net/embedvideo/.git/%22%22.%24thumbnail.%22/images/%24link?a=commitdiff_plain;h=27714b54990f6258a96c92a6872ae89fb0c311e1;p=rip_dvd%2F.git Added ability to deal with iso files given via the -n option --- diff --git a/rip_dvd b/rip_dvd index 9a6d471..c47fd59 100755 --- a/rip_dvd +++ b/rip_dvd @@ -48,6 +48,9 @@ typeset dvdpath="" typeset aspect="" typeset SCALE="" typeset CROP="" +typeset -i keep_isofile=0 +typeset -i keep_vobfile=0 +typeset -i keep_dvdfolder=0 typeset -i keep_intermediate_files=0 typeset -i make_final_dest_vob=0 typeset -i make_final_dest_iso=0 @@ -98,6 +101,7 @@ function usage() { echo >&2 " 2) If dvdname exists in $tmpdir, it will be ripped as a DVD instead of $dev" echo >&2 " 3) If dvdname is a full path to a DVD folder, it will be ripped as a DVD instead of $dev" echo >&2 " 4) If dvdname is a full path to an MPG2 file, it will be ripped as a DVD instead of $dev" + echo >&2 " 5) If dvdname is a full path to an ISO file, it will be ripped as a DVD instead of $dev" echo >&2 " -m Make a mirror image of the DVD and save it as a DVD ISO file" echo >&2 " The default operation is non-mirror mode where only the main" echo >&2 " feature title will be ripped." @@ -201,6 +205,7 @@ else if [ -d "$dvdname" ]; then dvdpath="$dvdname" dvdname=`basename "$dvdname"` + keep_dvdfolder=1 if [ -z "$dvdname" ]; then echo "-E- Unable to extract dvdname from path: $dvdpath" exit 1 @@ -210,16 +215,37 @@ else exit 1 fi fi - # check to see if dvdname is a full path to an MPG2 (VOB) file - # if it is, set dvdname and vobfile appropriately + + # Check to see if dvdname is a full path to a file if [ -f "$dvdname" ]; then - vobfile="$dvdname" - dvdname=`basename "$dvdname"` - file "$vobfile" | grep -q "MPEG" + valid_file=0 + + # check to see if dvdname is a full path to an MPG2 (VOB) file + # if it is, set dvdname and vobfile appropriately + file "$dvdname" | grep -q "MPEG" if [ $? == 0 ]; then # It is a valid MPEG2 file, now strip the extension off our dvdname + vobfile="$dvdname" + dvdname=`basename "$dvdname"` + dvdname=${dvdname%.[^.]*} + keep_vobfile=1 + valid_file=1 + fi + + # check to see if dvdname is a full path to an ISO file + # if it is, set dvdname and isofile appropriately + file "$dvdname" | grep -q "ISO" + if [ $? == 0 ]; then + # It is a valid ISO file, now strip the extension off our dvdname + isofile="$dvdname" + dvdname=`basename "$dvdname"` dvdname=${dvdname%.[^.]*} - else + keep_isofile=1 + valid_file=1 + fi + + # If we didn't find a handler for the file above, complain + if [ $valid_file -eq 0 ]; then echo "-E- Unsupported file type: $vobfile" exit 1 fi @@ -763,8 +789,8 @@ function fill_mythvideo_metadata { fi } +# remove the intermediate VOB file function remove_intermediate_vob_file { - # remove the intermediate VOB file if [ $keep_intermediate_files -eq 0 ]; then [[ -e "$tmpdir/$dvdname.VOB" ]] && rm -f "$tmpdir/$dvdname.VOB" else @@ -772,8 +798,9 @@ function remove_intermediate_vob_file { fi } +# remove the original DVD image function remove_intermediate_iso_file { - # remove the original DVD image + [[ $keep_isofile -eq 1 ]] && return 1 if [ $keep_intermediate_files -eq 0 ]; then [[ -e "$isofile" ]] && rm "$isofile" else @@ -781,6 +808,7 @@ function remove_intermediate_iso_file { fi } +# remove the intermediate dvdbackup folder function remove_intermediate_dvdbackup_folder { if [ $keep_intermediate_files -eq 0 ]; then [[ -d "$tmpdir/$dvdname" ]] && rm -rf "$tmpdir/$dvdname" @@ -982,7 +1010,7 @@ if [ $mirror_mode -eq 0 ]; then done if [ $keep_intermediate_files -eq 0 ] && [ $make_final_dest_vob -eq 0 ]; then - [[ -e "$vobfile" ]] && rm -f "$vobfile"; + [[ -e "$vobfile" ]] && [[ $keep_vobfile -eq 0 ]] && rm -f "$vobfile"; [[ -e "$passlogfile" ]] && rm -f "$passlogfile"; else echo "-> Keeping VOB file: $vobfile" | tee -a "$logfile"