Difference between revisions of "User:Cactus/ScriptForDvdBackup"

From ArchWiki
Jump to: navigation, search
m
(rm template, categories)
 
(11 intermediate revisions by 9 users not shown)
Line 1: Line 1:
[[Category:CD/DVD]]
+
Requirements: [[Wine]], {{pkg|libdvdcss}}, {{pkg|libdvdread}}
[[Category:Scripts]]
 
I created a simple script for backing up a DVD and thought I'd share.
 
  
First you need wine, libdvdcss and libdvdread installed and have wine configure itself for your user
+
Download and install [http://www.dvdshrink.org/what_en.php DVDShrink 3.1] from http://www.afterdawn.com/software/video_software/dvd_rippers/dvd_shrink.cfm:
sudo pacman -S wine libdvdcss libdvdread wine
 
  
Then download and install DVDShrink 3.1 http://www.dvdshrink.org/where.html
+
  $ unzip dvdshrink*.zip
  unzip dvdshrink*.zip
+
  $ wine dvdshrink*.exe
  wine dvdshrink*.exe
 
  
 
You also need to find dvdbackup.c and compile it
 
You also need to find dvdbackup.c and compile it
  gcc -o dvdbackup -ldvdread dvdbackup.c
+
 
 +
  $ gcc -o dvdbackup -ldvdread dvdbackup.c
  
 
And for simplicity's sake make a batch script to have wine run DVDShrink 3.1
 
And for simplicity's sake make a batch script to have wine run DVDShrink 3.1
echo wine /home/username/.wine/drive/c/Program\ Files/DVD\ Shrink/DVD\ Shrink\3.1.exe > wine_dvdshrink
+
 
</pre>
+
{{hc|wine_dvdshrink|
 +
#!/bin/bash
 +
wine "$HOME/.wine/drive/c/Program Files/DVD Shrink/DVD Shrink 3.1.exe"
 +
}}
  
 
Almost everything is in place just need to move some files around
 
Almost everything is in place just need to move some files around
  
<pre>
+
$ chmod 755 dvdbackup
chmod 555 dvdbackup
+
$ chmod 755 wine_dvdshrink
chmod 555 wine_dvdshrink
+
# mv dvdbackup /usr/bin/
sudo mv dvdbackup /usr/bin/
+
# mv wine_dvdshrink /usr/bin/
sudo mv wine_dvdshrink /usr/bin/
 
</pre>
 
  
 
All done now except for the actual script which does all of the work.
 
All done now except for the actual script which does all of the work.
Line 31: Line 29:
 
you want to read, burn and where you want to store the temporary VOB files.
 
you want to read, burn and where you want to store the temporary VOB files.
  
<pre>
+
{{bc|<nowiki>
#!/bin/sh
+
#!/bin/bash
  
#setup for reader and directories
+
# setup for reader and directories
 
TheDVDReader="/dev/cdroms/cdrom1"
 
TheDVDReader="/dev/cdroms/cdrom1"
 
TheRIPFolder="/mnt/extrahdd/dvd_backups/"
 
TheRIPFolder="/mnt/extrahdd/dvd_backups/"
 
TheDVDBurner="/dev/cdroms/cdrom0"
 
TheDVDBurner="/dev/cdroms/cdrom0"
 +
 
# Most likely you do not need to edit the "MOVIE=" line
 
# Most likely you do not need to edit the "MOVIE=" line
MOVIE=`dvdbackup -i $TheDVDReader -I 2> /dev/null || grep "DVD-Video information" || sed -e 's/.* //g'`
+
MOVIE=$(dvdbackup -i $TheDVDReader -I 2> /dev/null || grep "DVD-Video information" || sed -e 's/.* //g')
 +
 
 +
user_query() {
 +
  case "$ready" in
 +
    [nN])
 +
      echo "Cancelled, exiting.."
 +
      exit 0
 +
      ;;
 +
    *)
 +
      ;;
 +
  esac
 +
}
  
 
clear
 
clear
 
echo "################## $MOVIE #######################"
 
echo "################## $MOVIE #######################"
 
echo "Are you ready to start copying the DVD to disk [[Y/n]]?"
 
echo "Are you ready to start copying the DVD to disk [[Y/n]]?"
 +
 
read ready
 
read ready
 
+
user_query
if [ "$ready" = "n" ]; then
 
  echo "Cancelled, exiting.."
 
  exit 0
 
fi
 
 
 
if [ "$ready" = "N" ]; then
 
  echo "Cancelled, exiting.."
 
  exit 0
 
fi
 
  
 
dvdbackup -M -i $TheDVDReader -o $TheRIPFolder
 
dvdbackup -M -i $TheDVDReader -o $TheRIPFolder
 
  
 
clear
 
clear
Line 73: Line 74:
 
echo " "
 
echo " "
 
echo "Also make sure to  insert a blank DVD into your writer now."
 
echo "Also make sure to  insert a blank DVD into your writer now."
 +
 
read ready
 
read ready
 
+
user_query
if [ "$ready" = "n" ]; then
 
  echo "Cancelled, exiting.."
 
  exit 0
 
fi
 
 
 
if [ "$ready" = "N" ]; then
 
  echo "Cancelled, exiting.."
 
  exit 0
 
fi
 
  
 
#delete temp files since now we have a .iso
 
#delete temp files since now we have a .iso
rm -rf $TheRIPFolder/$MOVIE
+
rm -rf "$TheRIPFolder/$MOVIE"
  
 
growisofs -dvd-compat -Z $TheDVDBurner=$TheRIPFolder/$MOVIE.ISO
 
growisofs -dvd-compat -Z $TheDVDBurner=$TheRIPFolder/$MOVIE.ISO
Line 93: Line 86:
 
echo "################## $MOVIE #######################"
 
echo "################## $MOVIE #######################"
 
echo "Would you like to delete the .iso at this time? [[Y/n]]"
 
echo "Would you like to delete the .iso at this time? [[Y/n]]"
 +
 
read ready
 
read ready
 +
user_query
  
if [ "$ready" = "n" ]; then
+
rm -f "$TheRIPFolder/$MOVIE.ISO"
  echo "Cancelled, exiting.."
+
</nowiki>}}
  exit 0
 
fi
 
 
 
if [[ "$ready" = "N" ]; then
 
  echo "Cancelled, exiting.."
 
  exit 0
 
fi
 
 
 
rm -f $TheRIPFolder/$MOVIE.ISO
 
</pre>
 
 
 
Any alterations with this is welcomed.  I've only tried this on my install, so I might be missing a thing or two.
 

Latest revision as of 08:55, 13 September 2014

Requirements: Wine, libdvdcss, libdvdread

Download and install DVDShrink 3.1 from http://www.afterdawn.com/software/video_software/dvd_rippers/dvd_shrink.cfm:

$ unzip dvdshrink*.zip
$ wine dvdshrink*.exe

You also need to find dvdbackup.c and compile it

$ gcc -o dvdbackup -ldvdread dvdbackup.c

And for simplicity's sake make a batch script to have wine run DVDShrink 3.1

wine_dvdshrink
#!/bin/bash
wine "$HOME/.wine/drive/c/Program Files/DVD Shrink/DVD Shrink 3.1.exe"

Almost everything is in place just need to move some files around

$ chmod 755 dvdbackup
$ chmod 755 wine_dvdshrink
# mv dvdbackup /usr/bin/
# mv wine_dvdshrink /usr/bin/

All done now except for the actual script which does all of the work. Copy and paste this into a new file and chmod it executable. Then just run this script and follow the prompts. The first few lines define variables so you can adjust what drive you want to read, burn and where you want to store the temporary VOB files.

#!/bin/bash

# setup for reader and directories
TheDVDReader="/dev/cdroms/cdrom1"
TheRIPFolder="/mnt/extrahdd/dvd_backups/"
TheDVDBurner="/dev/cdroms/cdrom0"

# Most likely you do not need to edit the "MOVIE=" line
MOVIE=$(dvdbackup -i $TheDVDReader -I 2> /dev/null || grep "DVD-Video information" || sed -e 's/.* //g')

user_query() {
  case "$ready" in
    [nN])
      echo "Cancelled, exiting.."
      exit 0
      ;;
    *)
      ;;
  esac
}

clear
echo "################## $MOVIE #######################"
echo "Are you ready to start copying the DVD to disk [[Y/n]]?"

read ready
user_query

dvdbackup -M -i $TheDVDReader -o $TheRIPFolder

clear
echo "################## $MOVIE #######################"
echo "DVDShrink will now run under wine."
echo "Make whatever changes you need to and"
echo "save your iso as z:\$TheRIPFolder/$MOVIE.ISO"

wine_dvdshrink

clear
echo "################## $MOVIE #######################"
echo "Hit return when you are ready."
echo "All files will be deleted except for your .iso"
echo " "
echo "Also make sure to  insert a blank DVD into your writer now."

read ready
user_query

#delete temp files since now we have a .iso
rm -rf "$TheRIPFolder/$MOVIE"

growisofs -dvd-compat -Z $TheDVDBurner=$TheRIPFolder/$MOVIE.ISO

clear
echo "################## $MOVIE #######################"
echo "Would you like to delete the .iso at this time? [[Y/n]]"

read ready
user_query

rm -f "$TheRIPFolder/$MOVIE.ISO"