Whether browsing for technical books on Amazon, or during the long process of writing a dissertation, I often come across references to volumes online that I’d like to see if I could get from my university’s library. Thanks to the explosion of computerized databases, the ISBN of these books is oftentimes exposed right alongside the title and author. And given the similar titles of many books, having that ISBN number is a great way to go directly to the volume I want, rather than sorting through a list of similar-sounding titles returned by a keyword search. (Ever try to find one specific book on iPhone programming?):
Because the ISBN number works so well as a unique lookup, I thought that I could save some time by automating the lookup for an arbitrary ISBN against WorldCat, the union catalog of many of the world’s research libraries. In Mac OS X Snow Leopard, there’s a super-easy way to do this, by using some 10.6-specific ways to extend the Services menu.
(“Services” is a terrific, if underutilized, underpinning of OS X which actually dates from NextStep:
The idea on the NeXT was that applications could deliver certain services across the system — say, a spelling checker, or an equation solver — by populating a menu and acting on contextual selections. Services have undergone a lot of changes since 1988, and in the latest version of OSX, 10.6, they’ve experienced a renaissance due to the inclusion of Automator-generated AppleScript workflows.)
The robot that will make this all easy is called Automator, who lives in the Applications folder:
Automator uses a combination of tools drawn from the entire OS, from the circa-System 7.1 scripting language called AppleScript, to system-level affordances such as the Clipboard, to whole standalone applications such as Safari. Automator lets you put these all together at an extremely high level, taking care of the ‘glue’ that binds each part together. If programming in Assembly is the equivalent of atomic engineering, and Objective-C is working at the level of cells, then Automator lets you go all the way past Lego and into the comforting, easy-to-grab world of Duplo.
What we want Automator to do for us is to act upon any ISBN we highlight with the text cursor, and pass that number off to WorldCat’s ISBN resolver. (Which, conveniently enough, is worldcat.org/isbn/…) Here’s what the entire Automator Workflow will look like when it’s done:
To get started, we’ll fire up Automator and choose Service from its initial list of different kinds of templates:
Before we add anything to the resulting blank box, we need to tell Automator the general terms of the Service we’re building. Luckily, the defaults are spot-on: our ISBN lookup script will accept text in any app (allowing you to use it in Word as well as a web browser or email client) and won’t replace what you’ve selected. (A more advanced Service might replace a highlighted ISBN with a full formatted citation — but that’s a good bit more complicated).
Now we can begin dragging elements into the large blank area on the right, as if they were big plastic blocks. We’ll start with an some code to prefix the WorldCat ISBN resolver’s URL onto the text that Automator receives from the user, so go to the Utilities folder and select Run AppleScript:
This gives us a container that can handle any AppleScript code we type in. What we need AppleScript to do for us is refreshingly simple, and the language’s syntax is extremely human-readable:
on run {input}
set QueryURL to "http://www.worldcat.org/isbn/" & input
end run
All we’re doing here is constructing a variable to pass off to a web browser that consists of two parts: the WorldCat ISBN resolver, and whatever the Service was given when the user selected text and invoked it.
Next step: pass that full QueryURL off to Safari (or whatever the default browser is on the system.) This step is embarrassingly easy: drag the Display Webpages block from the Internet folder in the Library:
In the words of Jeff Goldblum: there’s no step 3. Save your file as “WorldCatISBN” or similar:
Automator will take care of installing the Service for you (behind the scenes, it’s putting it into your username/Library/Services folder.
Now it’s time to test it out. Navigate to a page on Amazon for a random book. Scroll down to the “Product Details” section, and drag your cursor over either the ISBN-10 or ISBN-13. (WorldCat will handle either form.) Right-click (or hold down Control and click) and select “WorldCat ISBN”.
(What’s especially nice about Services in 10.6 Snow Leopard is that they are contextual — the WorldCatISBN menu won’t show up if you’re selecting pixels in Photoshop, or an icon in the Finder. Of course, there’s nothing to prevent you from selecting an invalid ISBN and sending it to WorldCat, or any gibberish text, but you won’t cause any problems doing that either.)
A new window will open with the results found from WorldCat’s library listings, geo-located to show the library nearest you with the book in their collection.
The end result? That programming book you thought you might have to pay $50 for may well be available for free on campus. And you can check if it is with one right-click.
More and more libraries are using a facet of WorldCat called WorldCat Local to replace their own internal catalogs. This is true of my institution, the University of Washington — we use http://uwashington.worldcat.org/. These URL’s have a few advantages over using the normal site, including telling WorldCat that you presently have (or could log in to if necessary) databases and other subscription resources requiring authentication, and also setting the default scope of queries to buildings on campus and local consortia. So it may make sense to customize the WorldCat URL in the AppleScript above for your local institution. Everything after the worldcat.org behaves as normal, so I would use “uwashington.worldcat.org/isbn” in my code and get the same results from my ISBN queries.