How-To: Automate DVD & Blu-Ray (Backup, Encoding & Tagging)

HandBrake for Mac support
Forum rules
Activity Log is required for support requests. See Must Read: How To Get Questions Answered on These Forums for details

Forum Rules can be found here

How-To: Automate DVD & Blu-Ray (Backup, Encoding & Tagging)

Postby mac.jedi » Tue Oct 20, 2009 5:19 am

How-To: Automate DVD & Blu-Ray (Backup, Encoding & Tagging) for Mac OS X 10.6


Image

Introduction

Backing up a DVD or Blu-Ray library can be an arduous, time consuming task. Using a GUI tool is a simple task if you do one occasionally, but a lot of us have amassed large collections that would take days, weeks, months or even years to complete.

And, if you’ve ever tried to encode an entire season of TV episodes you know how laborious a project this can be as well: Insert a DVD, rip the disc, choose your encode settings, select and add each title to the queue, process the file, rinse and repeat for each of the discs in the season … and don't even get me started on manually doing this with Blu-ray.

The good news is that most of these tasks can be easily scripted to remove the manual intervention required. Just insert a disc and it will rip automatically. When done, pop in another. If you’ve got Mac with two or three optical drives connected, fill em' up and you’ll save yourself some trips. Set a repeating iCal alarm, and at midnight HandBrakeCLI will encode each track within the min/max duration you set in your workflow. You can even set it do multiple encodes if you'd like an iPod version, an Apple TV 720p version and/or a DTS 1080p MKV file for Plex. All you need to do now is the tagging, but why stop there … let's automate that as well! If you want to get really fancy, you can take your workflow to the next level by using folder actions or Noodlesoft's Hazel to backup your rips, add the finished files to all the iTunes Libraries on your network and sync to an Apple TV. Virtually anything is possible with automation.

Note: This tutorial assumes you have some familiarity with Mac OS X 10.6 and the ripping/encoding process. The focus of this tutorial is how to automate your workflow. It is not intended to be a beginners guide to DVD/BD encoding. If you are new to any of the concepts presented in this tutorial, I highly recommend engaging in some of the fantastic forum threads on the macrumors and handbrake forums to help get you started. Then, return to this tutorial after you have become comfortable with the process and have been successful doing it manually. See the section Additional Resources for more info.

This tutorial follows the recommended approach of ripping the complete folder structure of your optical media to your hard drive. For DVD media, this is done with FairMount. For BD media, we use MakeMKV (beta) which extracts each title of a disc into a MKV file. So instead of copying the entire disc, it will only copy the tracks that are over the minimum duration set in MakeMKV's GUI preferences. MakeMKV is still in beta and has some drawbacks. The command-line interface does not include track duration, so min/max duration filtering is not possible. Also, MakeMKV doesn't fully support BD+ titles and may not work with every disc or drive.

Until MakeMKV is out of beta, I highly recommend using AnyDVDHD for your BD backups. AnyDVDHD is developed by SlySoft.com and is considered the gold standard for BD backup. The upside to AnyDVDHD is that it fully supports Blu-Ray copying and creates a true backup of the entire disc. The downside is that it is Windows only. AnyDVDHD can be used with the free, open source VirtualBox for Mac, VMware Fusion (recommended) and Parallels. Using this method, eac3to or tsMuxeR can be used to get BD track info for use in min/max duration filtering.

Once the disc's contents have been ripped to the hard drive, the movies or TV episodes are encoded to an iTunes compatible MP4 format and/or MKV file for Plex. Next, the files are tagged with metadata iTunes, FrontRow, AppleTV or other devices can manage. The workflow is broken up into components that can be used individually or together to create one simple batch workflow.


Workflow Components

  • Getting Started
  • Batch Rip Workflow
  • Rename Files & Folders
  • Batch Encode Workflow
  • Auto-Tagging with theMovieDB.org and theTVdb.org
  • Using Hazel to manage your media



Getting Started

Batch Rip Actions for Automator
Batch Rip Actions for Automator are actions that automate each step of the batch rip and encode process.

Automator is an innovative personal automation assistant that makes it easy to automate repetitive tasks. Automator lets you skip the complex programming and scripting that is normally required to create automations. Individual steps called actions can be assembled into a complete task by dragging actions into an Automator workflow. You can run your completed workflows repeatedly, create Services, Folder Actions, iCal Alarms and Droplets.

These actions began as a series of scripts that made up my batch rip workflow. When I started writing this tutorial, the focus was to illustrate how to create these scripts and tie them together. However, with the introduction of Snow Leopard, it became clear to me that Automator and Services could make this a much simpler process.

So, I switched gears and began writing about how to use Automator along with my collection of scripts to create a really great batch workflow. However, after about a thousand lines of how to edit and compile these components, I realized that it would be even simpler to just make them pre-compiled Automator actions.

Actions are the building blocks for creating Automator workflows. Each action performs an individual step you might currently do manually‚ such as ripping a disc, changing filenames, encoding files with HandBrake, or tagging files with iTunes metadata.

This tutorial will focus on how to use these actions in our workflows. But before we get started, we need to install our actions and set up our batch folders.

To complete this tutorial you will need to download and install the following:
Batch Rip Actions for Automator v1.0.4

The actions included in this bundle include:

Batch Rip
This action copies video DVDs and BDs to a chosen folder. Will cancel after 30 seconds unless set to Run Automatically.

Batch Rip Dispatcher - NEW
This action controls the Batch Rip Dispatcher LaunchAgent which acts like a folder action to automatically launch Batch Rip when a disc is inserted.

Batch Encode
This action encodes DVD/BD content to m4v/mkv. This action receives no input from other actions, only input sources specified in the action panel. Input types: DVD-ROM, BD-ROM, VIDEO_TS, BDMV, m2ts, mkv.

Rename Movie Items
This action searches themoviedb.org for movies matching the query and renames items to the selected search result.

Add TV Tags
This action searches thetvdb.com database and adds iTunes metadata for the specified TV episode mp4/m4v files.

Add Movie Tags
This action searches themoviedb.org database and adds iTunes metadata for the specified mp4/m4v files.

Add Movie Poster
This action will add cover art to selected files.

Add Genre to Movie File
This action tags mp4 files with a selected iTunes genre.

Tag Inspector - NEW
This action displays the iTunes metadata for the input file.

Get Source Info from HandBrake - NEW
This action scans each source with HandBrakeCLI and saves the info to a text file.


Installing Batch Rip Actions for Automator

  1. Download the Batch Rip Actions for Automator installer.
  2. Open the dmg file and Double-click to run the installer.

    Image
  3. Follow the installation instructions & perform a standard installation.

    Image
  4. The Actions will be installed in your ~/Library/Automator folder. The related Automator workflow files will be placed in your ~/Library/Services. This folder contains all the pre-built workflows which are used in this tutorial (plus a few others that are helpful, but not essential to the workflow). Additional shared components will be installed in the /usr/local/bin folder on the System volume of your computer.
  5. There are also additional Service workflows provided that are not touched on in this tutorial.



Managing Your Workflow Files

A well planned folder structure will make your workflow much easier to manage. Most of these workflows rely on consistent paths to the source and destination folders, as well as the paths to the actions and applications themselves. For most users, your files should be processed on your local hard disk. External drives can be used, but in some cases they may slow down the speed of your encoding.

For this tutorial, we'll use your ~/Movies folder as the container for your workflow files and folders. Keeping your workflow under this one directory will make this process much easier. You can then have Hazel or Automator move the finished rips and encoded files to another drive or remote volume after they are done.

IMPORTANT: These workflows rely on one important piece of information that needs to be set for each disc, Video Kind. Video Kind is a variable we use in the actions to identify whether a disc contains a Movie or TV Show. The easiest way I've found to do this is to simply rip TV Shows to one folder and Movies to another. A script can then determine a disc's "kind" based on its location. The Batch Rip Dispatcher allows you to set the video kind for each disc inserted. Also included are two Services located in your Services folder that will add the “video kind” as a Spotlight comment to selected files or folders.

With the video kind set, the Batch Encode action will now know whether to encode every episode for TV Shows or only the main feature for Movies. You can also set unique min/max durations for each video kind. Video kind also helps for auto-tagging. Auto-tagging during the encoding process only works reliably for movies. TV Shows need to be done as a separate process after the files have been encoded to ensure that all the episodes have been verified, sorted and renamed properly with season and episode number.


Creating Your Batch Folders

  1. Navigate to your ~/Movies folder.
  2. Create two folders and rename them Batch Rip TV and Batch Rip Movies. These folders will be used as the destination folders for your ripped files when copied from DVDs and BDs using the Batch Rip action. These folders will also be the source folders for the Batch Encode action.
  3. Create another folder named Batch Encode. This folder will be the destination folder for your final encoded m4v/mkv files using the Batch Encode action.

    Image


About Growl Support

Growl v1.2
Growl is a free notification system for Mac OS X: it allows applications and scripts that support Growl to send you notifications.

The Batch Rip and Batch Encode actions both contain Growl support. The growlNotify command-line tool is needed by these actions to notify the Growl application. To activate notification by email or speech, navigate to the Growl System Preferences and click enable in the growlNotify application notification settings.

Image

  1. Download Growl, open the DMG file and install the application.
  2. Keeping the DMG file mounted, Open Terminal.app from your Applications/Utilities folder.
  3. Enter the following two commands in the Terminal window. Press the Return key after each command.
    Code: Select all
    cd /Volumes/Growl-1.2/Extras/growlnotify

    Code: Select all
    ./install.sh
  4. Enter your administrator password and growlNotify will then be installed in a hidden directory used for command line tools: /usr/local/bin



Using Batch Rip to Automate DVD/BD Ripping

Image

This workflow uses several technologies to automate the ripping process. For DVDs, FairMount and VLC are used to decrypt and mount DVDs on your system. A subroutine within the Action will then copy the entire DVD to your hard drive. Also, if your have more than one DVD drive, this Action will allow multiple DVDs to copy at the same time. The Action also includes Growl notification support and an option to eject the discs when finished.

For Blu-Ray, the workflow is essentially the same, except we use MakeMKV which extracts each title of a disc into a MKV file. So instead of copying the entire disc, the script will only copy the tracks that are over the minimum duration you set in MakeMKV’s GUI preferences, not the Action. For now, there is no way to get the title duration from the makemkvcon CLI. Hopefully, MakeMKV will add title duration to the CLI output in a future release.

For TV shows the Action will extract every title over the minimum duration. Movies will extract only the main title. Since MakeMKV's only output format is MKV, this will be the input format for HandBrake if further encoding is desired.

Note: It is also possible to use MakeMKV to encode DVDs straight to MKV as well, using the useOnlyMakeMkv setting in the Batch Rip Action. Same restrictions will apply to title duration.

OPTIONAL: Though this workflow does support Blu-Ray ripping using MakeMKV, the recommended way to rip a Blu-Ray disc is using a combination of VMware Fusion, Windows XP (or better), and AnyDVDHD. For this method, we launch our Windows environment, insert a disc, right-click the AnyDVDHD icon in the task bar and select "Rip Video DVD to Hard Disk…". AnyDVDHD will then copy entire disc in its original format to one of our batch folders. It can also copy multiple discs at a time if you have more than one drive, just right-click and select "Rip Video DVD to Hard Disk…" again, select your other drive in the pop-up window and Click "Copy DVD". After all the discs have been copied. We run a batch script in Windows that uses eac3to to get valuable title info from the copied files that we can later use on the Mac side to weed out unwanted tracks. This script is provided below.

Image

eac3info.command Prints eac3to info output to file
Code: Select all
for /d %%i in ("Z:\Path\to\Batch Rip Movies\*") do "C:\Path\to\eac3to\eac3to.exe" "%%i" > "%%i\%%~ni_info.txt"
)
for /d %%j in ("Z:\Path\to\Batch Rip TV\*") do "C:\Path\to\eac3to\eac3to.exe" "%%j" > "%%j\%%~nj_info.txt"
)


What you need to get started
To complete this tutorial you will need to download and install the following applications:

FairMount v1.0.5
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. You also need to use the same Bit versions for both applications: 32 or 64 Bit. Install in /Applications.
Note: (there is no need to install DVDRemaster that comes with the package)

VLC Media Player v1.0.3
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 and HandBrake to work with DVDs. Install in /Applications.
Note: You also need to use the same Bit versions for both FairMount and VLC: 32 or 64 Bit.

MakeMKV v1.4.9
MakeMKV is the only mac native app for ripping Blu-ray discs. However, at this time it doesn't fully support BD+ encrypted discs and may not work with every disc or drive. It converts DVDs and BDs into a set of MKV files. MakeMKV has a GUI and a command-line interface which is located in the application's bundle. Install in /Applications.
Note: (MakeMKV is a free beta, for now )


Creating your Batch Rip Service
This Service displays a dialog box whenever a BD-ROM or DVD-ROM is mounted. The action will cancel and ignore the disc after 30 seconds, if no action is received from the user. The dialog box will ask if you'd like to copy the disk. Choosing Movie or TV Show will set the video kind for that disc. The action will then copy the disc to your Batch Rip TV or Batch Rip Movies folder. You can also set the action to run automatically which disables the dialogs and uses the default video kind set in the action panel.

Image

  1. Launch Automator and open the "Batch Rip • Batch Rip (Service).workflow" file located in ~/Library/Automator.
  2. Set the options in the action panel.
  3. Run Automatically (disables dialog boxes and runs without user intervention).
  4. BD-ROM & DVD-ROM check-boxes (type selected will launch the workflow).
  5. Skip Duplicates prevents copying a disc if it already exists. If unchecked, it will copy the disc and append a number to the name of the new copy (useful in situations where a series of discs have the same name).
  6. Default video kind (when Run Automatically is set, this selection will copy all discs to either Batch Rip Movies or TV Folder).
  7. Set the path to the FairMount application (32 or 64-Bit, depending on version of VLC installed). Note: FairMount and VLC is required
  8. Set your output directories (see section on Folder Setup for more info).
  9. Choose additional options: Enable Growl, Eject disc when done, Use MakeMKV for DVD (instead of Fairmount), Save Session Log (saves Terminal output to ~/Library/Logs).
  10. Choose Save As > Save service as: Batch Rip • Batch Rip (Service), replacing the existing file. Note: Services are saved in ~/Library/Services.

Using Batch Rip Dispatcher
Batch Rip Dispatcher is a LaunchAgent that monitors your /Volumes directory for BD-ROM or DVD-ROM discs. It keeps a record of currently mounted discs and controls the activation of the Batch Rip Service. To control Batch Rip Dispatcher we use the "Batch Rip • Batch Rip Dispatcher" service located in the Services menu:

  1. Choose Application Menu > Services > "Batch Rip • Batch Rip Dispatcher" to run the service.
  2. A dialog box will appear with three options: Enable, Disable, and Reset.

    Image


    • Choosing Enable will activate Batch Rip Dispatcher and start watching for discs. It will then launch the Batch Rip • Batch Rip Service whenever a BD-ROM or DVD-ROM is mounted.
    • Choosing Disable will deactivate Batch Rip Dispatcher and no action will be taken when a disc is inserted.
    • Choosing Reset will disable Batch Rip Dispatcher and clear the cache of known inserted discs. You will then have the option of re-enabling it.
  3. You can enable or disable Batch Rip Dispatcher at any time by Choosing Application Menu > Services > "Batch Rip • Batch Rip Dispatcher"

Testing your Batch Rip Workflow
  1. Make sure you have enabled Batch Rip Dispatcher by Choosing Application Menu > Services > "Batch Rip • Batch Rip Dispatcher"
  2. Insert a BD or DVD. Wait for the disc to mount and the dialog box to appear asking if you’d like to copy the disc. Choose either TV Show (if the disc contains TV shows) or Movies (if disc contains movies). Choosing Ignore will ignore the disc and cancel the action. Note: no dialog will appear if you have set the action to "Run automatically".

    Note: If DVD Player.app is set to launch when a Video DVD is mounted, set "Video DVD" to "Ignore" in the CD & DVDs Preference Pane.

    Image
  3. The action will launch Terminal and display the basic setup info. If you have any errors they will be presented here, such as missing apps or incorrect paths. It will also display the options you set in the action.

    Image
  4. The action will copy each disc to the selected TV or Movie output folder.
  5. For DVDs, FairMount will launch automatically, then you'll see a graphic of cream cheese being spread on a bagel.
  6. The DVD will unmount and re-mount as a disk image.
  7. After a short delay, the DVD will start copying.

    Image
  8. 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.

  9. For BDs, makemkvcon will extract the titles in the background, but the Terminal window will display the progress.
  10. If you've set up growl support, you will be notified by display, speech or email when completed.

    Image



A Few Words on Source Folder and File Naming
Many applications use the file or folder name to get content info and cover art from sites like imdb.com, themoviedb.org and thetvdb.com. It is considered good practice to rename your files and folders, BEFORE encoding your final files. Your source files will then be named correctly making them easier to manage later. In addition, your output files will also be named correctly, allowing for a script or application to associate the correct metadata for your content.

For TV Shows the naming convention is: <Show Name - S#D#> or Veronica Mars - S1D1. The "D#" represents the disc number. If your using MakeMKV (which creates separate files for each episode), add -1, -2, etc. to the end of the filename. Example: Veronica Mars - S1D1-1.mkv. More information on tagging and renaming your final TV show files will be discussed in later chapter. Just make sure you name your source files according to the naming convention listed above.

For movies the naming convention is: <Movie Name (year)>. Example: X-Men Origins - Wolverine (2009). Note that titles that contain a colon [:] are replaced with a space and a dash [ -], as filenames cannot contain this character.

To make this process easier and more reliable for movies, I've provided an Automator Service that will search themoviedb.org database for the correct title and year, and automatically rename your movie file or folder. Just select the files or folders you want to rename and run the Service. A dialog box will appear, enter the movie title to search. Select the movie name and year that matches your content and the Service will then rename your item. The Service will loop through each item incrementally.

Additionally, there is a Rename & Tag Movie Items Service in the Workflow folder that will rename and tag selected items with iTunes metadata.

Note: themoviedb.org is a free online service. Periodic outages are not uncommon. If data is not returned, the service may be down.


Using the Rename Movie Items Service

  1. Select a movie file or folder, choose Services, and then choose > "Batch Rip • Rename Movie Items"

    Image
  2. A dialog box will appear listing the active item. Enter the movie name in the search field for this item and Choose OK.

    Image
  3. The action will search the themoviedb.org database and return a list of possible matches. Choose the movie title and year that matches your file or folder.

    Image
  4. Choose OK, and the action will rename your item to the selection. The action will repeat for each selected item.

    Image



Using Batch Encode to Automate HandBrake Encoding

Image

This Automator Action incorporates many of the tasks commonly used for processing files and includes growl support. The input sources can be files or folders located in your "Batch Rip TV" and "Batch Rip Movies" folders, or direct disc access.

If the input source resides in your Batch Rip TV folder or its Spotlight comment is set to "TV Show" the script will select each track that's between the min/max duration set in the script. If the input source resides in your Batch Rip Movies folder, or its Spotlight comment is set to "Movie", only one track is selected, provided it's between the min/max duration you set in the script for movies. The encode script will then encode and output the selected titles to your Batch Encode folder.

For DVD sources, the input types supported are MKV, VIDEO_TS folder or DVD-VIDEO Disc. The default output setting is a "Universally" compatible m4v file.

Note: DVD disc input is only supported if the same 32-Bit or 64-Bit versions of VLC and HandBrake are installed.

For Blu-Ray sources, the input types supported are MKV, M2ts, BDMV folder or Blu-Ray Disc (MakeMKV supported discs only). The script will output up to four different output formats for BD sources. The default options are:

  1. Uncompressed MKV (from MakeMKV)
  2. 1080p h.264 MKV (for Plex)
  3. 720p h.264 m4v (for AppleTV)
  4. SD iPod compatible m4v

Note: The default encode settings include a sub-routine that will set the audio output settings differently depending on the audio source. The sub-routine favors DTS pass-thru for 1080p mkv, and AC-3 pass-thru for m4v. If AC-3 is not available, it will down-convert DTS to AAC for m4v files (since DTS is not an option in m4v files). The 720p Apple TV default will not include a secondary stereo aac track if 5.1 pass-thru is available.

If a 720p m4v file is encoded, the HD flag is set to allow the HD or HD/SD logo to appear in iTunes and the AppleTV. If an HD and SD m4v is created from the same source, they will both be set with the same cnid number. This is a number that is generated from a text file that will be created in your "Batch Scripts" folder and updated every time a new source is encoded. Having the same cnid number will allow the SD and HD versions show up as one entry in iTunes. Once a m4v file is encoded, movies are then optionally embedded with iTunes XML style metadata and cover art via theMovieDB.org API.

In addition, there are "Override" settings in the script to allow you to ignore the optical drive, only encode DVD sources, set the video kind for direct disc access and use tsMuxeR instead of MakeMKV for BD sources.

Note: MakeMKV has some caveats, there is no title duration information in the CLI output, so the min/max time in the Action will not function for BD sources. You can however set the minimum track time in the GUI preferences. The makemkvcon CLI will use that preference to weed out the shorter tracks. If you are using the eac3to script to get disc info as discussed in the Batch Rip workflow, the Action will use the eac3to info file to get the title duration. The Action will then be able to encode only the tracks between the min/max duration you set in the Action. See the section on using AnyDVDHD in the Batch Rip workflow for more info.


What you need to get started
To complete this tutorial you will need to download and install the following applications:

MANDATORY
HandBrakeCLI v0.9.4
HandBrake is an open-source, GPL-licensed, multiplatform, multithreaded DVD to MPEG-4 converter, available for MacOS X, Linux and Windows. The Command Line Interface version of HandBrake is a lot faster and more flexible than the MacGui. Using scripting you can automate HandBrakeCLI to encode your files as a background process using the same parameters you'd set in the GUI. Install in /Applications.
Note: DVD disc input is only supported if the same 32-Bit or 64-Bit versions of VLC and HandBrake are installed.

How to Install HandBrakeCLI
  1. Download and open the HandBrakeCLI disk image.
  2. Next, drag the HandBrakeCLI application from the disk image to your applications folder.

    Image

VLC Media Player v1.0.3
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 and HandBrake to work with DVDs. Install in /Applications.
Note: At this time, Fairmount is only compatible with the 32-bit version of VLC. Do not install the 64-bit version if you are using Fairmount.

FOR BLU-RAY ENCODING ONLY:
MakeMKV v1.4.9
MakeMKV is the only mac native app for ripping Blu-ray discs. However, at this time it doesn't support BD+ encrypted discs and may not work with every disc or drive. It converts DVDs and BDs into a set of MKV files. MakeMKV has a GUI and a command-line (makemkvcon) interface that's located in the application's bundle. Install in /Applications.
Note: MakeMKV is not needed if you are only encoding DVD sources (not BD). MakeMKV is a free beta, for now…

OPTIONAL:
tsMuxeR v1.10.6 (Optional, use instead of MakeMKV for unencrypted BD volumes)
SmartLabs tsMuxeR is a software utility used to create TS and M2TS files from unencrypted Blu-Ray mpls and m2ts files. It will "mux" together branching titles, extract the core audio from the HD audio source. SmartLabs tsMuxeR is freeware. Install in /Applications.
Note: tsMuxeR is not required if MakeMKV is being used to mux files: at this time tsMuxeR is not compatible with Snow Leopard.


Creating your Batch Encode Service

Image

  1. Launch Automator and open the "Batch Rip • Batch Encode.workflow" file located in ~/Library/Services.
  2. Set the options in the action panel.
  3. Select "Other…" from the HandBrakeCLI pull-down menus. Navigate and Select the HandBrakeCLI application. Click Choose.
  4. Select your Batch Rip TV and Batch Rip Movies folders from the Source pull-down menus
  5. Set the minimum and maximum duration for TV and Movies sources (HandBrake will only encode tracks between these min/max durations).
  6. Select your Batch Encode folder from the output pull-down menu.
  7. Select your Default video kind from the pull-down menu (the source will encoded based on this selection if there is no Spotlight comment or the source is located somewhere other than your Batch Rip TV or Batch Rip Movies folder (like an optical drive).
  8. Choose additional options:
    • Run in the background (if enabled, the service will run as a background process with no Terminal output).
    • Verbose logging (if enabled, HandBrake will display a verbose activity log for each encode).
    • Encode HD Sources (if enabled, will encode BD-ROM, BDMV folders, mkv and m2ts sources).
    • Add iTunes tags (if enabled, will automatically add iTunes style metadata and cover art to Movie files, TV Shows need to be done as a separate process).
    • Growl when done (if enabled, will send a notification via Growl, see the Growl section in this tutorial for more info).
    • tsMuxeR override (if enabled, will use tsMuxer instead of MakeMKV for BDMV sources. At this time, tsMuxeR is not Snow Leopard compatible).
    • Encode Types (DVD is on by default, if Encode HD Sources is enabled):
      • HD (SD): if enabled, will output a HandBrake Universal m4v file
      • HD (720p): if enabled, will output a Apple TV 720p HD m4v file
      • HD (1080p): if enabled, will output a 1080p HD h.264 mkv file (useful for Plex)
    • Choose custom output settings for DVD and any of the HD output formats (Not recommended for new users).
      • To enable a custom setting, check the Encode type check-box, then click the appropriate tab for the encode type to the right.
      • Check the Use Custom Setting check-box and enter your HandBrakeCLI arguments in the text field below. See the HandBrakeCLI wiki for more info on setting your arguments.
    • To check for existing files in an existing movie library, Check the Move existing files check-box.
      • Select your movie library folder from the pull-down menu.
      • Select your retired folder from the retired folder pull-down menu. Existing movies with the same title will be moved to this folder.
  9. Choose Save As > Save Service as: Batch Rip • Batch Encode, replacing the existing file. Note: Services are saved in ~/Library/Services.
  10. You can also set up a keyboard shortcut to execute your workflow by selecting the Application Menu > Services > Services Preferences.

Using the Batch Encode Service
  1. Choose Application Menu > Services > "Batch Rip • Batch Encode" to run the service.
  2. Terminal will launch and display some basic setup info. If you have any errors they will be presented here, such as missing apps or incorrect paths. It will also display the options you set in the action.

    Image
  3. Terminal will display a list of the input sources found and detail the progress of each item/process.

    Image

    Note: If “Run in background” is selected in the action, Terminal will not launch, the action will “run in background”.
  4. If you've set up growl support, you will be notified by display, speech or email when completed.

    Image


Setting Batch Encode to Run Automatically with iCal

  1. Open Automator.
  2. Choose File > New, then select the iCal Alarm template and click Choose.
  3. Open your "Batch Rip • Batch Encode.workflow" in Automator.
  4. Drag the “Batch Encode” Action into your iCal Alarm workflow.

    Image
  5. Choose File > Save, enter a name for your iCal alarm, and then click Save. Note: iCal Alarms are saved in ~/Library/Workflows/Applications/iCal.
  6. iCal opens, automatically creates an event for your workflow, and displays the event editor. The alarm type is preset to run your workflow. By default the current time and date are in the “alarm” settings.
  7. Set the Start Time to the time you'd like your encodes to begin (ex. 12:00AM)
  8. Set the End Time to the Start Time + 1 minute (ex. 12:01AM)
  9. Set Repeat to "Every Day" (if you want it to run every day)
  10. Set End to "Never"
  11. Change the "on date" pop-up menu of the “alarm” setting to "0 minutes before" (double-click on the minutes number to change the minutes).
  12. When you are finished setting your alarm, click Done.

    Image
  13. Your workflow will now execute every day at the time specified.
  14. To deactivate and remove the alarm, choose None from the “alarm” pop-up menu.

Note: If you sync your iCal calendars with other Macs, you will get an error message if the script is not installed on the other machines. To fix this, you will need to select the calendar containing your Batch Encode Alarm on the other Macs and choose File > Get Info > and check the box next to "Ignore Alarms". If you use alarms on other events in the same calendar and do not wish them to be ignored, move the Encode Alarm to a new calendar and name it (ex. Automator) and ignore alarms only on the "Automator" calendar.



How to Automate TV Show File Tagging with iTunes Style Metadata

Rename & Tag TV Items Service
This Automator workflow will rename a set of m4v files with the following naming convention: (Show Name - S#D#-#.m4v) to (Show Name - S##E##.m4v), then tag each file with the appropriate cover art and iTunes metadata from thetvdb.org database.

IMPORTANT: Your files must be named with this naming convention BEFORE running this service: <Show Name - S#D#-#.m4v> or "Veronica Mars - S1D1-1.m4v". The "S##" signifies the season number, the "D#" represents the disc number. The "-#" is the episode sequence number for the disc and doesn't have to represent the episode number, just a number to keep them in numerical order.

If your are using the Batch Encode Action to encode your TV files, the action will automatically include the title number at the end of the name (example: Veronica Mars - S1D1-1). For DVDs the files will most likely already be in order with the disc number and title number, but this isn't always the case and is rarely the case with Blu-ray. In any case, you should always verify that all the episodes are present, any extras that may have been encoded are removed, and the files are in the correct order before renaming or tagging. Visit thetvdb.com to check your show and season to verify the number of episodes and check your files. Note, some discs may present two-part episodes as one title. In this case, these files should be processed in sets (example: if the season starts with a two-parter, process episode …E01. Process your next set with your number sequence starting at …E03, skipping …E02).

Thetvdb.com database has different options for episode ordering, Date Aired and DVD Order. Be sure to check the website to verify the correct order for your files. In most cases it will be DVD. However, some blu-ray discs have been released with a different sort order than the DVD versions. So, it’s good practice to check before renaming or tagging your files.


Using the Rename & Tag TV Items Service

  1. Visually check to make sure all the episodes have been encoded properly, in the right order and named properly.
  2. Select the sequence of files you want to rename and tag.
  3. Select the "Batch Rip • Rename & Tag TV Items" Service.

    Image
  4. The Service will launch and display the Make Finder Item Names Sequential action pane.

    Image
  5. If necessary, change the "Start Numbers at" text field if your episodes start at an episode number other than 1 (0 for Pilots). Other fields should be left alone.
  6. Choose Continue.
  7. The files will then be renamed and tagged.

    Image

    Note: thetvdb.com is a free online service. Periodic outages are not uncommon. If data is not returned, the service may be down.


Add TV Tags Service

This Automator Service will search thetvdb.org database and add iTunes style metadata to a set of m4v files named with the following naming convention: <Show Name - S##E##> (ex. Veronica Mars - S01E02). The "S##" signifies the season number and the "E##" represents the episode number.

Image


Creating the Add TV Tags Service

  1. Launch Automator and open the "Batch Rip • Add TV Tags.workflow" file located in ~/Library/Services.
  2. Choose action options:
    • Add TV Tags (if enabled, will tag selected files)
    • Replace original file (if enabled, will replace the original file with the new file)
    • Remove Tags (if enabled, will remove existing tags if present)
    • Sort Order: DVD or Date Aired (will add episode data based on the selected sort order. Check the thetvdb.com database to determine whether your files are ordered by Date Aired or DVD)
  3. Choose Save As > Save Service as: Batch Rip • Add TV Tags, replacing the existing file.


Using the Add TV Tags Service
  1. Visually check to verify that all the episodes have been named properly (ex. Veronica Mars - S01E02).
  2. Select the files you want to tag.
  3. Select the "Batch Rip • Add TV Tags" Service.
  4. Each file will then be tagged with the cover art and iTunes metadata for the show, season and episode.



How to Automate Movie File Tagging with iTunes Style Metadata

There are three services provided to add iTunes metadata and cover art using the Add Movie Tags Action:
  • Batch Rip • Add Movie Tags (Search).workflow
  • Batch Rip • Add Movie Tags (Filename).workflow
  • Batch Rip • Rename & Tag Movie Items.workflow

These workflows all use the Add Movie Tags Action and operate differently on the settings used in the Service workflows. The workflows are designed to tag movie files that have already been encoded (the Batch Encode workflow has an option to tag files as they are processed). To use, just select the files you want to tag and run a service. The workflows will then tag each file with metadata from themoviedb.org database.

Using Batch Rip • Add Movie Tags (Search)
This service will display a list of possible matches from themoviedb.org database based on your search criteria. The service will then tag the file with metadata for the title selected.

  1. Select the files you want to tag.
  2. Right-Click and Select the "Batch Rip • Add Movie Tags (Search)" Service.
  3. A dialog box will appear listing the active item. Enter the movie name in the search field for this item and Choose OK.

    Image
  4. The action will search the themoviedb.org database and return a list of possible matches. Choose the movie title and year that matches your file.

    Image
  5. Choose OK, and the action will tag the file with metadata for the selected title. The action will repeat for each selected movie file.

    Note: themoviedb.org is a free online service. Periodic outages are not uncommon. If data is not returned, the service may be down.


Using Batch Rip • Add Movie Tags (Filename)
This service will tag each file based on its filename with metadata from themoviedb.org database.

IMPORTANT: Your input files must be named properly with the following naming convention: Movie Name (year).m4v ( example: X-Men Origins - Wolverine (2009).m4v ). Titles that contain a colon [:] are replaced with a space and a dash [ -], as filenames cannot contain this character (see the section on file and folder renaming for more information). There is also a Rename & Tag Movie Items Service included in the Services menu if you also need to rename and tag your finished files.

  1. Visually check to verify that all the files have been named properly (ex. X-Men Origins - Wolverine (2009).m4v).
  2. Select the files you want to tag.
  3. Right-Click and Select the "Batch Rip • Add Movie Tags (Filename)" Service.

    Image
  4. Each file will then be tagged with the cover art and iTunes metadata for the movie.

    Image


Using Batch Rip • Rename & Tag Movie Items
This service works like Add Movie Tags (Search) but will rename the file after tagging. See the section on Using the Add Movie Tags (Search) Service for more information.


Changing options for Add Movie Tags Services
Each Service is designed to perform a certain function, however there are options available in the Add Movie Tags Action panel that you may want to tailor to fit your needs.

Image

  1. Launch Automator and open the workflow file located in ~/Library/Services.
  2. Choose action options:
    • Disable dialog and search using filename (if checked will auto-tag using the filename for the search criteria).
    • Add tags (if enabled, will tag selected files)
    • Replace existing file (if enabled, will replace the original file with the new file)
    • Remove existing tags (if enabled, will remove existing tags if present)
    • Rename file with title & year (if enabled, will rename the tagged file)
  3. Choose Save As, and replace the existing file. Note: Services are saved in ~/Library/Services.


Managing your Media with Hazel

Moving files around can be a chore, especially if you have an elaborate Mac media setup. Rather than going into each step in detail, I'll just touch on a few concepts that might peak some interest in how automation can help manage files on a multi-Mac setup.

The Batch Rip and Batch Encode workflow provide a few elements that will allow you to easily automate and organize your media. The key components are "Finder Label Index" (File/Folder Color) and "Spotlight Comments" (Finder Comments).

  1. The Batch Rip action will set the output files/folders Spotlight comment to the video kind set in the action.
  2. The Batch Encode action will take the source file's Spotlight comment and use it as the video kind, as well as derive it from the source file's location if the Batch Rip action was not used.
  3. After a source has been encoded, the Batch Encode action will change the Label color of the source file/folder to green and set the Spotlight comment of the resulting output file to the source's video kind.

We can use these elements to automate the file management process with a series of Folder Actions or with Noodlesoft's Hazel application.

Hazel http://www.noodlesoft.com is a preference pane that allows you to set up Rules based on a file's Spotlight data and specify actions to take when an item matches the Rules. This is similar to the way Smart Playlists function in iTunes and Smart Albums in iPhoto.

Image

For example: If a file or folder located in our "Batch Rip TV" or "Batch Rip Movies" has a green Label color we can assume it has already been encoded since the Batch Encode Script will change its color to green after it has been encoded. We can set a rule in Hazel that will move any file/folder that's green to a "Backup" drive. One nice thing about Hazel is that it will move the source file to the target location, not just copy it. It has some intelligence and safeguards built in to know if a file has been moved successfully and then deletes the source file, freeing up more space on our Batch Rip volume.

We can also have Hazel monitor our Batch Encode folder for files that have the extension ".m4v", have a Spotlight comment set to Movie, and have a "Musical Genre" that is not Blank. The "Musical Genre" is the generic spotlight comment for "Genre" in iTunes. If a file has a genre, we can assume it has already been tagged with metadata so it should be considered a finished file. If all these criteria match, we can have Hazel then automatically move the file to our Movie library folder, then add the file to our local iTunes library, then change its color label to purple. You can even set up Hazel on a remote Mac to monitor the Movie folder via file sharing and add and movie file that's color label is purple and add it to its iTunes libraries as well, then change its color. You can repeat this with every Mac on your network to easily sync every added file. You can also duplicate this workflow for TV Shows as well keeping the files in separate folders and automatically creating subfolders based on the show name and season.

Image

In addition to m4v files, we can have a similar Rule for our Batch Encode folder that looks for ".mkv" files with a Spotlight Comment of Movies or TV Shows and move them to a Plex depository on a local or network drive.

Hazel also allows for scripts to run when an item matches our rules. For example, with the "Move existing file to retired folder" option in the Batch Encode action enabled, you can have Hazel run an AppleScript that will remove the existing movie or TV show from iTunes when its file is added to the retired folder set in the action, helping to prevent duplicates in your library.

Hazel is a do-it-as-it-happens approach. The disc rips, the file encodes, the file is tagged, the source is backed up, the 1080p mkv is sent to a Plex folder, the m4v file is moved to my library, the file is then added to all my iTunes libraries and is sync'd to my Apple TV's. Simple and done.

The point is with a few triggers, you can easily automate the process of moving, organizing and syncing your media. I prefer Hazel for it's versatility and ease of use, but a lot of what Hazel provides can also be done with Folder Actions … but with a lot more work.

Conclusion
I hope you enjoyed this tutorial. If you've made it to the end, kudos to you. This process has been a great learning experience for me and hope it is for you as well. The elements of this workflow really demonstrate the power Mac OS X has with Unix, AppleScript, Automator and a brilliant developer community. Though this tutorial is a bit more involved than I had anticipated, I can attest that once you've got it going, you will spend less time managing your content and more time enjoying it. If you’d like to dig a little deeper, there are additional resources listed below. If you’re a power user and you’d like to customize and adapt the scripts used in these actions, the scripts are in the action bundles. Happy Encoding!

Additional Resources:
How To: Rip, Encode and Combine Using Fairmount & DTOX
Native Blu-ray ripping for OS X is finally here!
Blu-Ray to Apple TV
Advanced Bluray/HDDVD Workflow & Features Discussion
Subler (like Muxo, maybe better?)

Older automation thread
How-To: Automate DVD Backup w/ FairMount & HandBrake
Last edited by mac.jedi on Thu Dec 03, 2009 3:30 am, edited 8 times in total.
mac.jedi
 
Posts: 84
Joined: Fri Apr 25, 2008 12:17 am

 

Release Notes

Postby mac.jedi » Tue Oct 20, 2009 5:20 am

ANNOUNCEMENT: BATCH RIP ACTIONS UPDATED


Update 2009-12-02

Release Notes
Batch Rip Actions for Automator 1.0.4

Everything
  • Provides general fixes that enhance the stability, compatibility and functionality of Batch Rip Actions for Automator. In other words, I fixed a lot of stuff, but forgot write them all down.
  • Updated installer package, should provide greater compatibility for those with unique system configurations.
  • Batch Rip • Batch Rip (Folder Action).workflow has been replaced by the new Batch Rip Dispatcher LaunchAgent.
  • Tutorial has been updated to reflect the changes of v1.0.4.

Batch Rip Dispatcher.action - NEW ACTION
    This action controls the Batch Rip Dispatcher LaunchAgent which acts like a folder action to automatically launch Batch Rip when a disc is inserted.
  • IMPORTANT: The Batch Rip Folder Action is no longer supported. You need to Enable Batch Rip Dispatcher by running the Service after it is installed.

Tag Inspector.action - NEW ACTION
    This action displays all the iTunes metadata present in the input file.

Get Source Info from HandBrake.action - NEW ACTION
    This action scans each source with HandBrakeCLI and saves the info to a text file.

Batch Rip.action - UPDATED
  • Updated to version 1.0.4
  • Added support for Batch Rip Dispatcher
  • Changed the way variables are passed to the shell
  • Added an option to skip discs that already exist in the output folder or append the name of new copy.
  • Added an option to save Terminal output to ~/Library/Logs.

Batch Encode.action - UPDATED
  • Updated to version 1.0.4
  • Improved compatibility with HandBrake v0.9.4.
  • Fixed min/max title selection for Movies, where movies were returning more than one title.
  • Changed the way variables are passed to the shell, improves stability when running multiple instances
  • Added ISO8859-1 character substitution in meta-tag info.
  • The HandBrakeCLI title scan is now saved as a text file to the source directory.
  • Added an option to display a verbose activity log for HandBrake.
  • Terminal output from last session is now saved in ~/Library/Logs.

Add Movie Tags.action - UPDATED
  • Added support for Search & Tag. If enabled, will display a search field and return a list of matches instead of using filename.
  • Added ISO8859-1 character substitution in meta-tag info.
  • General improvements in returning titles, handling metadata and processing cover art.
  • Added option to remove all tags from the input file when the "Add tags" option is off.

Add TV Tags.action - UPDATED
  • Added ISO8859-1 character substitution in meta-tag info.
  • General improvements in returning episode info, handling metadata and processing cover art.
  • Added option to remove all tags from the input file when the "Add tags" option is off.

Rename Movie Items.action - UPDATED
  • Added underscore replacement when using file/folder name as search criteria.
  • Added ISO8859-1 character substitution.
  • General improvements in returning matching titles.

Add Movie Poster.action - UPDATED
  • Added underscore replacement when using file name as search criteria.
  • Added ISO8859-1 character substitution.
  • General improvements in returning matching titles.


_______________________________________________________________________________________________

Update 2009-11-10

Release Notes
1.0.3

In Apple speak, v1.0.3 provides general fixes that enhance the stability, compatibility and functionality of Batch Rip Actions for Automator

  • Added workflows to install package. Now installs Services to ~/Library/Services, and Folder Actions to ~/Library/Workflows/Applications/Folder Actions
  • Shared components are now installed in /usr/local/bin
  • Fixes an issue that might cause tagging actions to stall when adding cover art
  • Includes general reliability and speed improvements for Add TV Tags, Add Movie Tags, Add Movie Poster, Batch Encode and Batch Rip


_______________________________________________________________________________________________

Update 2009-10-27
1.0.2

Everything
  • Requires Mac OS X 10.6 or later
  • Updated installer package, should correct permissions issues some users were experiencing

Add Genre to Movie File.action - NEW ACTION
    This action tags mp4 files with a selected iTunes genre

Add Movie Poster.action - NEW ACTION
    This action will add cover art to selected files. There are three options:

  1. Disable dialogs and use clipboard: Will download an image from a URL in the clipboard. The downloaded image will be added as cover art to the mp4/m4v file.
  2. Search themoviedb.org: Will search themoviedb.org and display movie posters matching a search term in Safari. Right-click and choose Copy Link to select a image. In the dialog box Choose OK. The selected image will then be downloaded and added as cover art to the mp4/m4v file.
  3. Choose from file: Will display a choose file window. The selected image will then be added as cover art to the mp4/m4v file.

Batch Rip.action - UPDATED
  • Updated to version 1.0.1
  • Note: FairMount has a new 64-Bit version and has been updated to 1.0.5.
  • Added pop-up menu to set the path to FairMount … since FairMount now has a 64-bit version and has changed its folder structure.
  • Changed how the Action logs mounted discs
    • Folder Action log is cleared when Batch Rip start processing
    • When an active Batch Rip disc item remounts after finishing a process, no dialogs will appear
  • Changed the way Batch Rip handles discs with the same name
    • If Batch Rip is set to run automatically, Batch Rip will skip discs if an item with the same name appears in the output directory
    • If Batch Rip is NOT set to run automatically, Batch Rip will copy the disc and append the filename of the new copy with the current process ID number (PID)
  • FairMount will now quit after DVDs have been copied
  • Fixed the error some users were experiencing with MakeMKV returning "No titles longer than" for DVD-ROM sources
  • Sets the Spotlight comment for all output items to the selected video kind

Batch Encode.action - UPDATED
  • Updated to version 1.0.1
  • Changed the egrep syntax for line 786, to fix the "echo: line 786" error message
  • Updated the subroutine for tsMuxeR, but doesn't matter since tsMuxeR is still not compatible with Snow Leopard

Add Movie Tags.action - UPDATED
  • Added new tags:
    • HD-Flag: for file resolutions over 1280x720
    • Title: will add the filename as the title
    • Video Type (stik): Movie (9-Short Movie)
  • Added add chapters from file (mp4chaps)
    • Chapter file must be named: filename.chapters.txt (filename must be exactly the same as the movie file)
  • Added cover art resizing. Will now resize images to a maximum of 600x600 pixels as recommended by iTunes. Also allows Finder to update icon more effectively and reduces file size a bit.

Add TV Tags.action - UPDATED
  • Added HD-Flag: for file resolutions over 1280x720
  • Added add chapters from file (mp4chaps)
    • Chapter file must be named: filename.chapters.txt (filename must be exactly the same as the movie file)
  • Added cover art resizing. Will now resize images to a maximum of 600x600 pixels as recommended by iTunes. Also allows Finder to update icon more effectively and reduces file size a bit
Last edited by mac.jedi on Thu Dec 03, 2009 3:46 am, edited 5 times in total.
mac.jedi
 
Posts: 84
Joined: Fri Apr 25, 2008 12:17 am

Re: How-To: Automate DVD & Blu-Ray (Backup, Encoding & Tagging)

Postby splodgecat » Tue Oct 20, 2009 4:04 pm

Absolutely the most insanely impressive tutorial I have ever seen in my history in the Mac community. The effort macjedi has put in is clear to see from beginning to end - professional screenshots, thoughtful notes, tips, detailed instructions... so may I be the first to say a huge thank you on behalf of everyone who will use this tutorial. Really great work.
splodgecat
 
Posts: 9
Joined: Fri Sep 25, 2009 7:58 am

Re: How-To: Automate DVD & Blu-Ray (Backup, Encoding & Tagging)

Postby mac.jedi » Tue Oct 20, 2009 6:24 pm

splodgecat wrote:Absolutely the most insanely impressive tutorial I have ever seen in my history in the Mac community. The effort macjedi has put in is clear to see from beginning to end - professional screenshots, thoughtful notes, tips, detailed instructions... so may I be the first to say a huge thank you on behalf of everyone who will use this tutorial. Really great work.


Thanks splodgecat!

But, I'm just standing on the shoulders of geniuses. This kinda stuff wouldn't even be possible without the great work done by the HandBrake team & the community at large, in particular nightstrm, Cavalicious, JohnAStebbins, & Cave Man … these guys are awesome!
mac.jedi
 
Posts: 84
Joined: Fri Apr 25, 2008 12:17 am

Re: How-To: Automate DVD & Blu-Ray (Backup, Encoding & Tagging)

Postby fcmarriott » Wed Oct 21, 2009 12:15 am

Mac.Jedi -

Truly great how-to. I have read through the entire thing a couple of times now and plan on implementing this weekend when I get a new mac and rebuild my ripping process. Couple of quick questions, for the last ~2 years, I have been using MacTheRipper (various versions, but currently 3.0 M14), and manually output to DTOX to pull out the Movie Only (I generally rip for AppleTV and/or Iphone/Ipod viewing, I don't backup to another DVD) and to ensure there aren't any zero cells or other funny business going on. I've only used Fairmount once, is it as good as MTR (religious question maybe?) and does Fairmount remove the need for the DTOX step, meaning, does it take care of zero cells or other encryption steps that can screw with the encoding process?

I suppose secondary question, is it possible to automate the MTR and/or the DTOX steps within you workflow? Is there a need to do that?

Thanks again for the workflow, between yours and Nightstrm's detailed posts, I'm moving to Bluray ripping/encoding and looking to automate as much as possible.

/bpm
fcmarriott
 
Posts: 14
Joined: Thu May 17, 2007 2:13 am
Location: seattle

Re: How-To: Automate DVD & Blu-Ray (Backup, Encoding & Tagging)

Postby mac.jedi » Wed Oct 21, 2009 6:34 pm

fcmarriott wrote:Truly great how-to. I have read through the entire thing a couple of times now and plan on implementing this weekend when I get a new mac and rebuild my ripping process.


Thanks fcmarriott! If your budget allows, get the fastest Mac you can afford. Blu-ray takes a lot of horse-power. In 2008, I bought an 8-core Mac Pro and love it. If you have the means I highly recommend picking one up. More cores will get you much faster HB encodes. I get almost realtime encoding of BD sources, about 2-3 hours per movie. I'm interested in seeing how the quad-core iMac does with HB.

fcmarriott wrote:Couple of quick questions, for the last ~2 years, I have been using MacTheRipper (various versions, but currently 3.0 M14), and manually output to DTOX to pull out the Movie Only (I generally rip for AppleTV and/or Iphone/Ipod viewing, I don't backup to another DVD) and to ensure there aren't any zero cells or other funny business going on. I've only used Fairmount once, is it as good as MTR (religious question maybe?) and does Fairmount remove the need for the DTOX step, meaning, does it take care of zero cells or other encryption steps that can [Censored] with the encoding process?


To my knowledge, FairMount doesn't handle zero-cells or ARcoSS protected discs. Unfortunately, for these you will need to do it manually with MTR, DTOX or even RipIt.app which seems to be a great MTR alternative.

The truth is I come across so few discs that FairMount can't handle. If I do, I try HandBrake direct from disc first, MTR or RipIt second and if that fails too, I'll try DTOX. I've even used AnyDVDHD on Windows/VMware Fusion on a problem disc.

I suppose secondary question, is it possible to automate the MTR and/or the DTOX steps within you workflow? Is there a need to do that?


I don't think either of those are scriptable. Zero-cells should be dealt with manually, but again this is something I don't run into very often. So for batch ripping, my process is to let er' rip and if I come across a disc that FairMount doesn't like, I deal with it later.

I hope this helps and good luck!
mac.jedi
 
Posts: 84
Joined: Fri Apr 25, 2008 12:17 am

Re: How-To: Automate DVD & Blu-Ray (Backup, Encoding & Tagging)

Postby Calomile » Thu Oct 22, 2009 1:56 pm

Wonderful tutorial, but I'm wondering if you could help solve a slight problem I seem to be having.

I've followed all the initial preliminary steps (downloading and installing all the programs, setting up folders and the like...) but once I've installed your actions and dragged the Workflows into my Movies folder, and try to run Batch Rip.workflow, I get a message saying that the appropriate actions cannot be located. When I go into my /User/Library/ folder I am confronted by this...

Image

I'm unsure as to whether this is a problem specific to my computer/installation or is a problem other uses might be having also. Any suggestions on how to fix this would be greatly appreciated.

Cheers.
Calomile
 
Posts: 2
Joined: Thu Oct 22, 2009 1:50 pm

Re: How-To: Automate DVD & Blu-Ray (Backup, Encoding & Tagging)

Postby Calomile » Thu Oct 22, 2009 4:15 pm

Hello again!

Seems I've solved my original problem, and I'd like to offer up a solution to anyone who might also have the same problem... It would appear that the current revision of the installer installs the action files into ~/User/Library/Automator/ but doesn't set privileges for Administrator, and sets "Everyone" to no access, which was what was causing all the problems.

To solve this, right click the Automator folder and select Get Info (Cmd+I), then click the padlock button in the bottom right of the window, enter your administrator account's password, then under Sharing & Permissions, remove the _unknown value, add your user account/group (Administrators, for example) and set to Read & Write access. Do the same for everyone. The workflow files should now open in Automator!
Calomile
 
Posts: 2
Joined: Thu Oct 22, 2009 1:50 pm

Re: How-To: Automate DVD & Blu-Ray (Backup, Encoding & Tagging)

Postby mac.jedi » Thu Oct 22, 2009 4:21 pm

Hi Calomile,

Yesterday someone wrote me regarding a similar issue… where they didn't have read/write access to their ~/Library/Automator folder. I'm not sure if this was the case before the install or the installer somehow changed the permissions. I haven't encountered this on any of my test systems yet, but I'll check the installer settings again just in case.

The fix is to do a get info (Cmd+i) on the folder and scroll down to the Sharing and Permissions section. Click the lock icon and enter an Administrator username & password to unlock the panel. Choose the tool popup menu below the user list and Select > Make "your username (me)" the owner. You can also do this in panel itself, you just want your active login name to be the Owner with read/write privileges. Select the tool popup menu again and Choose > Apply to enclosed items…

I hope this helps.

Thanks, mac.jedi
mac.jedi
 
Posts: 84
Joined: Fri Apr 25, 2008 12:17 am

Re: How-To: Automate DVD & Blu-Ray (Backup, Encoding & Tagging)

Postby mac.jedi » Fri Oct 23, 2009 1:06 am

Calomile wrote:It would appear that the current revision of the installer installs the action files into ~/User/Library/Automator/ but doesn't set privileges for Administrator, and sets "Everyone" to no access, which was what was causing all the problems.


Thanks Calomile for letting me know. I updated the installer, let me know if anyone finds it's still setting the wrong permissions.
mac.jedi
 
Posts: 84
Joined: Fri Apr 25, 2008 12:17 am

Re: How-To: Automate DVD & Blu-Ray (Backup, Encoding & Tagging)

Postby westbeverly » Fri Oct 23, 2009 6:43 pm

Mac.Jedi-

Thanks very much for this incredibly thorough how-to.

I am admittedly not at all versed in Automator, etc., and am trying to implement this tutorial piece-by-piece. I am having some difficulty with the Batch Rip folder action.

Upon creating the batch rip folder action, I am able to rip a DVD, no problem. However, if I then insert a new DVD, nothing happens. If I right-click on Macintosh HD and go into Folder Actions Set-Up, I see that "Volumes" is indeed checked and the folder action listed there is the Batch Rip action I have saved (and it is checked as well) -- so, from my very limited understanding, it seems like it should be operational.

I have repeated this behavior several times -- when I cannot get a second DVD to cause the folder action to start, I delete the folder action and then re-create and save it. At this point, it will again rip the first dvd fine for me, but nothing will happen when I insert a second dvd.

Do you have any idea why that folder action will not "launch" when I insert a new DVD?

Thanks again for the tutorial and any help you (or anyone else) may be able to provide.
westbeverly
 
Posts: 2
Joined: Sat Dec 13, 2008 6:18 pm

Re: How-To: Automate DVD & Blu-Ray (Backup, Encoding & Tagging)

Postby mac.jedi » Fri Oct 23, 2009 10:43 pm

westbeverly wrote:Do you have any idea why that folder action will not "launch" when I insert a new DVD?

Hi westbeverly,
Sorry you are having trouble. I've got a few suggestions, but a solution might require more investigation:

  1. Restart your system to clear the cache and any temp files.
  2. You need to manually quit FairMount before inserting another DVD, otherwise FairMount might grab the DVD first … I had to disable the part of the Action which quits FairMount after copying as it would quit while another disc was still copying. I'll add it back soon.
  3. What are the names of the discs your trying to copy? I remember early on I was having this issue with discs that had spaces in the volume name. I fixed it, but perhaps it broke again.
  4. Post the full Terminal output from your successful copy. It may be helpful for further testing.

If you can't get it working, in the meantime you can use the "Batch Rip • Batch Rip (Service).workflow" located in the Workflows folder. Just open it, set your options and do a Save As. You can then Select a mounted disc and run the Service by Right-Click or via the Services menu.

Thanks for posting your problem. I'm sure this will help others tremendously.

Thanks again, mac.jedi
mac.jedi
 
Posts: 84
Joined: Fri Apr 25, 2008 12:17 am

Re: How-To: Automate DVD & Blu-Ray (Backup, Encoding & Tagging)

Postby squamosity » Sat Oct 24, 2009 1:04 am

What a spectacular solution, Thanks mac.jedi! This was perfectly timed. I was looking for a sane solution to batch convert AVCHD files from my camera using Handbrake and was getting frustrated with existing solutions. I'd even started to roll my own script and diving into the Handbrake Wiki for the Command Line Interface.

That was yesterday.

Today, I tried searching again for an existing solution that was simple and cheap to see if I'd missed something. To my surprise, up popped this astonishingly detailed post! My spare machine is tearing its way through a folder of videos as we speak. Yes, as you humbly point out, this is all using pre-existing software solutions and yes it's possible for one to do this for oneself. But it did take an impressive amount of effort to create all the Automator actions and workflows and then an even more impressive amount of consideration to document your solution so thoroughly.

Thanks for your efforts they are much appreciated!

Now to the feedback:
  1. I'm not sure if this is an issue isolated to my setup, but the installer failed to properly install the actions. Automator gave me errors about missing actions. I checked permissions which were ok but I noticed that the the actions had been copied to in my Home folder (~/). I opened them and was prompted by Automator if I wished to install them. After this, the workflows opened without a hitch.
  2. Your guide states that MakeMKV isn't necessary if one is not dealing with BluRay. However, the script hangs if MakeMKV is not installed. I ensured that I wasn't transcoding to 1080, just to SD. Again, not sure if I'm an isolated case, but check it out and consider adding some logic to skip the detection if 1080 output is not selected.
  3. It would nice to see a progress indicator while encoding. The script currently displays a calculated ETA for each process. I'd like to also see a time elapsed for each process as well as an approximated ETA and Time Elapsed for the entire set. I know, these types of calculations are variable and unreliable, but it would still be nice to know. Even if it's off by 2 hours, at least I know to expect 12 hours instead of 4.
  4. On a related note, growl integration is fantastic and the email alert is a good idea. However, it would be nice to have a log somewhere of the entire process that includes a record of settings, errors, time, file sizes and maybe even system settings and load. It could come in handy for troubleshooting and to compare results of past sessions.
  5. Finally, you've gone to so much trouble to put this together and I sure would like to have read a preface or endnote in the documentation about the author and a link back to the forum or other location where more current discussions are occurring.

Minor hiccups and nice-to-haves in an otherwise excellent solution.

Thanks again!
squamosity
 
Posts: 1
Joined: Fri Oct 23, 2009 11:52 pm

Re: How-To: Automate DVD & Blu-Ray (Backup, Encoding & Tagging)

Postby Starhawk » Sat Oct 24, 2009 5:44 am

Fantastic guide! Thanks.

I've only tried the Add Movie Tag Service so far, and I notice that it's not deleting the original file or changing the name of the new tagged file from movie-temp.m4v (for example). Tried it twice just now on single movies each time.
Starhawk
 
Posts: 80
Joined: Sun Feb 24, 2008 9:27 pm

Re: How-To: Automate DVD & Blu-Ray (Backup, Encoding & Tagging)

Postby Starhawk » Sat Oct 24, 2009 5:58 am

Also, how does one deal with a colon in the title of a TV Show? I see in the guide it stated to use a space and a hyphen [ -] but this does not work in the example of Star Trek: The Next Generation.

When I go to thetvdb.com and test search for it, the only thing that works is "Star Trek: The Next Generation". The following do not successfully find the show:

Star Trek The Next Generation
Star Trek -The Next Generation
Star Trek - The Next Generation
Starhawk
 
Posts: 80
Joined: Sun Feb 24, 2008 9:27 pm

Re: How-To: Automate DVD & Blu-Ray (Backup, Encoding & Tagging)

Postby mac.jedi » Sat Oct 24, 2009 7:26 am

Starhawk wrote:I notice that it's not deleting the original file or changing the name of the new tagged file from movie-temp.m4v (for example).

Hi Starhawk,

Re-read the section: A Few Words on Source Folder and File Naming. Most of the conventions are described there.

If you're trying to rename and tag a movie file, make sure you're following the instructions and using the Batch Rip • Rename & Tag Movie Items.workflow Service.

If you're only trying to Add Movie Tags, make sure you're using the Batch Rip • Add Movie Tags.workflow Service. Remember that if you're not using the rename & tag service, you files must already be named: Movie Title (YEAR).m4v

Starhawk wrote:Also, how does one deal with a colon in the title of a TV Show? I see in the guide it stated to use a space and a hyphen [ -] but this does not work in the example of Star Trek: The Next Generation.


The naming convention for TV Shows is similar to movies as described in the "A Few Words on Source Folder and File Naming" section: For movies the naming convention is: <Movie Name (year)>. Example: X-Men Origins - Wolverine (2009). Note that titles that contain a colon [:] are replaced with a space and a dash [ -], as filenames cannot contain this character.

So for "Star Trek: The Next Generation", your files should be named "Star Trek - The Next Generation - S01E21.m4v". The action will parse the file name, add the colin for the search term and return the correct xml data for the show.

I hope this answers your questions. Let me know if you need more help.

Thanks, mac.jedi
mac.jedi
 
Posts: 84
Joined: Fri Apr 25, 2008 12:17 am

Re: How-To: Automate DVD & Blu-Ray (Backup, Encoding & Tagging)

Postby jrog » Sat Oct 24, 2009 12:43 pm

This guide and set of tools is a huge help. I've been ripping/encoding/tagging for years and this was easy to setup, and is easy to use.

I'm having no issues with the ripping and encoding stages, I like the tools and the methods. I have other apps if I run into trouble discs, but I'm having issues with the Tagging.

I have not been able to find a single tagging solution that tags the way I want to tag my library. I regularly use Vidalin, iDentify, MetaX... I end up with two, sometimes three passes of tagging apps to get everything in there. I'm wondering if there is a way to dig into your tagging script and pick what goes where, so that I can determine what tags get placed in specific fields that I want them. I'm also big on artwork, most of the times I edit my own artwork and fix colors, remove credits... then I add them by hand directly in iTunes.

I guess I just need to dig into the atomic parsley my self...I'm just saying, tagging is tough, people have their own preferences. If you could point me in the right direction, in keeping with the format, I'd be very happy!

-jrog
jrog
 
Posts: 6
Joined: Tue Mar 27, 2007 4:59 pm

Re: How-To: Automate DVD & Blu-Ray (Backup, Encoding & Tagging)

Postby mac.jedi » Sat Oct 24, 2009 3:26 pm

jrog wrote:I'm wondering if there is a way to dig into your tagging script and pick what goes where, so that I can determine what tags get placed in specific fields that I want them.


Hi jrog!

Thanks for posting! Here's a link to a post on another forum that discusses the tags the Actions set: http://forums.macrumors.com/showpost.php?p=8695988&postcount=30

If you're pretty comfortable with shell scripting, you take a look at the script below which is the guts for the Add Movie Tags Action. There's another sub-routine for adding HD and cnID tags, but we'll just focus on this one for now.

If you're not comfortable with shell scripting, now is great time to start learning since you've got some interest and a goal in mind. That's how I got started doing this whole thing. There are a lot of great resources on the web for Mac as well as Unix/linux shell scripting. Apple has a great tutorial on shell scripting that's a resource I use all the time: http://developer.apple.com/mac/library/documentation/opensource/conceptual/shellscripting/Introduction/Introduction.html

Code: Select all
#!/usr/bin/env sh

# main.command
# Add Movie Tags

#  Created by Robert Yamada on 10/2/09.

#  Copyright (c) 2009 Robert Yamada
#   This program is free software: you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation, either version 3 of the License, or
#   (at your option) any later version.

#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.

#   You should have received a copy of the GNU General Public License
#   along with this program.  If not, see <http://www.gnu.org/licenses/>.

scriptPID=$$
xpathPath="/usr/bin/xpath"
xmllintPath="/usr/bin/xmllint"
atomicParsley64Path="$HOME/Library/Automator/Add Movie Tags.action/Contents/Resources/AtomicParsley64"

addiTunesTagsMovie()
{   
# variables   
discName="$movieName"
sourceTmpFolder="/tmp/$scriptPID"
tmdbApiKey="yourkeygoeshere"
discNameNoYear=`echo "$discName" | sed -e 's|\ (.*||g' -e 's|\ \-\ |:\ |g'`
# set TMDb searchTerm
searchTerm=`echo "$discNameNoYear" | sed -e 's|\ |+|g' -e "s|\'|%27|g"`
searchTermNoColin=`echo $searchTerm | sed 's|:||g'`
movieYear=`echo "$discName" | awk -F\( '{print $2}' | awk -F\) '{print $1}'`

echo -e "  Searching TMDb for ${searchTerm}... \c"
if [ ! -e "${sourceTmpFolder}/${searchTermNoColin}_tmp.xml" ]; then
   mkdir $sourceTmpFolder
   # get TMDb ID for all matches
   movieSearchXml="${sourceTmpFolder}/${searchTermNoColin}_tmp.xml"
   curl -s "http://api.themoviedb.org/2.1/Movie.search/en/xml/$tmdbApiKey/$searchTerm" > "$movieSearchXml"
   tmdbSearch=`"$xpathPath" "$movieSearchXml" //id 2>/dev/null | sed -e 's|\/id>|\||g'| tr '|' '\n' | awk -F\> '{print $2}' | awk -F\< '{print $1}'`

   # find the listing that matches the releses the release date, movie title and type
   for tmdbID in $tmdbSearch
   do      
      # download each id to tmp.xml
      movieData="${sourceTmpFolder}/${tmdbID}_tbdb_tmp.xml"
      if [ ! -e "$movieData" ]; then
         tmdbXML=`curl -s "http://api.themoviedb.org/2.1/Movie.getInfo/en/xml/$tmdbApiKey/$tmdbID" > "$movieData"`
      fi
      
#      cat "$movieData"
      # get movie title and release date
      discNameNoYearWildcard=`echo "$discNameNoYear" | sed -e 's|:|.*|g' -e 's|\&|.*|g'`
      releaseDate=`"$xpathPath" "$movieData" //released 2>/dev/null | awk -F\> '{print $2}' | awk -F\< '{print $1}' | grep "$movieYear"`
#      echo "$releaseDate"
      movieTitle=`"$xpathPath" "$movieData" //name 2>/dev/null | awk -F\> '{print $2}' | awk -F\< '{print $1}' | sed "s|&apos;|\'|g" | egrep -i "$discNameNoYearWildcard"`

      if [ "$movieTitle" = "" ]; then
         movieTitle=`"$xpathPath" "$movieData" //alternative_name 2>/dev/null | awk -F\> '{print $2}' | awk -F\< '{print $1}' | sed "s|&apos;|\'|g" | egrep -i "$discNameNoYearWildcard"`
      fi
      # verify data match, delete if not a match
      if [[ ! $releaseDate = "" && ! $movieTitle = "" ]] ; then
         echo "Title found"
         mv $movieData $movieSearchXml
      else
         if [ -e $movieData ]; then
            rm $movieData
         fi
      fi
      
   done
   if [ ! -e "$movieSearchXml" ]; then
      echo " " > "$movieSearchXml"
   fi
fi

# set metadata variables and write tags to file
if sed '1q;d' "$movieSearchXml" | grep '>' > /dev/null ; then
   movieData="$movieSearchXml"
   movieTitle=`"$xpathPath" "$movieData" //name 2>/dev/null | awk -F\> '{print $2}' | awk -F\< '{print $1}'`
   videoType=`"$xpathPath" "$movieData" "//type" 2>/dev/null | awk -F\> '{print $2}' | awk -F\< '{print $1}'`
   movieDirector=`"$xpathPath" "$movieData" "//person[@job='Director']/@name" 2>/dev/null | sed 's| name="||g' | tr '\"' '\n' | sed -e '/./!d' -e 's|^|<string>|g' -e 's|^|<dict><key>name</key>|g' -e 's|$|</string></dict>|g'`
   movieProducers=`"$xpathPath" "$movieData" "//person[@job='Executive Producer']/@name|//person[@job='Producer']/@name" 2>/dev/null | sed 's| name="||g' | tr '\"' '\n' | sed -e '/./!d' -e 's|^|<string>|g' -e 's|^|<dict><key>name</key>|g' -e 's|$|</string></dict>|g'`
   movieWriters=`"$xpathPath" "$movieData" "//person[@job='Screenplay']/@name" 2>/dev/null | sed 's| name="||g' | tr '\"' '\n' | sed -e '/./!d' -e 's|^|<string>|g' -e 's|^|<dict><key>name</key>|g' -e 's|$|</string></dict>|g'`
   movieActors=`"$xpathPath" "$movieData" "//person[@job='Actor']/@name" 2>/dev/null | sed 's| name="||g' | tr '\"' '\n' | sed -e '/./!d' -e 's|^|<string>|g' -e 's|^|<dict><key>name</key>|g' -e 's|$|</string></dict>|g'`
   albumArtists=`"$xpathPath" "$movieData" "//person[@job='Actor']/@name" 2>/dev/null | sed -e 's| name="||g' -e 's|"|, |g' -e '/./!d' -e 's|, $||'`
   releaseDate=`"$xpathPath" "$movieData" //released 2>/dev/null | awk -F\> '{print $2}' | awk -F\< '{print $1}'`
   movieDesc=`"$xpathPath" "$movieData" //overview 2>/dev/null | awk -F\> '{print $2}' | awk -F\< '{print $1}'`
   genreList=`"$xpathPath" "$movieData" "//category[@type='genre']/@name" 2>/dev/null | sed 's| name="||g' | tr '\"' '\n' | sed -e '/./!d' -e 's|^|<string>|g' -e 's|^|<dict><key>name</key>|g' -e 's|$|</string></dict>|g'`

   # parse category info and convert into iTunes genre
   if echo "$genreList" | grep 'Animation' > /dev/null ; then
      movieGenre="Kids & Family"
   elif echo "$genreList" | grep '\(Fantasy\|Science\|Science Fiction\)' > /dev/null ; then
      movieGenre="Sci-Fi & Fantasy"
   elif echo "$genreList" | grep 'Horror' > /dev/null ; then
      movieGenre="Horror"
   elif echo "$genreList" | grep '\(Action\|Adventure\|Disaster\)' > /dev/null ; then
      movieGenre="Action & Adventure"
   elif echo "$genreList" | grep '\(Musical\|Music\)' > /dev/null ; then
      movieGenre="Music"
   elif echo "$genreList" | grep 'Documentary' > /dev/null ; then
      movieGenre="Documentary"         
   elif echo "$genreList" | grep 'Sport' > /dev/null ; then
      movieGenre="Sports"         
   elif echo "$genreList" | grep 'Western' > /dev/null ; then
      movieGenre="Western"
   elif echo "$genreList" | grep '\(Thriller\|Suspense\)' > /dev/null ; then
      movieGenre="Thriller"
   elif echo "$genreList" | grep '\(Drama\|Historical\|Political\|Crime\|Mystery\)' > /dev/null ; then
      movieGenre="Drama"
   elif echo "$genreList" | grep '\(Comedy\|Road\)' > /dev/null ; then
      movieGenre="Comedy"
   fi

      # check if moviePoster already exists
      moviePoster="${sourceTmpFolder}/${searchTermNoColin}.jpg"
      if [ ! -e $moviePoster ] ; then
         getMoviePoster=`"$xpathPath" "$movieData" "//image[@type='poster' and @size='original']/@url" 2>/dev/null | sed 's|url="||g' | tr '"' '\n' | sed -e 's|^ ||' -e '/./!d' | grep -m1 ""`
         curl -s "$getMoviePoster" > $moviePoster
      fi

   # create movie tags reverseDNS xml file
   movieTagsXml="${sourceTmpFolder}/${searchTermNoColin}_tags_tmp.xml"
   if [ ! -e $movieTagsXml ] ; then
      xmlFile="<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\"><plist version=\"1.0\"><dict><key>cast</key><array>${movieActors}</array><key>directors</key><array>${movieDirector}</array><key>screenwriters</key><array>${movieWriters}</array><key>producers</key><array>${movieProducers}</array></dict></plist>"
      echo "$xmlFile" | tr -cd '\11\12\40-\176' | "$xmllintPath" --format --output "${sourceTmpFolder}/${searchTermNoColin}_tags_tmp.xml" -
   fi
   movieTagsData=`cat "$movieTagsXml"`

   # write tags with atomic parsley
   echo -e "\n*Writing tags with AtomicParsley\c"
   if [[ overWrite -eq 1 ]]; then
      "$atomicParsley64Path" "$theFile" --overWrite --artist "$albumArtists" --year "$releaseDate" --genre "$movieGenre" --description "$movieDesc" --artwork "$moviePoster" --rDNSatom "$movieTagsData" name=iTunMOVI domain=com.apple.iTunes
   elif [[ overWrite -eq 0 ]]; then
      "$atomicParsley64Path" "$theFile" --artist "$albumArtists" --year "$releaseDate" --genre "$movieGenre" --description "$movieDesc" --artwork "$moviePoster" --rDNSatom "$movieTagsData" name=iTunMOVI domain=com.apple.iTunes
   fi

else
   osascript -e 'tell application "Automator Runner" to activate & display alert "Error: Add Movie Tags" message "Error: Could not find a match." & Return & "Check Movie Name and Year."'
fi
}

#####################################################################################
# MAIN SCRIPT

while read theFile
do
   if [[ ! "${overWrite}" ]]; then overWrite=0; fi
   if [[ ! "${removeTags}" ]]; then removeTags=0; fi
   if [[ ! "${addTags}" ]]; then addTags=0; fi

   if [[ removeTags -eq 1 ]]; then
      "$atomicParsley64Path" "$theFile" --overWrite --metaEnema
   fi

   if [ -e "$atomicParsley64Path" ]; then
      if echo "$theFile" | egrep '.* \([0-9]{4}\)' ; then
         movieName=`basename "$theFile" .m4v`
         outputDir=`dirname "$theFile"`

         if [[ addTags -eq 1 ]]; then
            addiTunesTagsMovie
         fi

         if [ -e "$sourceTmpFolder" ]; then
            rm -f $sourceTmpFolder/*
            rm -d $sourceTmpFolder
         fi
      else
         osascript -e 'tell application "Automator Runner" to activate & display alert "Error: Add Movie Tags" message "Error: File Naming Convention. Cannot parse the filename." & Return & "Rename your file: Movie Name (year)"'
      fi
   else
      osascript -e 'tell application "Automator Runner" to activate & display alert "Error: Add Movie Tags" message "Error: Cannot Find AtomicParsley64." & Return & "Install MetaX in your Applications Folder"'
   fi

done


The first thing you should do is get an API key from themoviedb.org and thetvdb.com. My first attempt was with tag chimp, but I got way too many mis-matches. Unfortunately, their database is full of duplicates, incorrect and incomplete info. Both themoviedb.org and thetvdb.com have nicely managed wiki-style databases and great tutorials on how to use their APIs. The links are listed below.
http://api.themoviedb.org/2.1/
http://thetvdb.com/wiki/index.php?title=Programmers_API

The biggest learning curve for me was how to parse the xml data from the API's and how to create the xml plist file Apple uses for the rDNS atom that shows Directors, Producers, Screenwriters, etc. in Front Row and Apple TV. For this you should read up on XPATH (to parse the xml data) and xmllint (to write the iTunes plist). These are both CLI tools included in the /usr/bin directory of every modern Mac.

Adding tags is pretty easy with the right tools. This script uses MetaX's modified AtomicParsley64 CLI to write the tags (available inside the MetaX.app package). AtomicParsley has a wealth of information in the command-line help. Just enter the path to AtomicParsley (or drag the app) in the Terminal window and Press Enter. The help also includes a list of commands to get additional help on specific types of tags.

Anyway, there really is a lot to it when you're getting started. But once you've messed around with it enough, it's easy as pie.

I hope this helps point you in the right direction. I don't really want to derail the focus of this thread too much, but I'm happy to help.

Thanks, mac.jedi


Addl Resources:
http://code.google.com/p/mp4v2/wiki/iTunesMetadata
http://code.google.com/p/mp4v2/
http://mp4v2.googlecode.com/svn/doc/1.9.0/ToolGuide.html
http://atomicparsley.sourceforge.net/
mac.jedi
 
Posts: 84
Joined: Fri Apr 25, 2008 12:17 am

Re: How-To: Automate DVD & Blu-Ray (Backup, Encoding & Tagging)

Postby splodgecat » Mon Oct 26, 2009 8:39 pm

Hey macjedi

In response to some above posts:

I too have had problems getting the initial folder action to work on the *second* dvd inserted and further dvds. The dvd I was trying DID have a space in the name (SHOOTER_EUROPE). Haven't tried dvds without spaces.

The first time I got the action to work, terminal launched, and reported errors. Can't remember what they said. Unhelpful I know!

I have been unable to get terminal to launch subsequently, even when the action initiates (giving me the movie/tv choice)

I shall try what you recommended above and see if I can produce some consistent results.

*UPDATE*

Just tried 3 different DVDs with single-word names. The script seems to consistently launch. But when I click on 'Movie' NOTHING happens, even after waiting a few minutes. Terminal doesnt launch, not even once. V strange behaviour. Ive reinstalled the workflows and deleted and re-done the Folder Action process but to no avail.
splodgecat
 
Posts: 9
Joined: Fri Sep 25, 2009 7:58 am

Re: How-To: Automate DVD & Blu-Ray (Backup, Encoding & Tagging)

Postby mac.jedi » Wed Oct 28, 2009 4:48 am

ANNOUNCEMENT: BATCH RIP ACTIONS UPDATED

Release Notes
Batch Rip Actions for Automator

1.0.2

Everything
  • Requires Mac OS X 10.6 or later
  • Updated installer package, should correct permissions issues some users were experiencing

Add Genre to Movie File.action - NEW ACTION
    This action tags mp4 files with a selected iTunes genre

Add Movie Poster.action - NEW ACTION
    This action will add cover art to selected files. There are three options:

  1. Disable dialogs and use clipboard: Will download an image from a URL in the clipboard. The downloaded image will be added as cover art to the mp4/m4v file.
  2. Search themoviedb.org: Will search themoviedb.org and display movie posters matching a search term in Safari. Right-click and choose Copy Link to select a image. In the dialog box Choose OK. The selected image will then be downloaded and added as cover art to the mp4/m4v file.
  3. Choose from file: Will display a choose file window. The selected image will then be added as cover art to the mp4/m4v file.

Batch Rip.action - UPDATED
  • Updated to version 1.0.1
  • Note: FairMount has a new 64-Bit version and has been updated to 1.0.5.
  • Added pop-up menu to set the path to FairMount … since FairMount now has a 64-bit version and has changed its folder structure.
  • Changed how the Action logs mounted discs
    • Folder Action log is cleared when Batch Rip start processing
    • When an active Batch Rip disc item remounts after finishing a process, no dialogs will appear
  • Changed the way Batch Rip handles discs with the same name
    • If Batch Rip is set to run automatically, Batch Rip will skip discs if an item with the same name appears in the output directory
    • If Batch Rip is NOT set to run automatically, Batch Rip will copy the disc and append the filename of the new copy with the current process ID number (PID)
  • FairMount will now quit after DVDs have been copied
  • Fixed the error some users were experiencing with MakeMKV returning "No titles longer than" for DVD-ROM sources
  • Sets the Spotlight comment for all output items to the selected video kind

Batch Encode.action - UPDATED
  • Updated to version 1.0.1
  • Changed the egrep syntax for line 786, to fix the "echo: line 786" error message
  • Updated the subroutine for tsMuxeR, but doesn't matter since tsMuxeR is still not compatible with Snow Leopard

Add Movie Tags.action - UPDATED
  • Added new tags:
    • HD-Flag: for file resolutions over 1280x720
    • Title: will add the filename as the title
    • Video Type (stik): Movie (9-Short Movie)
  • Added add chapters from file (mp4chaps)
    • Chapter file must be named: filename.chapters.txt (filename must be exactly the same as the movie file)
  • Added cover art resizing. Will now resize images to a maximum of 600x600 pixels as recommended by iTunes. Also allows Finder to update icon more effectively and reduces file size a bit.

Add TV Tags.action - UPDATED
  • Added HD-Flag: for file resolutions over 1280x720
  • Added add chapters from file (mp4chaps)
    • Chapter file must be named: filename.chapters.txt (filename must be exactly the same as the movie file)
  • Added cover art resizing. Will now resize images to a maximum of 600x600 pixels as recommended by iTunes. Also allows Finder to update icon more effectively and reduces file size a bit

Enjoy!
mac.jedi
 
Posts: 84
Joined: Fri Apr 25, 2008 12:17 am

Re: How-To: Automate DVD & Blu-Ray (Backup, Encoding & Tagging)

Postby splodgecat » Wed Oct 28, 2009 1:25 pm

The update seems to have fixed a lot of errors for me. DVDs now activate the script consistently. However on first go, Terminal produced:

laptop:~ nathan$ /Users/nathan/Library/Automator/Batch\ Rip.action/Contents/Resources/batchRip.sh ; exit;

ERROR: makemkvcon command tool is not setup to execute
ERROR: attempting to use tool at /Applications/MakeMKV.app/Contents/MacOS/makemkvcon

ERROR: makemkvcon command tool could not be found
ERROR: makemkvcon can be installed in ./ /usr/local/bin/ /usr/bin/ ~/ or /Applications/

logout

[Process completed]

I installed MakeMKV, and it worked. So it seems even if you're not using MakeMKV (I'm not, and I checked that the tickbox was UNticked) you're still required to install it.

Terminal did produce some crap after the copy though:

*Scanning DVD-ROM: STARDUST_UK
Copying /Volumes/STARDUST_UK

- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2009-10-28 12:17:11.821 osascript[15427:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found. Did find:
/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper
osascript: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.


PROCESSING COMPLETE
Disk /Volumes/STARDUST_UK ejected
End: Wed 28 Oct 2009 12:17:30 GMT
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -

logout

[Process completed]
splodgecat
 
Posts: 9
Joined: Fri Sep 25, 2009 7:58 am

Re: How-To: Automate DVD & Blu-Ray (Backup, Encoding & Tagging)

Postby mac.jedi » Wed Oct 28, 2009 2:50 pm

splodgecat wrote:The update seems to have fixed a lot of errors for me. DVDs now activate the script consistently.


Cool splodgecat, I'm glad you got it workin'. I'll check on the makeMKV requirement.

Code: Select all
2009-10-28 12:17:11.821 osascript[15427:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types:  dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found.  Did find:
   /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper
osascript: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.


This is an Adobe scripting addition module that it incompatible with Snow Leopard. When I did a clean install of 10.6 and then installed Adobe CS 3.3, 10.6 threw up an error and asked me if I wanted to remove it. If you did an upgrade-install perhaps it doesn't notify you. The solution is to remove it manually as it won't work anyway. It looks like it's located in /Library/ScriptingAdditions. As you can see, I still have mine:
Image
mac.jedi
 
Posts: 84
Joined: Fri Apr 25, 2008 12:17 am

Re: How-To: Automate DVD & Blu-Ray (Backup, Encoding & Tagging)

Postby mac.jedi » Wed Oct 28, 2009 6:10 pm

splodgecat wrote:
Code: Select all
    ERROR: makemkvcon command tool is not setup to execute
    ERROR: attempting to use tool at /Applications/MakeMKV.app/Contents/MacOS/makemkvcon

    ERROR: makemkvcon command tool could not be found
    ERROR: makemkvcon can be installed in ./ /usr/local/bin/ /usr/bin/ ~/ or /Applications/



I checked the code and there was a typo in the code that switches the BD-ROM function on and off … it seems that the force was not with me on that one.

I updated the Batch Rip.action to 1.0.1b at about 8:30 PST. I highly recommend re-downloading and using the custom install to replace the Batch Rip action.

Thanks for letting me know, mac.jedi
mac.jedi
 
Posts: 84
Joined: Fri Apr 25, 2008 12:17 am

Re: How-To: Automate DVD & Blu-Ray (Backup, Encoding & Tagging)

Postby splodgecat » Thu Oct 29, 2009 12:18 pm

Thanks for your help mate you've been brilliant.

Now I've moved on to perfecting the encode stage.

I've tried to customize the rip settings for standard DVD sources.

Any idea why the script is producing this error?

Code: Select all
PROCESSING: Stardust (2007)

*Scanning Folder: 'Stardust (2007)'
  Will encode the following tracks: 1


*Creating Stardust (2007).m4v
Using Custom/DVD-toolArgs: -f mkv -m -e x264 -q 0.600000023841858 -a 1 -E ac3 -B 160 -R Auto -6 auto -p -x ref=3:mixed-refs:bframes=3:b-pyramid:weightb:filter=-2,-1:trellis=1:analyse=all 8x8dct:me=umh:subme=9:psy-rd=1,1 -s 1 2 -F -U


  Script could not complete because Stardust (2007).m4v does NOT exist
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -

PROCESSING COMPLETE: Stardust (2007)


If anyone's interested I'm attempting to use Constant Quality to produce a sort of default high quality setting that I can use for nearly all sources (apart from animation and old tv shows - which I'll have to master once I get to them :? ). I'm experimenting with putting soft subtitles into the mkv format which from what I hear the latest handbrake snapshot can do.
splodgecat
 
Posts: 9
Joined: Fri Sep 25, 2009 7:58 am

Re: How-To: Automate DVD & Blu-Ray (Backup, Encoding & Tagging)

Postby mac.jedi » Thu Oct 29, 2009 4:26 pm

splodgecat wrote:Any idea why the script is producing this error?
Code: Select all
*Creating Stardust (2007).m4v
Using Custom/DVD-toolArgs: -f mkv -m -e x264 -q 0.600000023841858 -a 1 -E ac3 -B 160 -R Auto -6 auto -p -x ref=3:mixed-refs:bframes=3:b-pyramid:weightb:filter=-2,-1:trellis=1:analyse=all 8x8dct:me=umh:subme=9:psy-rd=1,1 -s 1 2 -F -U

Script could not complete because Stardust (2007).m4v does NOT exist


Hi splodgecat,
I haven't had time to really look into it, but it do see a couple of issues:
First, the action wasn't designed to create mkv files from DVD sources, only mp4/m4v for DVD, so it gonna try to create an mp4 file even if you specify -f mkv. HandBrake sets the format from the filename which gets set to .m4v in the action. Is there a reason you need mkv?

Second, I tried your args without the mkv format flag and it still fails so there is something else going on in your args as well. I tested a couple of my other arg sets and they start to encode fine. Have you tried your args with the CLI or hand selecting in the GUI?
mac.jedi
 
Posts: 84
Joined: Fri Apr 25, 2008 12:17 am

Next

Return to Mac