Announcement
I've posted a new tutorial thread in the Apple TV and Home Theater forum:
How-To: Automating DVD & Blu-Ray (Backup, Encoding & Tagging) for Mac OS X 10.6
I hoping this one will die a graceful death.![]()
Enjoy!
Part 2: Automating DVD Backup with FairMount, HandBrake and iTunes
Parts to this tutorial:
Part 1: Introduction
Part 2: Using AppleScript to Automate Ripping
Part 3: Using a Batch Script to Automate HandBrake
Part 4: TV Show Renamer Droplet
Part 5: Add to iTunes and Auto-tag Script
Using AppleScript to Automate Ripping
This workflow uses several technologies to automate the ripping process. An AppleScript is triggered whenever a DVD is mounted (setup via the DVD preference pane). The script uses FairMount and VLC to decrypt and mount DVDs on your system. A ditto shell script copies the entire DVD to your hard drive. Optionally, if your have dual DVD drives, this script will allow two DVDs to copy at the same time into different folders. The script also includes Growl notification support.
What you need to get started
To complete this tutorial you will need to download and install the following applications:
FairMount v1.02
FairMount is a free tool that allows decryption of DVD content on the fly for a convenient access. FairMount does not perform the actual decryption, it simply forwards the data to VLC Media Player which is used for decryption - thus, VLC Media Player must be installed for FairMount to work.
Note: (there is no need to install DVDRemaster that comes with the package)
VLC Media Player v0.9.6
VLC media player is a free, open source multimedia player for various audio and video formats (MPEG-1, MPEG-2, MPEG-4, DivX, mp3, ogg, ...) as well as DVDs, VCDs, and various streaming protocols. VLC Media Player must be installed for FairMount to work.
Script Editor
The Script Editor is an application included with Mac OS X that allows editing and creating scripts using AppleScript. Scripts can be saved as plain text, scripts that open in Script Editor, or standalone applications (including droplets). Script Editor is located at /Applications/AppleScript/Script Editor.
Creating Your Batch Rip Script
- Select, Copy and Paste the batchRip script into a new Script Editor document.
Code:---------- BatchRip.scpt ---------- ---------- Updated: 01-22-2009 ---------- (* This script opens DVDs with FairMount and copies them to a destination folder with a ditto shell script. This script includes support for dual DVD drives installed in a Mac Pro, if two disks are inserted. This script also uses Growl to notify you when completed *) global diskCount, dvd1Src, dvd1copy, dvd2src, dvd2copy ---------- Properties ---------- -- The output directory for all DVD files. Default is ~/Movies/BatchRip. This folder will be automatically created on first run. property outputPath1 : "~/Movies/BatchRip" -- Set ejectDisk to yes if you want your disk(s) to eject when completed. Default is no. property ejectDisk : no ---------- Optional Properties ---------- -- Dual-Drive: If you have two DVD Drives, you can set a second output directory below to rip two disks at once. The default is ~/Movies/BatchRip2. This folder will be automatically created if 2 disks are mounted and the script is executed. property outputPath2 : "~/Movies/BatchRip2" -- Setup Growl Support: Set useGrowl to yes and set the path to the GrowlNotifyLib.scpt. property useGrowl : no -- If you have growl, set to yes. Default is no. property growlTitle : "BatchRip" property growlLibraryPath : POSIX file "Users/userloginname/Movies/BatchScripts/GrowlNotifyLib.scpt" -- Set the path to the GrowlNotifyLib.scpt. ---------- Batch Script ---------- try tell application "FairMount.app" to launch delay 20 countDisks() copyDisks() tell application "FairMount.app" to quit end try ---------- Sub-routines ---------- on countDisks() try if useGrowl is yes then setGrowl(growlTitle) of (load script growlLibraryPath) end try try tell application "System Events" to set DVDs to name of disks whose capacity is less than 8.589934592E+9 set diskCount to count of DVDs set dvd1Src to quoted form of (POSIX path of item 1 of DVDs) set dvd1copy to escapePath(outputPath1 & "/" & item 1 of DVDs) set dvd2src to quoted form of (POSIX path of item 2 of DVDs) set dvd2copy to escapePath(outputPath2 & "/" & item 2 of DVDs) end try end countDisks on escapePath(outputPath) set the search_string to " " set the replacement_string to "\\ " set AppleScript's text item delimiters to the " " set the text_item_list to every text item of the outputPath set AppleScript's text item delimiters to the replacement_string set the new_item_name to the text_item_list as string set AppleScript's text item delimiters to "" set the outputPath to new_item_name end escapePath on copyDisks() if diskCount is less than 2 then mkDir(outputPath1) do shell script "ditto " & dvd1Src & " " & dvd1copy cleanUp(dvd1Src, dvd1copy) else mkDir(outputPath1) mkDir(outputPath2) do shell script "ditto " & dvd1Src & " " & dvd1copy & " &> /dev/null & " & "ditto " & dvd2src & " " & dvd2copy cleanUp(dvd1Src, dvd1copy) cleanUp(dvd2src, dvd2copy) end if end copyDisks on mkDir(outputPath) do shell script "mkdir -p " & escapePath(outputPath) end mkDir on cleanUp(dvd, dvdcopy) try do shell script "chmod -R 755 " & dvdcopy if useGrowl is yes then set growlMessage to (characters (10 + 1) thru -2 of the dvd as string) & " has been copied." if ejectDisk is yes then do shell script "diskutil eject " & dvd if useGrowl is yes then growlMe(growlTitle, growlMessage) of (load script growlLibraryPath) end try end cleanUp ---------- End Script ----------
- Choose Script > Compile (Command-K)
- Follow the steps in the script to set the properties, if needed.
- Save the script in your ~Movies/BatchScripts folder as "batchRip.scpt"
Making Your Script the Default Action When a DVD is Inserted:
- Open System Preferences and click CDs & DVDs.
- Choose the action "Run Script…" from the DVD pop-up menu.
- Navigate and Choose your batchRip script.
- Close the window to save your settings.
Testing Your Batch Rip Automation
- Insert a DVD (or DVDs if you have a dual-drive system)
- The script will activate and automatically launch FairMount after a 20 second delay, then you'll see a graphic of cream cheese being spread on a bagel).
- The DVD will unmount and re-mount as a disk image.
- After a short delay, the DVD will start copying to your destination folder.
- FairMount will display the progress as well as any bad sectors it encounters.
Note: Some DVD's may contain copy protection measures that will result in bad sectors and a failed rip using FairMount. For these situations, it may be necessary to rip the DVD with other software such as DVD2One where you can adjust the settings manually.
- If you've set up growl support, you will be notified by display, speech or email when completed.
Go To Part 3: Using a Batch Script to Automate HandBrake