EyeTV and AppleTV Integration

When the second generation AppleTV was released, I was intrigued by it, but even the low $99 price tag didn't get me to bite as I couldn't quite justify it. Now that we're trying out Netflix (our viewing will increase this summer when most shows are in re-runs), the AppleTV became more interesting and then the enhanced AirPlay on the iPad pretty much sealed the deal for me getting one. I almost ordered one, but hesitated and then MacMall had an eBay special for $80 for one (+$6 California sales tax), so I bit.

So besides watching Netflix on it and streaming movies I create on my iPad with it, what else could I do with it? I already have a Mac Mini setup as a media center handling broadcast TV recordings on my EyeTV. Viewing shows with the EyeTV is fine, but I wanted to use the Remote app on the iPad as it looked cool (did I need a better reason?). I started hacking away at a system to export the videos and import them into iTunes on the fly. Since the export takes a long time, I needed to export the videos in the middle of the night after ETVComskip ran to strip out the commercials.

I came up with the following AppleScript to do the exports of the shows that were recorded in the last day.

set destFolder to "Macintosh HD:Users:mediacenter:Movies:EyeTV Encoded:"
set currentDate to (current date) - 1 * days
set currentSeconds to seconds of currentDate
tell application "EyeTV"
	set recordCount to count recordings
	if recordCount is greater than 0 then
		repeat with myCounter from 1 to count recordings
			set theRecording to item myCounter of recordings
			if busy of theRecording is false then
				set startDate to actual start of theRecording
				if (startDate > currentDate) then
					set thisTitle1 to title of theRecording
					set thisTitle2 to unique ID of theRecording
					set AppleScript's text item delimiters to ":"
					set theTextItems to text items of thisTitle1
					set AppleScript's text item delimiters to "-"
					set thisTitle1 to theTextItems as string
					set AppleScript's text item delimiters to {""}
					set thisTitle to thisTitle1 & " " & thisTitle2
					export from theRecording to file (destFolder & thisTitle & ".m4v") as AppleTV replacing no
				end if
			end if
		end repeat
	end if
end tell

Next I setup a cronjob like this:

15 0 * * *  /Library/Application\ Support/ETVComskip/\
MarkCommercials.app/Contents/MacOS/MarkCommercials\
 all > /dev/null 2>&1
15 2 * * * open /Users/mediacenter/Desktop/Export\
ToAppleTV.app
15 20 * * * rm -rf ~/Movies/EyeTV\ Encoded/*

The first line runs the commercial skipping, the second runs the AppleScript that I've saved as an app. The third line removes all the exported videos as they're no longer needed.

I've been using this for about a week now and it's working quite well. I can control the shows from my iPad, but my wife thinks I'm just doing it because I'm a geek (and I say, so?).

The only issues with this is that I can't delete the shows with my AppleTV and as of now, I'm keeping the backup copies on the EyeTV. So I have to manually delete the watched shows from iTunes as well as EyeTV. Once I get more confident, I'll modify the AppleScript to delete the shows from the EyeTV after exporting and then I can write another script that removes the shows from iTunes after they have been watched; this is a little risky as I'm not sure if I can tell if it has been completely watched or partly watched. I wouldn't want to prematurely delete the shows.

While this isn't for the novice, I think it's pretty cool and if I can centralize all my media watching to the AppleTV, I'll be pretty happy. The Remote app on the iPad is very slick and beats any standard remote.