Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

rjbs (4671)

  (email not shown publicly)
AOL IM: RicardoJBSignes (Add Buddy, Send Message)
Yahoo! ID: RicardoSignes (Add User, Send Message)

I'm a Perl coder living in Bethlehem, PA and working Philadelphia. I'm a philosopher and theologan by training, but I was shocked to learn upon my graduation that these skills don't have many associated careers. Now I write code.

Journal of rjbs (4671)

Thursday September 15, 2005
11:21 PM

vim, my new netflix client

[ #26740 ]

Tonight, I was struck by an urge to JFDI. For a long time, I've wanted a better way to organize my Netflix queue. There used to be Netflix Freak, which was decent, but cost money, and I think it went away. I think it had other problems, I just can't remember anymore.

Anyway, what I really wanted was a way to save my queue to a text file, edit the file, and then upload it again. It should have been simple, but the form used on Netflix is pretty ugly, and I was having a hell of a time figuring out how to deal with it using TokeParser, which is built in to Mech. I knew it wasn't the right sort of parser, but I didn't know what was better. Finally, I asked #perl where I could get something to say "for each div of class foo, do X." DrForr pointed me toward HTML::Tree, which made this task incredibly simple.

Now I can save my queue, rearrange the file, and update my queue. No more trying to remember what number I put in front of what, no more trying to keep lots of changes in my head at once. I put the lines in the order I want and hit "go!" It doesn't delete or add movies yet, but I may (or may not) add that. Tomorrow I'll probably collect these two little hacks into one program with some command line switches.

In the meantime, I would like everyone to know that Sean Burke and Andy Lester deserve candy and hugs for giving away such great toolkits.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • My hammer of choice is forcing the input to XHTML using HTMLTidy, then attacking it with XPath. XPath rocks extremely hard. HTML::Tidy (there’s Andy Lester again) and XML::LibXML are excellent tools for this approach.

    • Do you really need to tidy first? I just make sure recover mode is turned on and use LibXML's parse_html method - works for me. Maybe you have to deal with uglier HTML than I do.
      • I didn’t think of that because I actually use XSLT most of the time (nowadays a Perl wrapper script around XML::LibXSLT and the aforementioned modules), and there’s something really strange going on with namespaces in a DOM built using libxml’s HTML parser, which causes strange misbehaviour in XSL transforms that I never figured out (just had hours of debugging fun with). When I started out, I didn’t even have the option because I was in fact using libxslt’s xsltproc utility, a

  • Of course, now what you need to do is make one script that, on startup, downloads your queue to a tmp file, spawn the editor, checks for changes on exit, and if changed uploads it back to netflix, all in one step.
    • Actually, what I did was create :getQueue and :pushQueue. I think that I'm more comfortable being explicit: I don't want to hit the wrong few keys and accidentally delete all the movies from my queue!