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.
Re: (Score:1)
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.
Tidy first? (Score:2)
Re:Tidy first? (Score:1)
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
xsltprocutility, aOne more step... (Score:1)
Re:One more step... (Score:1)
rjbs