Automatic DVD to .iso copy after disc insert with two drives

applescriptbashdvdoptical-driveterminal

I have a lot of DVDs (Movies) that I want to save as an .iso preferably using dd. To speed up the process I have two drives.

I'd like to set up a script (pure bash or bash + AppleScript combination) that runs on insert. macOS allows to configure a script in Settings › CDs & DVDs › On insert…

The process should look like this:

  1. Insert DVD in one of the two drives
  2. Script starts and checks which drive triggered the command (hardest part for me)
  3. Opens a Terminal window and runs the actual script

A rough draft of what my idea is:

#!/bin/bash
diskutil umountDisk /dev/THEDRIVE
echo -n `date "+%Y-%m-%d - %H:%M:%S -> Starting with DISCTITLE"` >> iso.log
dd if=/dev/THEDRIVE | pv -s DRIVESIZE | dd of=/myfolder/DISCTITLE.iso
echo -n `Finished DISCTITLE, took TIME. Ejecting.`
drutil tray eject -drive DRIVENUMBER
  1. Close the Terminal window after ejecting

UnmountDisk for dd, write to log, copy with status using pv, write to log again and eject the disc after finishing.

What I don't know is how I get the part with the two drives right. And set up the script so that it handles it right.

drutil status tells size and device. mount tells the name. But I have, of course, always both drives present.

How could I use e.g. awk or sed to get device/mountpoint, disc title, size and drivenumber (to eject the right one) of the current disc?

Best Answer

I've managed to solve it very easily.

After comparing Mac DVD Ripper Pro, MacX DVD Ripper Pro (don't confuse the two), RipIt and AnyDVD for Windows. I decided to use Mac DVD Ripper Pro.

It has a setting to start automatically after inserting a DVD and ejecting it after being finished.

I run two instances of the app using open -n /Applications/MDRP.app. Since MDRP picks up the first DVD it finds, and the first one won't be available, the second instance will pick up the second DVD drive and vice versa.

Output .iso is not a bitwise copy, since MDRP takes care of the copy protection (at least CSS was no problem) but played well in my tests with VLC and Kodi (on my Media Server).

Only thing I didn't find were log files, but everything else I've been looking for is solved this way.

If you prefer video_ts output over .iso you can do the same thing using RipIt, RipIt also in-officially supports ripping from two drives at the same time.

Note: I haven't yet tried ripping DVDs protected with Sony ArccOS, UOPs, and Disney X-project as mentioned in the comments. CSS protection worked.

Related Question