Post on 06-Dec-2014
description
TV TubesTalkin’ ‘bout my automation…
(Complete with crappy PowerPoint theme)(Complete with crappy PowerPoint theme)Neil CrosbyNeil Crosby
The Problem
You:
• Like watching TV Shows.
• Can’t watch when they’re on TV normally.
• Don’t have a VCR.
The Solution
• Timeshift by downloading episodes.
• Put episodes into iTunes.
• Sync to iPod, iPhone, TV etc.
• Delete them once they’ve been watched.
• But, do this completely automatically.
What You Need
• A Mac
• TVShows.app
• BitTorrent Client
• VisualHub
• iTunes
• Two FolderActions
• One Standalone AppleScript
• A Small Aubergine
TVShows.app
• Lets you download new episodes of shows whenever they appear, automatically.
• Whenever new episodes appear, they get downloaded by your favourite BitTorrent client.
• It’s a kind of magic
BitTorrent
• Any client will do, as long as fully downloaded items are able to be moved to a “downloaded” folder automatically.
• Azureus does this quite happily.
The First FolderAction
• Invoked when files appear in “downloaded” folder.
• Starts VisualHub using a config file.
• Pipes files into VisualHub.
• Starts VisualHub re-encoding the files.
VisualHub
• Costs $23.32
• Uses ffmpeg for encoding.
• So, it could (and should) be refactored out as an exercise for the reader
ffmpeg commandlineffmpeg -y -threads 4 -i some.show.03x05.some.episode.name.avi -s 640x480 -r 29.98 -vcodec h264 -g 300 -aspect 640:480 -qmin 27 -b 900 -level 30 -loop 1 -sc_threshold 40 -partp4x4 1 -rc_eq 'blurCplx^(1-qComp)' -refs 2 -qmax 51 -maxrate 1400 -async 50 -acodec aac -ar 44100 -ac 2 -ab 128 some.show.03x05.some.episode.name.mp4
VisualHub
• Costs $23.32
• Uses ffmpeg for encoding.
• So, it could (and should) be refactored out as an exercise for the reader
• Set up to save re-encoded to episodes to “encoded” folder.
The Second FolderAction
• Invoked when files appear in “encoded” folder.
• Adds files to iTunes
• Works out Show Name, Season Number and Episode Number (Perl)
The Perl
if (/^(.*)[\s\.\-]+s?([0-9][0-9]?)[ex]?([0-9][0-9])/i) {
$show=$1; $season=$2; $episode=$3; $show=~s/\s*-\s*$//; // Remove dash from end of show name $show=~s/\./ /g; // Convert dots to spaces $show=~s/((^\w)|(\s\w))/\U$1/g; // Capitalise each word print "$show\n$season\n$episode\n";
}
Show Season Episode
The Second FolderAction
• Invoked when files appear in “encoded” folder.
• Adds files to iTunes
• Works out Show Name, Season Number and Episode Number (Perl)
• Sets info in iTunes
iTunes
• Does any syncing that you’ve told it to do with your TV Shows!
• You get to watch the shows you want without having to be around when they’re on TV.
• Awesome.
The Overall Process
But wait, there’s more!
Current Gotchas
• Deletion process still to be written.
• VisualHub can’t cope with videos inside folders.
• VisualHub doesn’t like things to be added to its “to encode” list - shows get encoded twice.
Write-up / Instructions
• Full instructions for setting up your own “TV Tubes” process will be available at workingwith.me.uk very soon.