« New library catalog at North Carolina State University | Main | Google Talk IM bot to search the AADL catalog »

12 January 2006

Build notes for Amazon AADL Linky

I found some code - Carrick Mundell's "Amazon SPL Linky" - that adds links from the amazon.com catalog into the Seattle Public Library catalog. After an evening of hacking on it, I came up with the "Amazon AADL Linky", which does the same thing for the Ann Arbor District Library catalog.

(Update: Jon Udell pointed out quite correctly that Carrick's version is derived from Jon's original Library Lookup Greasemonkey script, which in turn is derived from Jon's Library Lookup bookmarklet. Thanks Jon!)

I did this after a lunch (a very mild Thai shrimp curry) with Mr. Findability, Peter Morville, who said that he doesn't use the library as much as he might because it's so easy to buy books from Amazon. & so you figure, what would it take to make it that much easier to use the library? Put it in the middle of Amazon.

Here are some build notes of what I did, which should help the next person do this for whatever system they want to do it for, and should help me remember what I did if it needs to happen again.

First, don't start from my copy of the code, start from the original script. Carrick is maintaining it and doing the necessary changes to keep it working with Firefox and Greasemonkey. You'll want to use some kind of source code control system to keep track of you changes, so that when a new release comes out you can patch in what you did and not have to figure it all out again.

The script has a number of variables at the top. I won't go through all of them, but some critical ones to start:

libraryUrlPattern (and in my copy libraryUrlPatternTrailer) are strings that represent how to do a search for a known ISBN in your catalog. Every catalog has a slightly different syntax for doing ISBN lookups, and the easiest way to find it is to go into your "advanced search" and do a lookup, copy out the URL you find and decode the results. Try to trim away any extraneous stuff like a session id.

notFound is a pattern that matches the screen that gets returned when your catalog has no holdings for that item. The catalog might try to be extra-helpful and tell you about all kinds of other things it has, but you want to zero in on the bit of bad news.

libraryAvailability, libraryOnOrder, libraryInProcess, libraryHolds, and libraryDue are all patterns that match the state of the system regarding hold status. Find items in each of those states - a book that's in, a book on order, a book in processing, a book with lots of holds, and a book that's due back - and determine the unique string that signals that state. You might need to be clever about it, because e.g. the AADL has "Zoom Lends" which means you can pay to get "S is for Silence" right away if you want to bypass the hold queue. I don't count that as "Available".

If you're not familiar with regular expressions, this is not the place to teach them. Know that \d matches a digit, \- matches a -, and a phrase in (parenthesis) can be returned as a match string.

On to the logic of the program. The program tests for a number of conditions in order to figure out what the state of the world is with that title. I had to reorganize the if/elseif clauses a little bit to get the "S is for Silence" + Zoom Lends case right, so that it looked for hold status before it looked for available copies. I'm not entirely happy with how my code picks out the due date, because that's not terribly meaningful with lots of copies out and lots on hold, and the catalog doesn't predictably return the "first" due date first. You might be able to use it as is.

You'll need to adjust the very top stanza, the @namespace part, to reflect the server you're putting the code on. Save it somewhere it can be downloaded. It requires Firefox 1.5 and a current Greasemonkey, which are easy enough to install.

To use it, fire up amazon.com and start browsing. When you hit a book title, you should see the status of it in your catalog appropriately highlighted under the title. Click through to confirm, and if it's not quite right iterate until it is right. The two things I needed to do iteratively were to adjust the regular expressions and to resort the test order.

Hope this helps.

Technorati Tags: , , , , , , ,

Comments

Hi Ed! You rule, but you already knew that. I've stolen your script and modified it to work with our (SJCPL) catalog. Do you mind if I put it out there? I've left the superpatron url in. :)

and now i show my excitment at new shiny things. I re-read through your post. I know you say not to start with your code, but it's so good! and I'm pretty new at this greasemonkey stuff. anyhoo, thanks again for posting this!

Maire, absolutely, put it out there to use. Jon Udell gets the original idea and code credit.

You might want to register your copy of it at http://userscripts.org (free) which puts it somewhere people can find it who would be looking.

Ed

Thanks Ed! I'm making a userscripts account now.

Jon is mostly correct. I derived my code from a script I found at snarfed.com, which I mention and link to in my original post about the script. Jon's script was the inspiration and basis for the script at snarfed.com.

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment

What they're saying about Superpatron

  • So you've got Ed exploring the possibility space, and John working to enlarge that space, and together they've created a virtuous cycle of innovation. Now this is obviously an extreme example. You are not going to find a superpatron of Ed's caliber and a superlibrarian of John's caliber in every town. But I think the dynamic at work there can apply more broadly. And if it does, it will matter that these patrons and librarians are situated in a local context. (Jon Udell, Remixing the Library, GRL2020)
  • Der Supernutzer beschreibt 10 Möglichkeiten, der Bibliothek zu helfen....Den wichtigsten Punkt hat er vergessen, ihn aber selbst erfüllt. Sozusagen als Präambel könnte man also anführen:

    “Übe konstruktive Kritik an der Bibliothek. Ohne Resonanz können die Leute da drin nicht wissen, was Du willst.” Infobib.de

  • How come only some books in the Google Book Search have “find in a library” links next to them? Diglet asks, and gets an answer, sort of a lame one if you ask me. update: Kevin mentioned in the comments that it would be great to see this for all books in Google Books. I went to bed thinking “Oh yeah, I should look into that….” and while I was sleeping, Superpatron, aka Ed Vielmetti solved the crime, er problem, and created a Greasemonkey script (a plug-in that you can run with Firefox) that does this for Ann Arbor and can be modified for any library. (Jessamyn West)
  • Curse you Superpatron! t's way past my bedtime, but the Ann Arbor Superpatron has been planting ideas in my head again… (Dave Pattern)
  • Superpatron is a blog run by a patron. The author posts entries about events and articles relevant to the library community, but does it with a patron point of view. (North Texas Regional Library System)
  • The blogosphere's resident "awesomest patron ever," Edward Vielmetti, appears in an article in School Library Journal about how he wrote a script tweaking (ahem, improving) Google Book Search. Vielmetti's blog, Superpatron, is one I read daily and highly recommend to anyone in libraries looking to get a very smart user's perspective. (Librarian In Black)
  • When I wrote him back, I called him the “AADL Super Patron,” which is very coincidental, since he has been planning to create a blog with almost the same name. Today, Superpatron is live and I’m sure it will quickly be filled with Ed’s terrific ideas about making libraries more responsive to patrons’ needs. So hurry up and subscribe already, ok? (Meredith Farkas)
  • The Superpatron (faster than a speeding reference librarian…) posts a presentation on the use of del.icio.us for research. Steven Cohen, Library Stuff
  • I've talked about Edward Vielmetti here before, but I never had the right name for him. Now I do. He's Superpatron! (Jenny Levine)
  • Last fall, in Ann Arbor, Michigan, I gave a talk entitled Superpatrons and Superlibrarians. Joining me for this week’s podcast are the two guys who inspired that talk. The superpatron is Ed Vielmetti, an old Internet hand who likes to mash up the services proviced by the Ann Arbor District Library. That’s possible because superlibrarian John Blyberg, who works at the AADL, has reconfigured his library’s online catalog system, adding RSS feeds and a full-blown API he calls PatREST. (Jon Udell)
  • Little did I know that when I pointed to Ed Vielmetti’s blog, I was not only coining a phrase, but providing the name for Ed’s brilliant new blog. Ed is that (unfortunately still) rare creature that not only groks the net in fullness, but also has use for his public library. (Eli Neiburger)
  • Die Ann Arbor District Library hat einen Nutzer, der sie liebt. Und nicht nur das, er schreibt darüber. Oliver Obst

mybloglog


Blog powered by TypePad