Added new moviedir option and makemkv only copy largest mkv option.
[rip_dvd/.git] / rip_dvd
diff --git a/rip_dvd b/rip_dvd
index 24d881e73dbbf9b19746e678fe990a01c01ee733..3b846fbafd360607ef4f4ae669c38a9cc310ff90 100755 (executable)
--- a/rip_dvd
+++ b/rip_dvd
@@ -78,6 +78,7 @@ typeset -i custom_audio_2ch=0
 typeset -i custom_audio_6ch=0
 typeset -i minimum_feature_title_length=60
 typeset -i lsdvd_timeout=10
+typeset -i makemkv_copy_largest_title_only=1
 
 ##############################################################################
 # Local Machine Settings:
@@ -336,9 +337,18 @@ if [ -z "$dvdname" ]; then
     echo "-E- Can't access the DVD device $dev"
     exit 1
   fi
+
   # now capture the volume name from the device
   dvdname=`volname $dev | awk '{ print $1 }'`
   ripdvd=1
+  # if the dvdname is still blank, go about it a different way (for BluRays)
+  if [[ -z "$dvdname" ]]; then
+    echo "-> Using makemkv to obtain disk label"
+    dvdname=`$makemkv info --noscan --robot disc:$makemkv_disc_id | grep "CINFO:2," | awk -F "," '{ print $3; }' | tr ' ' '_' | sed 's/\"//g'`
+    echo "   Found disk label: $dvdname"
+    ripdvd=1
+  fi
 
 else 
 
@@ -1121,7 +1131,7 @@ function make_dvd_mkv_image {
     dstdir=${dstmkv%.[^.]*}
     ((min_length = minimum_feature_title_length * 60))
 
-    echo -e "\n   Ripping: $makemkv --minlength=$min_length --decrypt --progress=-same $srctype:$srcname all $dstdir"
+    echo -e "\n   Ripping: $makemkv mkv --minlength=$min_length --decrypt --progress=-same $srctype:$srcname all $dstdir"
     mkdir -p "$dstdir"
     $makemkv mkv --minlength=$min_length --decrypt --progress=-same $srctype:$srcname all $dstdir 2>&1 | tee -a "$ddrescuelog"
     makemkv_retval=$?
@@ -1130,22 +1140,24 @@ function make_dvd_mkv_image {
        fatal_and_exit "-E- Unhandled makemkv error"
     fi
 
-    # Move the largest created MKV file into place
-    # There might be multiple ones, so just grab the largest one
-    largest_mkv_file=`/bin/ls -1S "$dstdir"/*.mkv | head -1`
-    echo -e "\n   Moving largest mkv file $largest_mkv_file -> $dstmkv\n" | tee -a "$ddrescuelog"
-    mv "$largest_mkv_file" "$dstmkv"
-
-    # Move all of the created MKV file into place
-    #echo "\n" | tee -a "$ddrescuelog"
-    #dstfile=${dstmkv%.[^.]*}
-    #typeset -i num=0
-    #for i in `/bin/ls -1 "$dstdir"/*.mkv`; do
-    #echo -e "   Moving $i -> $dstfile.$num.mkv" | tee -a "$ddrescuelog"
-    #mv "$i" "$dstfile.$num.mkv"
-    #((num = num + 1 ))
-    #done
-    #echo "\n" | tee -a "$ddrescuelog"
+    if [ $makemkv_copy_largest_title_only -eq 1 ]; then
+      # Move the largest created MKV file to destination
+      # There might be multiple ones, so just grab the largest one
+      largest_mkv_file=`/bin/ls -1S "$dstdir"/*.mkv | head -1`
+      echo -e "\n   Moving largest mkv file $largest_mkv_file -> $dstmkv\n" | tee -a "$ddrescuelog"
+      mv "$largest_mkv_file" "$dstmkv"
+    else
+      # Move all of the created MKV files to destination
+      echo "\n" | tee -a "$ddrescuelog"
+      dstfile=${dstmkv%.[^.]*}
+      typeset -i num=0
+      for i in `/bin/ls -1 "$dstdir"/*.mkv`; do
+        echo -e "   Moving $i -> $dstfile.$num.mkv" | tee -a "$ddrescuelog"
+        mv "$i" "$dstfile.$num.mkv"
+        ((num = num + 1 ))
+      done
+      echo "\n" | tee -a "$ddrescuelog"
+    fi
 
     if [ $? != 0 ]; then
        fatal_and_exit "-E- Unhandled mv error"