Windows Movie Post Processing Script for AppleTV

Come up with a useful post-processing script? Share it here!
Post Reply
randyharris
Full Member
Full Member
Posts: 146
Joined: January 21st, 2010, 5:36 pm

Windows Movie Post Processing Script for AppleTV

Post by randyharris »

This is a post processing script for use with SAB for Movies.

I put this together for a buddy, if you use it, please let me know if all is well or if you had any issues that need debugging.

You can download the Batch file here.

You can see the batch code here:

Code: Select all

@ECHO OFF
Echo.
Echo.
Echo Start of the AppleTV PostProcessing Script
Echo.

:: ##################################
::
:: IMPORTANT USAGE NOTES
::
:: READ THIS NOTE OR THE SCRIPT WILL NOT WORK
::
:: SABnzbd needs to be set to not download Samples
:: To do this go into the SAB web interface:
:: CONFIG | SWITCHES | and set IGNORE SAMPLES to "do not download".
::
:: Make sure your SAB | Config | SORTING has the "Multi-part Label"
:: in the Generic Sorting Section set to: " CD%1"   (Not including the quotes)
::
:: This script will encode your movie into a single M4V file in your iTunes
:: directory and open it in MetaX, which you will tag the file with.
::
:: You can receive an email of the summary of the jobs that this script runs
:: on by doing: SAB Web interface, CONFIG | EMAIL | check the "always" box for
:: Email Notificaion on Job Completion and complete the "Email Account Settings"
:: (search the SAB forums if you're not sure how to do this.)
::
:: Be sure to set the line below that starts with "set Dest_Dir" to the actual
:: location is on your user login of your computer.
::
:: ##################################

:: One time a cop pulled me over for running a stop sign.  He said, "Didn't you
:: see stop sign?"  I said, "Yeah, but I don't believe everything I read."
::	-- Steven Wright


:: These SET locations below match the locations in the checks above.
set HandBrakeCLI="C:\Program Files\SABnzbd\HandBrake\HandBrakeCLI.exe"
set MetaX="C:\Program Files\SABnzbd\MetaX\MetaX.exe"
set MetaX_dir="C:\Program Files\SABnzbd\MetaX\"
set Mencoder="C:\Program Files\SABnzbd\Mencoder\mencoder.exe"
set Dest_Dir="C:\Users\bobbyj\Music\iTunes\iTunes Music"

:: Remove Directory Quotes
set Dest_Dir=%Dest_Dir:"=%
set MetaX_dir=%MetaX_dir:"=%


:: Lets see if these applications are where we expect them to be

Echo Checking to see if specified locations are accurate:
Echo.
if exist %HandBrakeCLI% GOTO DoneHBck
Echo.
Echo * * * W A R N I N G * * *
Echo *** HandBrake CLI was not found, make sure it matches the location
Echo *** specified in the AppleTV Post Processing Script.
Echo ***
Echo *** It can be downloaded here: http://handbrake.fr/downloads.php
Echo * * * E N D  W A R N I N G * * *
Echo.
:DoneHBck

if exist %MetaX% GOTO DoneMetack
Echo.
Echo * * * W A R N I N G * * *
Echo *** MetaX was not found, make sure it matches the location
Echo *** specified in the AppleTV Post Processing Script.
Echo ***
Echo *** It can be downloaded here: http://www.danhinsley.com/MetaX.htm
Echo * * * E N D  W A R N I N G * * *
Echo.
:DoneMetack

if exist %Mencoder% GOTO DoneMenck
Echo.
Echo * * * W A R N I N G * * *
Echo *** Mencoder was not found, make sure it matches the location
Echo *** specified in the AppleTV Post Processing Script.
Echo ***
Echo *** It can be downloaded here: http://www.mplayerhq.hu/design7/dload.html#binaries
Echo * * * E N D  W A R N I N G * * *
Echo.
:DoneMenck

if exist "%Dest_Dir%" GOTO DoneDestDirck
Echo.
Echo * * * W A R N I N G * * *
Echo *** The Destination Directory where the AppleTV movies will go does
Echo *** not exist, make sure it matches the location
Echo *** specified in the AppleTV Post Processing Script.
Echo ***
Echo *** This directory was not found:
Echo *** "%Dest_Dir%"
Echo * * * E N D  W A R N I N G * * *
Echo.
:DoneDestDirck

:: Matching the Windows variables to Mac
set DIR=%1
set DIR=%DIR:"=%
set NZB_FILE=%2
set NAME=%3
set NZB_ID=%4
set CATEGORY=%5
set GROUP=%6
set STATUS=%7

:: You can Fake the SAB Settings by uncommenting these lines below
:: Be sure to comment them again with ":: when you are through testing"
::
:: set DIR="C:\Documents and Settings\Administrator\Desktop\Great Movie"
:: set DIR=%DIR:"=%
:: set NZB_FILE=Great Movie.nzb
:: set NAME=Great Movie
:: set NZB_ID=
:: set CATEGORY=movies
:: set GROUP=alt.binaries.greatmovies
:: set STATUS=0

Echo.
Echo.
Echo SABnzbd Output Parameters:
Echo.
echo DIR: %DIR%
echo NZB_FILE: %NZB_FILE%
echo NAME: %NAME%
echo NZB_ID: %NZB_ID%
echo CATEGORY%CATEGORY%
echo GROUP: %GROUP%
echo STATUS: %STATUS%

Echo.
Echo Determining the file type from known list...
Echo.
Echo    (MKV, AVI, MP4, WMV, IMG, ISO, Video_TS)
Echo.
pushd "%DIR%"
Echo The directory searched for a file is:
Echo "%DIR%"
Echo.
Echo The file(s) found here:
dir /b
Echo.
if exist "%DIR%\video_ts" set filetype=.iso && GOTO VIDEOTS
if exist *.avi set filetype=.avi && GOTO JoinAVI
if exist *.mkv set filetype=.mkv && GOTO Transcode
if exist *.mp4 set filetype=.mp4 && GOTO Transcode
if exist *.wmv set filetype=.wmv && GOTO Transcode
if exist *.img set filetype=.img && GOTO IMGISOVIDEOTS
if exist *.iso set filetype=.iso && GOTO IMGISOVIDEOTS
Echo.
Echo Sorry, no valid video file was found
Echo.
GOTO EOF


:JoinAVI
Echo.
Echo File type is AVI, checking to join 2 AVI's
Echo.

:: The section below will join 2 AVI files into a single file
pushd "%DIR%"
FOR %%A IN (.) do set newname=%%~nA
if exist *cd2*.avi GOTO JoinAVI2
Echo    - Did not find 2 AVI's, processing as single file.
Echo.
GOTO Transcode

:JoinAVI2
Echo   - CD2 found, Joining AVI's
ren *cd2*.avi 2nd.avi
if exist *cd1*.avi ren *cd1*.avi 1st.avi && GOTO JoinAVI3
GOTO Transcode


:JoinAVI3
%Mencoder% -oac copy -ovc copy -o "%newname%.avi" 1st.avi 2nd.avi >nul
del /q "%DIR%\1st.avi"
del /q "%DIR%\2nd.avi"
GOTO Transcode


:VIDEOTS
Echo.
if exist "%Dest_Dir%\%%~ni%.m4v" GOTO Dupe
pushd "%DIR%"
      echo VIDEO_TS DVD rip found, converting.
      echo.
      echo The next section of information is output from HandBrake,
      echo try your best to ignore it.
      echo.
      echo.
      %HandBrakeCLI% --input "%DIR%" --output "%Dir%\%%~ni%.m4v" --longest --preset="AppleTV" >nul
)
Echo.
Echo    - Transcoding complete.
Echo.
GOTO TAGGING


:IMGISO
Echo.
if exist "%Dest_Dir%\%%~ni%.m4v" GOTO Dupe
pushd "%DIR%"
for /f "tokens=* delims=" %%i in ('dir/b/a-d *%filetype%') do (
      echo   - Transcoding: %%i
      echo.
      echo The next section of information is output from HandBrake,
      echo try your best to ignore it.
      echo.
      echo.
      %HandBrakeCLI% --input "%%i" --output "%Dir%\%%~ni%.m4v" --longest --preset="AppleTV" >nul
)
Echo.
Echo    - Transcoding complete.
Echo.
GOTO TAGGING


:Transcode
Echo.
pushd "%DIR%"
for /f "tokens=* delims=" %%i in ('dir/b/a-d *%filetype%') do (
      echo   - Transcoding: %%i
      echo.
      echo The next section of information is output from HandBrake,
      echo try your best to ignore it.
      echo.
      echo.
      if exist "%Dest_Dir%\%%~ni%.m4v" GOTO Dupe
      %HandBrakeCLI% --input "%%i" --output "%Dir%\%%~ni%.m4v" --preset="AppleTV" >nul
)
Echo.
Echo    - Transcoding complete.
Echo.
GOTO TAGGING


:TAGGING
pushd "%DIR%"
for /f "tokens=* delims= " %%a in ('dir/b *.m4v') do (
::: set path=%%~DPa
set New_M4V=%%~NXa
Echo.
)
Echo Opening the file "%New_M4V%" with MetaX for Tagging:
Echo.
move /y "%DIR%\%New_M4V%" "%Dest_Dir%\%New_M4V%"
pushd "%MetaX_dir%"
start MetaX.exe "%Dest_Dir%\%New_M4V%"
Echo AppleTV Movies Script Complete
GOTO EOF

:DUPE
Echo.
Echo *** Skipping transcoding the file because it already exists in:
Echo.
Echo "%Dest_Dir%"
Echo.

:EOF
Last edited by randyharris on April 16th, 2010, 12:52 am, edited 1 time in total.
qas06
Newbie
Newbie
Posts: 2
Joined: August 23rd, 2010, 10:30 am

Re: Windows Movie Post Processing Script for AppleTV

Post by qas06 »

Hi Randy this is most impressive.

can i ask some questions regarding this.

i have my sabnzbd configured to execute your post script but nothing seems to happen. should the script start to run once the file has completed the extraction process?
and what happens if i have multiple downloads going on will they all trigger the convertion to apple tv once completed, so i could have multiple files converting at once?

Last question :) does this script also support extracting iso?

Thanks
randyharris
Full Member
Full Member
Posts: 146
Joined: January 21st, 2010, 5:36 pm

Re: Windows Movie Post Processing Script for AppleTV

Post by randyharris »

qas06 wrote: Hi Randy this is most impressive.

can i ask some questions regarding this.

i have my sabnzbd configured to execute your post script but nothing seems to happen. should the script start to run once the file has completed the extraction process?
and what happens if i have multiple downloads going on will they all trigger the convertion to apple tv once completed, so i could have multiple files converting at once?

Last question :) does this script also support extracting iso?

Thanks

In order for the script to know to do something, you have to have selected the category for your download, TV, Movies, Music Videos, etc... I put together a manual for the Mac version look it up in this same forum and I think it will help clear it up. And you can have endless files queued up for processing and it will do them all.
qas06
Newbie
Newbie
Posts: 2
Joined: August 23rd, 2010, 10:30 am

Re: Windows Movie Post Processing Script for AppleTV

Post by qas06 »

Thanks for the response Randy, unfortunately your AppleTV Script Installation Pak is no longer hosted
http://files.me.com/randyharris/foahkv returns file no longer available.

Could you give me some options to get the AppleTV Script Installation Pak from you

Thanks
Post Reply