MyNetflix2
August 9th, 2005 by herichon
EDIT: As the notes below make clear, I’m not actively developing or supporting this plugin any longer, though I’ll leave it up in case anyone would like it for whatever obscure reason they may have. If you’re looking for a Wordpress Netflix plugin, have a look at the one that Albert Banks has on offer. The comments there seem to indicate that he’s actively working on it, so you’ll probably find better support there. I was a bit irritated originally since I thought he might have borrowed a couple of my ideas without crediting me, but after all great minds do think alike, or so I am told. Besides his code is entirely different, and he’s actually put together the Control Panel interface that I never got around to implementing in my plugin, so his plugin is probably more stable and easier to use. If I ever start using NetFlix again, I’ll bring this back up to date though. Thanks for stopping by in the meantime.
Okay so let’s talk about the plugin I’m using to show NetFlix activity on my sidebar.
It’s called MyNetflix2. It’s based on the MyNetflix plugin by Jimmy Oliver. His latest version was 1.5, for WP1.5, but (since it’s GPL and all) I took the liberty of adding some new features and rewriting most of the code. You can see the current version in operation in the lower right sidebar of this page.
Features include:
- display of text titles, box images or both for your currently out, recently returned, or in-queue movies
- extra text from Netflix (“Returned”, “Shipped”, and leading numbers in queue) is removed
- all titles and images are hotlinked to Netflix movie pages
- supports removal of “trkid” tracking number from Netflix links
- configure your Netflix plan size, image height and width, and number of images to display per row (to fit your sidebar)
Next steps include:
- improved RSS feed validation
- support for the movie description and ratings fields (currently ignored)
- (ultimately) some way of caching box cover images locally, otherwise NetFlix is going to start raising our rental fees to cover all the bandwidth we’re sucking down in images
Ultimately where I’d like to go with this is something like a WordPress version of Oscar’s Netflix Suite. It may take a while to get there though. I’m stumbling my way through PHP and RSS stuff so forgive me if the code is a little ugly. Suggestions are of course welcome.
Instructions on how to use the plugin are included in the comments at the top of the file. It’s pretty straightfoward – drop the plugin file into your Plugins directory, activate it from the Plugins panel, and then add code to your sidebar to call the mynetflix() function. Just remember to wrap your calls in < ?php...?> tags. For example, here is the precise code inserted in the sidebar of this page to generate what you see on the right:
<h2>My Netflix activity</h2>
<p>Currently watching:</p>
< ?php mynetflix("out","image"); ?>
<p>Recently returned:</p>
< ?php mynetflix("returned","image"); ?>
<p>On deck:</p>
< ?php mynetflix("queue","text",10); ?>
Download the current version of MyNetflix2 here:
Version history:
- 2.0b – 12 August 2005
- added a parameter to switch between display text titles, images, or both
- added basic RSS feed validation (ie, if there’s a problem with the array, it reports it rather than throwing errors)
- added code to strip leading “Returned- ”, “Shipped- ”, and queue location numbers from RSS movie titles
- 1.81 – 10 August 2005
- fixed a typo bug in the determination of the $limit variable when no explicit limit is set
- clarified some of the documentation-type comments in the file
- 1.8 – 10 August 2005
- complete rewrite with cleaner code
- added “offset” system to distinguish between currently out and recently returned movies in “recent” feed
- 1.6 – 24 July 2005
- added simultaneous support for “recent” and “queue” feeds
- added images
- stripped tracking numbers from URLs
- 1.5 – Jimmy Oliver’s base code
UPDATE – 9 August 2005
As you can see on the sidebar, the ‘queue’ part of the plugin is currently not working. Not sure why – it’s puzzling, since nothing apparently changed on this end, and the RSS feed appears unchanged as well. It’s also puzzling that only the queue portion is broken and not the ‘recent activity’ part. Anyway I’ll be messing with this over the next day or two and will update again once I’ve got some clue as to what’s happening.
Okay this is bizarre. I reloaded just now as I was editing elsewhere and – lo and behold – the queue appeared just fine. Reloaded again – broken.
I am starting to wonder if there’s something funky going on at my webhost. I can’t imagine what could be happening on the back end that would cause a relatively simple script to behave so badly but I can’t think of any other explanation.
Bah. Nothing for it but a rewrite from the ground up, I guess, just to rule it out. Not much else I can do at this point.
In case anyone should come across this while I’m working on it – I’ve pretty much rewritten the plugin from the ground up and currently I’m working out some bugs. You’ll continue to see errors on the sidebar until I get the new version configured right, but the existing version (1.6) should be pretty stable. Will update again once the new version (1.8 beta) is a little less twitchy.
Note to self – do not comment out global variables.
Okay – version 1.8 is complete, we’ll still call it beta but I think it’s pretty solid. Tarballed and stashed on the server, link above is updated.
The good news – the plugin is pretty much completely rewritten from the ground up, is now less than half the size, fully documented and much prettier. Also some minor new functionality (distinguishing movies out from movies returned) is added.
The bad news – even with all these changes, the original problem (queue not appearing) persisted. I was ready to beat my head against the wall until – on a whim – I replaced my rss-functions.php file with an updated version, the latest Magpie package. This one failed too but it dropped a useful warning – “Failed to parse RSS file. (not well-formed (invalid token)”. Nah, it couldn’t be the feed itself, could it? I fed my queue RSS into the validator and – sure enough – it choked.
“Sorry – This feed does not validate. * Your feed appears to be encoded as “UTF-8”, but your server is reporting “US-ASCII”
* line 1444, column 236: ‘utf8’ codec can’t decode byte 0×96 in position 169654: unexpected code byte (maybe a high-bit character?) ... urns from a space mission, all is well ? well, almost. Depp?s sudden per …
The culprit turned out to be The Astronaut’s Wife (1999), starring Johnny Depp and Charlize Theron. Apparently some of the characters in the Netflix description are screwing with the RSS feed. I took the movie off my queue and – voila – everything worked fine. I guess I didn’t really need to see that movie anyway.
Today we moved officially to MyNetflix2 with the 2.0 beta version. As noted above, this is the “Netflix-bandwidth-friendly” version – not only does it support both text titles and box cover images, but the default is now set to text instead of images.
I think this will probably be the last of the work I do on this for the moment (besides squishing any bugs that pop up). It does everything I need it to do, and it should be flexible enough for most anyone else that wants to play with it. I’d still like to explore caching images locally, but now that the text options are in place, I’m not as concerned about bandwidth usage. I’ll revisit this if anyone has requests or suggestions.
No one is paying much attention, but for the record, I’ve tweaked my sidebars today so that the MyNetflix2 plugin only appears in the sidebar for this page. (I’m adding some other items to the sidebar on the main page and it was getting a little cluttered.) Also I’ve updated the text above a little to demonstrate usage.
You know, talking to yourself is usually a bad sign…
Greetings Herichon!
I just joined Netflix yesterday, so I stopped by looking for a WP plugin to show my queue. Looks like exactly what I need!
[...] Of course, this gives me another feature to hack/play with here on the blog: displaying our Netflix queue and/or recent activity. I was initially thinking of using Jimbo’s mynetflix 1.5 plugin, but he’s been pretty busy lately. It looks like development work has been taken over by Herichon, who recently released mynetflix2. I’ll be fiddling with this plugin and squeezing it into my page somewhere. Of course, this is going to be another customization that needs to be maintained for each theme, sigh. [...]
[...] A few days ago my family signed up for Netflix. I had some spare time to play over the Thanksgiving weekend, so I installed and set up MyNetflix2 on my blog. Here’s how I did it. These instructions cover installation of MyNetflix2.0 beta on my web server (running FreeBSD 4.8). YMMV [...]
Oops – forgot to move the plugin files over, when I switched hosts. Sorry about that folks. Links should work better now.