NetNewsFlix

February 27th, 2006

First 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:

tell application "TextEdit"
	make new document
end tell

tell application "NetNewsWire"
	set myHeadlines to (headlines of selectedSubscription) as list
	repeat with myItem in myHeadlines
		set thisTitle to (title of myItem)
		tell application "TextEdit"
			set text of document 1 to (text of document 1) & thisTitle & return
		end tell
	end repeat
end tell

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.

6 Responses to “NetNewsFlix”

  1. Brian Webster Says:

    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…)

  2. Daniel Jalkut Says:

    Nice work, Brian. I hope you’re still reading when I really want some help optimizing a script :)

  3. Andy Kim Says:

    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.

  4. sjk Says:

    Has your friend tried Netflix Freak? I haven’t (no subscription, yet) so I can’t say whether or not it would be useful.

  5. Nick Valvo Says:

    RE: Netflix Freak.

    It would be useful.

  6. Alan Fraser Says:

    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.

Comments are Closed.

Follow the Conversation

Stay up-to-date by subscribing to the Comments RSS Feed for this entry.