Please share [Windows] Handbrake for to iTunes script

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

Please share [Windows] Handbrake for to iTunes script

Post by randyharris »

Hi,

I'm a Mac guy loving my post processing scripts from "Imthenachoman".

I am trying to help a Windows Vista using friend setup SAB with RSS feeds and post processing so that he has a similar setup to me.

Searched the post processing thread in vane - hoping to find somebody with a script to share.

Sorting names the TV series shows "TV Show - SxxExx.xxx" and then trying to find a usable script that will take off from this point and:

1) Convert the MKV/AVI using HandBrakeCLI with the AppleTV preset to a specified folder.
2) using the TV Show and SxxExx information, add the TV show to iTunes without worrying about full tagging.

A separate script for Movies would ideally tag the transcoded movie file for cover art and other tags, and then add to iTunes.

Really appreciate any help you can provide.

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

Re: Please share [Windows] Handbrake for to iTunes script

Post by randyharris »

Cobbled together this script from the work of others on these forums - thanks.

For the most part this is working, but there is a bugaboo that I need help with.

The Sorting function of SAB is working great, but the script reverts to the downloaded name of the TV Show, not the post SORTING name.

for example, as a test I downloaded: Parks.and.Recreation.S02E19.hdtv.iTouch-MW

And it ended up in my completed base directory as: ..\TV\Parks and Recreation\Parks and Recreation - S02E19.mp4

So far so good. But when the script starts, it encodes that nice cleanly named file as: Parks.and.Recreation.S02E19.hdtv.iTo.m4v

And I believe as a result, the tagged information is wonky too.

Could somebody please be so kind as to help me fix up this script a little so that it uses the name of the file that the SORTING feature of SAB used to name the file, not the nzb file name? Thanks so much!

Code: Select all

 @ECHO OFF
set AtomicParsley="C:\Program Files\SABnzbd\AtomicParsley\AtomicParsley.exe"
set HandBrakeCLI="C:\Program Files\SABnzbd\HandBrake\HandBrakeCLI.exe" 

set name=%3
set name=%name:"=%
set dirname=%1
set dirname=%dirname:"=%


for /R "%dirname%" %%f in (*.mkv) do %HandBrakeCLI% -i "%%f" -o %TEMP%\%name%.m4v --preset="AppleTV" -v 0 && CALL :tagTVshow %TEMP%\%name%.m4v
for /R "%dirname%" %%f in (*.avi) do %HandBrakeCLI% -i "%%f" -o %TEMP%\%name%.m4v --preset="AppleTV" -v 0 && CALL :tagTVshow %TEMP%\%name%.m4v
for /R "%dirname%" %%f in (*.mp4) do %HandBrakeCLI% -i "%%f" -o %TEMP%\%name%.m4v --preset="AppleTV" -v 0 && CALL :tagTVshow %TEMP%\%name%.m4v
for /R "%dirname%" %%f in (*.wmv) do %HandBrakeCLI% -i "%%f" -o %TEMP%\%name%.m4v --preset="AppleTV" -v 0 && CALL :tagTVshow %TEMP%\%name%.m4v

GOTO :EOF

:tagTVshow
REM split down into component parts
FOR /F "TOKENS=1-3 DELIMS=-" %%a in ("%name%") DO set show="%%a"
FOR /F "TOKENS=1-3 DELIMS=-" %%a in ("%name%") DO set seasXep="%%b"
FOR /F "TOKENS=1-3 DELIMS=-" %%a in ("%name%") DO set eptitle="%%c"

REM clean up leading or trailing spaces
SET eptitle=%eptitle:" =%
SET eptitle=%eptitle: "=%
SET eptitle=%eptitle:"=%
SET show=%show:" =%
SET show=%show: "=%
SET show=%show:"=%

REM remove all spaces (and quotes)
SET seasXep=%seasXep:"=%
SET seasXep=%seasXep: =%
 

REM split down the season and episode number
FOR /F "TOKENS=1-2 DELIMS=xX" %%a in ("%seasXep%") DO set season=%%a
FOR /F "TOKENS=1-2 DELIMS=xX" %%a in ("%seasXep%") DO set episode=%%b

REM now tag the file with this information for iTunes
%AtomicParsley% %1 --overWrite --title "%eptitle%" --genre "TV Shows" --stik "TV Show" --TVShowName "%show%" --TVEpisodeNum %episode% --TVSeason %season%

echo.
echo.
echo Moving file to iTunes
echo.

cd %TEMP%\
Move %name%.m4v "C:\Documents and Settings\Administrator\My Documents\My Music\iTunes\iTunes Media\Automatically Add to iTunes\."

GOTO :EOF
Last edited by randyharris on March 21st, 2010, 1:28 am, edited 1 time in total.
markus101
Release Testers
Release Testers
Posts: 406
Joined: August 13th, 2008, 2:51 am

Re: Please share [Windows] Handbrake for to iTunes script

Post by markus101 »

Updated my script to support other Preset's at your request, hope it helps!

-Markus
Co-developer of NzbDrone (.Net NNTP PVR) - http://www.nzbdrone.com
Post Reply