HOWTO: Add comics from to Delicious Library

With Delicious Library 2 releasing sometime this holiday season, I may actually start using it for my library catalog. What has stopped me in the past was its lack of expandability - with no AppleScript support, I couldn't add in new data scraping functionality myself (though, if I were truly bothered, I'd've done custom imports). Thankfully, Delicious Library 2 fully supports AppleScript and I'm hoping I'll be able to hook into new item creation, as I'd love to store my comic and magazine collections (and maybe even weirder things like collectible card games, but that'd be ReAaALly stretchin' it).

With the prospect of doing comic importing "the right way" (meaning "type in a title and have it Work" vs. "prepare an external file for importing"), I decided to see if I could get the current release, version 1.6.6, doing "the right thing" the wrong way - getting it to Work via an amalgamation of hacks. I succeeded, but I'm not going to spend a lot of time walking through this: I'll assume you're willing to wait until version 2 is out and this all gets rewritten properly (hopefully... if it's not possible, this hack will be fleshed out in more quality-assured detail).

To get this going, you're going to need:

  • The ability to modify the normally hidden /etc/hosts file.
  • The built-in Apache web server enabled (via System Preferences > Sharing).
  • Leopard. There's a 99% chance it'll work on Tiger too, but I'm not checking.
  • The comic book ID you'd like to import from the Grand Comic Database.

Be forewarned: this is a hack in the earliest stages! I'm sure there are plenty of things that can go wrong (like DL loading up the wrong URL for grey arrow clicks, bad scrapes from GCD due to unexpected formatting, the ability to add in other "matching" items from other Amazon sites, release dates that expect the exact day, etc.). I'm hoping all this stuff can be cleaned up a bit more in DL2, but DL is pretty tightly tied to Amazon's Web Services, so pulling data from other sources may always be kludgey like this.

Step 1: Intercept Delicious Library Lookups

The first thing we're going to do is tell Delicious Library to use Amazon Japan for data lookups (in Library > Preferences > Load Details From). I chose the Japan site because I don't think I'll ever legitimately visit there (much less use its Web Services), and the first step of the hack involves redirecting all requests sent to that site from your computer back to your computer. This will trick Delicious Library into thinking it's communicating with Amazon Japan, but instead, it'll be communicating with a script we'll install down in step 2.

To redirect all our Amazon Japan traffic, you'll need to edit /etc/hosts with an authenticating text editor (like BBEdit, or sudo vi, or whatever). Add the following to the bottom of the file, making sure that the whitespace between the two columns is created with a tab:

Once you save the file, you should be able to access within your web browser and see that it is most definitely not the Amazon site - it should be whatever page you would normally see if you loaded (by default, Apache's "Seeing this instead of the website you expected?").

Step 2: Responding to Delicious Library Lookups

Next, we have to install our script to respond to these lookups. If you attempted to add an item to your Library now, you'll notice that it should still work - it appears DL will default to Amazon US if there are no relevant results on your selected site (Japan, now being redirected back to your computer). The first step to responding correctly is creating a new directory at /Library/WebServer/Documents/onca/. Within this directory, we're going to create a text file called xml which will contain our custom script for loading comic books. This path mimicks the Amazon Web Services lookup that DL requests.

The new file will need to be set to 755 (chmod 755 /Library/WebServer/Documents/onca/xml) so that it is executable. We'll also tell Apache to let this script be executable from the web; to do so, add the following to /etc/apache2/users/username.conf and then restart the web server with sudo apachectl restart:

ScriptAlias /onca/ /Library/WebServer/Documents/onca/
Neat trick? Want me to keep going and get it working in DL2? Send me a buck or two! will be our comic book data source. We'll return data only if we actually find a comic book on that site... otherwise, we'll return nothing, which will force Delicious Library to use Amazon US for your regular scanning needs. Replace your xml file with this final version (renamed to xml), then run through the steps below:

  • Find your comic on the Grand Comic Database.
  • Get the comic ID from the URL (such as 13825 for Batman #111).
  • Add a new item to DL, and add the comic ID to the "Find by #" field.
  • Preface the comic ID with "B0" and then a series of "x"s until it turns into "Find by ASIN".
  • For Batman #111 (13825), you'd use B0xxx13825.
  • Click the "Find by ASIN" button.

If everything works, you should see something like:

Delicious Library importing from

There's plenty more to be done; I just hope I can do it better in DL2.


dl_comics-1.0.jpg128 KB