No, I still haven't found my overdue books, but at least now I know what they look like.
The AADL prints a helpful list of the books you have checked out, but doesn't give you pictures of them (not yet at least). So I'm working on the Greasemonkey script that will insert cover images into that page. This is not that, but a step along the way.
Again the PatREST system comes to the rescue - the books checked out list has the books listed by internal record numbers, so I have to do a transformation to generate the cover art. Here's the script to go from record number to cover image:
#!/bin/sh# recno to img - convert aadl record numbers to image links
curl --silent http://www.aadl.org/rest/record/$1 |
grep coverimglink |
sed -e 's/^.*xlink:href=.//' -e 's/\".*$//'
and here's a script that drives that one to generate a page full of HTML:
#!/bin/sh# renew coversfor n in $(cat ~/tmp/renews.html | grep "record=b" | \
sed -e 's/^.*record=b//' -e 's/\".*$//' )
do
sh ./recno-to-img.sh $n | \
sed -e 's/^/\<img src=\"/' -e 's/$/\">/'
done
where the "renews.html" file is a cached output of the previous script that renewed all my books.
Apologies for the quick and dirty sed scripts here; the important part of this is that the PatREST API has an attribute COVERIMGLINK with a link to the cover of the image of a record. I'm scraping the renews page and not yet capturing all of the information I really need to get good details about what is and isn't overdue. The AADL at least doesn't have a source of good cover art for DVDs, and so all of the Bob the Builder and Thomas the Tank Engine discs I'll have to catch by eye.
Here's the output (yes, these are what I have checked out; note that most of them are kid books and most of those are Boxcar Children)
Still thinking it would be possible (relatively simple? definitely interesting) to wrap the results in HTML pointing to Amazon affiliates pages.
Posted by: Bill Tozier | 20 August 2008 at 07:14 AM
the greasemonkey logic needs to be
for each element matching
do
take the record number
look up the image
insert the image tag into the page
done
I think the best way to start, though, is to work from my existing Amazon linky at
http://vielmetti.typepad.com/superpatron/2006/02/inserting_libra.html
which I suspect is broken now and repair it; there's not reason this should be two greasemonkeys for the same library, just one.
Posted by: Edward | 20 August 2008 at 03:40 PM