NetNewsFlix
February 27th, 2006First let me say, I love Netflix. When I’m not programming, sleeping, or running, I’m usually watching Netflix. What a life!
A friend who also loves Netflix came to me with a puzzling problem. He’s coming out of a long term relationship, and among the other shared possessions to be carefully divided was the couple’s Netflix queue. The account isn’t in his name, but he wants to keep his share of the hard-accumulated queue. He gazed at the long list of 308 titles and searched the web page carefully for an “Export” button. Nowhere to be found. It seems that Netflix, despite it’s totally awesome domination over all competitors, is a little teeny bit scared of what might happen if you could easily export your queue to a text file and then, say, re-import it to Blockbuster.
NetNewsWire, RSS, and AppleScript to the rescue! Since Netflix is hip enough to provide several RSS feeds for its savvy customers, I just grabbed my friend’s Netflix queue RSS feed, and subscribed with NetNewsWire. Then, after selecting the subscription, I typed the following into Script Editor:
It doesn’t matter if it’s efficient, it just has to work once. And voila! Switch to TextEdit and observe a 308 line file with the names of each film in order. If the numbered lines are a problem, a little bit of extra script could take care of that in a jiffy.
It’s exactly these kind of unforeseen circumstances where easy, predictable scripting interfaces save the day.
Update: It wouldn’t have been the worst thing in the world to simply save the HTML page listing the entire queue, but this solution makes it much easier to manage the data and process it however the owner sees fit.
February 27th, 2006 at 12:55 pm
Yeah, it doesn’t matter to most humans if it’s efficient, but I can’t resist a good Applescript optimization challenge. :-) Here’s what I got it down to:
set AppleScript's text item delimiters to return
tell application "NetNewsWire" to set theText to (title of every headline of selectedSubscription) as string
tell application "TextEdit" to set text of (make new document) to theText
Three lines, baby! Yeah!
(OK, back to work…)
February 27th, 2006 at 12:58 pm
Nice work, Brian. I hope you’re still reading when I really want some help optimizing a script :)
February 27th, 2006 at 8:57 pm
Oh you guys are such programming jocks. I would have probably busted out python to parse the html and be really proud of myself too.
The sad thing is, if a user is a bit smart, they can probably achieve the same results faster by copying and pasting the html into excel… After a bit of cleanup, that list can go anywhere from there.
BTW, I want to thank you Daniel for all of your posts in the cocoa-dev mailing list. They have been really helpful.
March 5th, 2006 at 9:25 pm
Has your friend tried Netflix Freak? I haven’t (no subscription, yet) so I can’t say whether or not it would be useful.
March 16th, 2006 at 12:27 am
RE: Netflix Freak.
It would be useful.
March 16th, 2006 at 2:33 am
That’s an elegant solution. I’m surprised to see Excel mentioned in the same context but there’s no accounting for taste. In any case, it’s a nice job and could well extend to other useful purposes. Or perhaps pick up the feed in PHP to present on your own site. I’ve found PHP useful in that way as people can preview my feeds without needing to subscribe to them. Anyway, nice job. Thanks.