AppleTV Movies and TV Show script for Mac

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

AppleTV Movies and TV Show script for Mac

Post by randyharris »

I am starting a new thread for this script since it is now out of the idea and development stage.

As this script progressed, it has become a real benefit for me in conjunction with SABnzbd+. Hopefully it will be something that you or a mate can use as well.

WHAT IS THE PURPOSE OF THIS SCRIPT?
This script is for AppleTV users who want as automated a process as possible for Video that comes through SABnzbd. This single script handles Movies and TV Shows. Recently I started using SAB and feeding it with RSS feeds, as well as using NZB index sites - it's a great tool, and I happily donated to the people that work on it. As an AppleTV user this seemed like it could be a great relationship, SABnzbd and AppleTV. Unfortunately there were few scripts on this board that did what I wanted, some did a few basics but I was looking for an end to end script that handled everything I threw at it, and one that had fall backs built into it so that it could handle things like TV Shows without Season and Episode information. I started off by modifying a script that somebody had posted, and I taught myself enough Bash knowledge via Google in order for me to complete this script. I am no programmer and Bash language looks like a foreign language to me, but I was able to get the job done.

TV Shows are auto-tagged into iTunes based on information contained from the download. In other words, if you have RSS feeds for your TV Shows - from start to finish it is a completely hands off process of them getting onto your AppleTV for viewing. If you select random shows from an NZB Indexing site, you simply need to be sure to set the Category to TV, (and the associated script will be AppleTV), and the rest is fully automatic.

Movies use iDentify for tagging and injecting into iTunes and are ready for your preview/edits before the tags are committed. I'm sure some of you use some RSS voodoo to select Movies automatically, most probably select from an indexing site. You only need to set the Category to Movies (and the associated script will be AppleTV). I also got in the habit of renaming the Movie in the SAB interface right when I add it and select the Category, that way the folder / files that are written out use the actual Movie name, and it speeds up iDentify in finding the proper tagging information. The movie will be make it through HandbrakeCLI to your destination folder and it will be opened in iDentify and awaiting your approval/edits before committing the tag/cover art to the file and injecting it into iTunes. You can have iDentify set to automatically tag without your telling it to process the information, but I find I edit enough that I want to preview it first, if nothing else but to set my preferred Genre.

WHY DO YOU USE iDentify TO TAG MOVIES?
Because it is awesome, MetaX showed promise but floundered and is not working for many. iDentify will cost you $10 to unlock everything but it is well worth it and it does a great job. You're welcome to use any other GUI tagger that you may prefer, just change the single line in the script that references iDentify to the GUI tagger of choice and it will use that instead.

WHICH MOVIE FORMATS DOES IT HANDLE?
The script will join 2 AVI's into 1. Additionally, the 2 original AVI's are moved into a new subfolder "Unjoined AVIs" for safe keeping.
The script will convert these sources for AppleTV:
MKV, M4V, MP4, AVI, WMV, ISO, IMG, and VIDEO_TS rips
Why is M4V in the list? Because not all M4V's are AppleTV compliant, it made sense to me to open up the possibility of input files, not just use MKV and AVI.

WHAT ABOUT MOVIES WITH SUBTITLES?
HandBrake does not currently support reading subtitles from MKV's, so I can't control that issue. Handbrake will read subtitles from ISO, IMG, and VIDEO_TS, however I don't have subtitles turned on, for fear that I'll burn some subtitle onto an English speaking movie - and I don't want that. In short, if it is a movie with Subtitles, you will need to handle that manually. I don't see how this could be an automated process, if you have an idea of a systematic flow of how it might be, please let me know and I'll see about incorporating it.

DOES IT HANDLE TV SHOWS WITHOUT SxxExx
Absolutely, if SxxExx information is not available it will use information from the Job Name for the Show Name, it will use the current year as the Season and defaults to an Episode number of 01.

WHY DON'T USE USE THE EPISODE TITLE IN YOUR TAGS?
I don't use them for 2 reasons, 1) I simply don't need that information, and 2) The Episode Title is not regularly given in the NZB download so I chose to not include it. The script could be modified fairly simply to incorporate the Episode Title, in fact I do use it for my racing series, Formula1, etc...

IS THE FULL JOB NAME USED FOR TAGGING?
Of course not, that would be hideous! SAB does a great job of renaming shows with SxxExx information, and I have done my best to clean up the tagging information for shows without it. For example, a show with the fictitious job name of: This.Earth.from.USA.to.China.WS.720P-ANGELiC
Would result in the following tag information: TV Show: "This Earth From USA to China", Season: 2010, Episode 01.

DO YOU DELETE THE SOURCE FILES AFTER IT'S DONE?
Sort of, I move the original folder and all the files and sub-folders within it into the Trash Bin, you will have them until you empty the Trash on your Mac.

ok - I may expand on this more later, I have done my best to documented the script pretty well internally so read through it. There are a few settings in SAB that you will need to set to work properly with the script, and there are a few local computer folder names that will need to match your system. Additionally you'll need to get HandBrakeCLI, Mencoder, and iDentify, and in the correct locations.

The version of the script that I am using is built to format the information for the motorsports I watch really, REALLY, nicely, I realize that it is a specialty thing that most people won't benefit from - no worries, having those sections of the code in the script makes no difference to you has no ill affects sitting there. If you would rather it not be there, you can easily strip those sections out of the script and it will affect nothing.


The script is done, aside from anything needing a fix.

Here is a PDF of the script that you can view in your browser.

Here is the script by itself.

Here is the script along with the apps that you need to go along with it. (The mencoder cli app is hard to find.)

Please feel free to use this for your own use, if you're on Mac and use an AppleTV that is... I can't promise, but will help troubleshoot if needed.
Last edited by randyharris on April 20th, 2010, 5:49 pm, edited 1 time in total.
randyharris
Full Member
Full Member
Posts: 146
Joined: January 21st, 2010, 5:36 pm

Re: AppleTV Movies and TV Show script for Mac

Post by randyharris »

Updates:

1) For TV Shows without SxxExx information, I had reference incorrect where it modifies the Job Name for the Show Name.
fixed.

2) Ran into a scenario where the VIDEO_TS folder wasn't off the root $DIR directory, it was down one extra level. Changed the Movies section a bit so that it will find the VIDEO_TS regardless of how many folders deep it is hiding in the $DIR.
updated.

Scripts that are linked up above in the first post have been updated to reflect these changes.
randyharris
Full Member
Full Member
Posts: 146
Joined: January 21st, 2010, 5:36 pm

Re: AppleTV Movies and TV Show script for Mac

Post by randyharris »

Small detail, I realized that the TV section was set to transcode DVD Rips and Image files, I decided to take this out because it is highly likely that the source would contain multiple episodes, and I don't know of a way to grab them all off hand.

With a DVD Movie image you generally want to nab the longest title in the rip, but for TV you often have multiple 22ish minute shows. I'll have to look. Thinking out loud - maybe if it is a TV show, and if it is a DVD image, the option should be to proceed to rip ALL titles and process accordingly. Food for thought.

For now I took the ability out of processing Image Files when it's a TV show, haven't uploaded this change, since I put on some other logic to test for DVD images - I'll wait until I run across that routine or manually test it.
randyharris
Full Member
Full Member
Posts: 146
Joined: January 21st, 2010, 5:36 pm

Re: AppleTV Movies and TV Show script for Mac

Post by randyharris »

Made a nice upgrade to the script today. Discovered you can use mkvdts2ac3 shell script and convert MKV's with DTS audio track to AC3 audio. AppleTV doesn't support DTS audio but it does AC3. So by using this setup to convert you can enjoy full 5.1 audio from MKV source video that comes with AC3.

I know how to do this 'long hand' but for SABnzbd -> script -> iTunes/AppleTV I had been suffering with DTS being converted to 2 channel audio. Back in 5.1 all au-to-matic.

The only bugger is that I had to install Xcode in order to compile 'aften' and 'libdca' on my machine. Had to 'link' mkvtoolnix also but the good news is that it works great.

Here is the info I used, http://stagingkiller.wordpress.com/2009 ... e-appletv/

But I snagged the latest copy of MKVToolNix from here: http://jonthn.free.fr/MKVtoolnix/
randyharris
Full Member
Full Member
Posts: 146
Joined: January 21st, 2010, 5:36 pm

Re: AppleTV Movies and TV Show script for Mac

Post by randyharris »

Enhancements and Refinement.

Features are pretty much there, but I decided to improve the script and give it some better abilities with how it does its functions.


* Mounted Volumes, It now makes sure your NAS/Time Capsule drive is mounted if that is the final destination. It will connect to it for you, but if unable to connect as a fail sale it puts the resulting video on your Desktop.

* Capacity Check, there are now user specified warning and abort % for drive capacity, I have it set to issue a warning when the drive is 95% full, and abort if the drive is 98% full.

* It now checks for the mkvdts2acs script, and only tries to convert MKV's with DTS to AC3 if the script is present.

* New Category, I added both in SAB and the script "Kids Movies", the only difference is that the Destination for the video can be set to a different location than "Movies".

* Category, previously, TV was my catch all category, but now a show will only be processed as a TV show if the Category is set to TV. Content with no defined Category (or with one other than: Movies, Kids Movies, TV) will be processed as a movie and placed on the Desktop.

I'll upload this newer script after I've had a chance to kick the tires a bit - having made most of the changes late at night I'm a bit skeptical that I did it error free! Syntax kills you on this stuff.
Last edited by randyharris on April 26th, 2010, 3:39 pm, edited 1 time in total.
randyharris
Full Member
Full Member
Posts: 146
Joined: January 21st, 2010, 5:36 pm

Re: AppleTV Movies and TV Show script for Mac

Post by randyharris »

CHANGE: TAGS
I have been using the AppleScript to inject tag data into iTunes, but I have noticed that the tag information isn't always persistent if I take that file and put it on another iTunes library or similar. So I am dropping the quick and dirty AppleScript routine in favor of hardcoding the tags into the files - it is a better way as they move with the file.


NEW FEATURE: CHAPTERS
I miss not having chapters on TV Shows and most movies, I figured out how to add chapters in seconds to M4V's (this doesn't require re-writing the file, just injecting some info into the header.)

By default I'm going to set TV Shows to add a chapter every 3 minutes and movies every 5. When a movie is tagged with iDentify - if the actual chapters are found they will overwrite my 5 minute chapters, but either way I get chapters which I like.
Last edited by randyharris on April 28th, 2010, 1:33 pm, edited 1 time in total.
randyharris
Full Member
Full Member
Posts: 146
Joined: January 21st, 2010, 5:36 pm

Re: AppleTV Movies and TV Show script for Mac

Post by randyharris »

Teaser: Some exciting things I've been working on.

Nearing completion and release to the hords of SABnzbd+ Mac AppleTV users. ;)
randyharris
Full Member
Full Member
Posts: 146
Joined: January 21st, 2010, 5:36 pm

Re: AppleTV Movies and TV Show script for Mac

Post by randyharris »

I'm looking for a person or three who would be interested in testing this out on their system.

I am now done with the AppleTV script. It is working stellar on my system and would like to put a version up for anybody to access, but I would feel more comfortable having a few people test it out first.

UPDATE: The DTS to AC3 is still not working in the script when executed by SAB after a download. Oddly it has always worked great for me when running the script in testing. Ok, so this is the one item left to fix that I am aware of.

Some of the new features I've added require unix binaries so I am going to package it all up into an install for the Mac. There is no way I want to put other people through the situation of jumping through hoops to compile these binaries like I had to.

If you are interested, please post a note here, or you can PM me.

I don't have documentation together for it yet, but will work on something when the first victim, err, I mean volunteer raises their hand.

Requirements:
  - You want to effortlessly get video content from SABnzbd+ to iTunes for AppleTV and other portable Apple Devices,
    say an iPhone or iPod with little or no hands on activity by yourself. 
  - Running Leopard or Snow Leopard OS X
  - You run SABnzbd+ of a recent version
  - You are comfortable opening a text file in an editor and setting half a dozen variables, folder locations mainly


This is what the script does:

[short version]
Completely hands off process getting Races and TV Shows into iTunes for both AppleTV and optionally a second Device.
Mostly hands off process for Movies. Same as TV Shows exception instead of being auto-tagged and moved to destintion folder, the movies are opened in a GUI tagger, after tagging they need to be moved to destination.


[long version]

I have it broken into three main video types that it processes, each have specific needs for me.

Races (Formula1, MotoGP, World Rally Car) - no worries if you don't watch these it won't matter.
- Virtually all single file source files are valid input files; I have excluded IMG, ISO, VIDEO_TS because
  they often contain more than 1 episode and that can't be automated.
- Name massaged into something nice, even do a custom lookup to get the Round number (episode number)
- MKVs: DTS audio (if present) converted to AC3.
- MKVs: Determine the frames per second and pixel resolution to determine if it can be encoded in 720P for the AppleTV
- MKVs: Determine the presence of SubTitles (you can add SRT subtitles to M4V's that are user selectible on/off.) This would be done manually after the Process is completed.
- Chapters added every 3 minutes
- HandBrakeCLI transcodes for AppleTV, source permitting in 720P - option user preference
- Tags are hard coded into the file
- M4V is optimized
- M4V is moved to the destination folder, the "Automatically Add to iTunes" is my folder of choice.
- Original files are moved to the Trash Bin

TV Shows
- Virtually all single file source files are valid input files; I have excluded IMG, ISO, VIDEO_TS because
  they often contain more than 1 episode and that can't be automated.
- MKVs: DTS audio (if present) converted to AC3.
- MKVs: Determine the frames per second and pixel resolution to determine if it can be encoded in 720P for the AppleTV
- Chapters added every 3 minutes
- HandBrakeCLI transcodes for AppleTV, source permitting in 720P - option user preference
- Optionally a second file will be created for either: iPhone/iPod/Universal - and both versions show up as a single
  item in iTunes which I find very slick. The higher res one will be played on your AppleTV, the device specific
  one will sync to your portable device. (here is what two versions of the same show looks like in iTunes)
- You can default TV Shows to always try to encode in 720P if able, or you can leave that global  option off and via
  a 'tag' in the Category name you can tell specific shows to encode to 720P if able.
- If Season and Episode information are present then it will tag with this information
- If there is no Season and Episode information it will tag based on the Name of the download.
- Tags are hard coded into the file
- M4V is optimized
- M4V(s) is moved to the destination folder, the "Automatically Add to iTunes" is my folder of choice.
- Original files are moved to the Trash Bin

Movies
- (if content is uncategorized as either TV or Movies from SAB it will be processed as a Movie and referenced to
  as 'Uncategorized Video')
- 2 AVI's are joined to 1 AVI
- MKVs: DTS audio (if present) converted to AC3.
- MKVs: Determine the frames per second and pixel resolution to determine if it can be encoded in 720P for the AppleTV
- MKVs: Determine the presence of SubTitles (you can add SRT subtitles to M4V's that are user selectible on/off.) This would be done manually after the Process is completed.
- Chapters added every 5 minutes
- HandBrakeCLI transcodes for AppleTV, source permitting in 720P - option user preference
- Optionally a second file will be created for either: iPhone/iPod/Unversal - and both versions show up as a single
  item in iTunes which I find very slick. The higher res one will be played on your AppleTV, the device speciric
  one will sync to your portable device. (here is what two versions of the same show looks like in iTunes)
- Can default TV Shows to always try to encode in 720P if able, or you can leave that global  option off and via
  a 'tag' in the Category name you can tell specific shows to encode to 720P if able.
- Folder containing the original files is renamed with " - Test M4V before deleting" to it.
- If original folder is on the Desktop no further action, if the location is anywhere but the Desktop an alias to the
  folder is put onto the Desktop as a reminder that the files are out there still, and you have quick access to them.
- Movie(s) are opened in a GUI Tagger, I use iDentify but others can be used waiting for you to edit/commit them to file.
- Lastly you need to move the movie to it's ultimate destination. I created an automator action so that I can right click
  on any video file and select 'Send Movie to iTunes AutoAdd Folder', so after tagging I click click and it's in iTunes.

This list is going from memory, I'm sure there are other fine details it does, oh yeah a couple things come to mind:
- The script checks drive capacity and issues either a warning or aborts depending on where those two thresholds are set
- Measures lapse time of the entire script - just for reference.
Last edited by randyharris on May 7th, 2010, 10:01 am, edited 1 time in total.
randyharris
Full Member
Full Member
Posts: 146
Joined: January 21st, 2010, 5:36 pm

Re: AppleTV Movies and TV Show script for Mac

Post by randyharris »

haha, I think I've finally got the DTS -> AC audio sorted and with a better workflow.

Also going to add "Music Video" as a category.
imthenachoman
Jr. Member
Jr. Member
Posts: 59
Joined: March 2nd, 2009, 10:58 am
Contact:

Re: AppleTV Movies and TV Show script for Mac

Post by imthenachoman »

I'd be interested. Don't have a lot of free time but when I do...
randyharris
Full Member
Full Member
Posts: 146
Joined: January 21st, 2010, 5:36 pm

Re: AppleTV Movies and TV Show script for Mac

Post by randyharris »

imthenachoman wrote: I'd be interested. Don't have a lot of free time but when I do...
I decided to make the script into 2 separate scripts. The first one is all user variables, and the second is the actual script itself. This way if the script needs updating you can just overwrite the file with the update and not lose any of your user settings.

I'll try and make the install package of the binaries and stuff that the script uses, will shoot a note when it's all done.

Still looking for another person or two who might be interested in helping me test this out on other systems.

Thanks.
Last edited by randyharris on May 10th, 2010, 2:28 pm, edited 1 time in total.
randyharris
Full Member
Full Member
Posts: 146
Joined: January 21st, 2010, 5:36 pm

Re: AppleTV Movies and TV Show script for Mac

Post by randyharris »

Documentation is weak at the moment, but everything is bundled up into an installation and it's ready for testing on some other systems.

Let me know how it goes.

DOWNLOAD the AppleTV Script Installation Pak here.

Update: Documentation is no longer weak, I sat down and worked on putting a Tutorial together. It isn't complete yet, I'll add more in a day or three. But it has enough information now to hold your hand through the setup process and give you an idea of how to use it.

Image
Last edited by randyharris on May 18th, 2010, 1:35 am, edited 1 time in total.
gids
Newbie
Newbie
Posts: 1
Joined: April 7th, 2010, 5:40 am

Re: AppleTV Movies and TV Show script for Mac

Post by gids »

Hi, I'm interested in testing it too. Well I am in fact testing it! I tried a DTS mkv first which as you say is not working at the moment and does seem to hang SABnzb which has to be force quit. AVIs are converted great. One question, can you configure it to keep the originals and not delete them?

Many thanks for sharing this, its fantastic

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

Re: AppleTV Movies and TV Show script for Mac

Post by randyharris »

gids wrote: Hi, I'm interested in testing it too. Well I am in fact testing it! I tried a DTS mkv first which as you say is not working at the moment and does seem to hang SABnzb which has to be force quit. AVIs are converted great. One question, can you configure it to keep the originals and not delete them?

Many thanks for sharing this, its fantastic

Gideon
Actually everything should be working great. I'll PM you as I have an idea of what may be happening.
brazuca
Newbie
Newbie
Posts: 2
Joined: May 24th, 2010, 5:53 pm

Re: AppleTV Movies and TV Show script for Mac

Post by brazuca »

Hi. Great script. Just some issues. How would I cancel or stop the script? In SABnzbd+ I have an item that seems to be stuck in "Running Script: AppleTV" and I have no way to release it or restart it. Any tips?
Post Reply