In the course of looking at the patch for Koha bug 9580 today, I ended playing around with Coce.
Coce is a piece of software written by Frédéric Demians and licensed under the GPL that implements a cache for URLs of book cover images. It arose during a discussion of cover images on the Koha development mailing list.
The idea of Coce is rather than have the ILS either directly link to cover images by plugging the normalized ISBN into a URL pattern (as is done for Amazon, Baker & Taylor and Syndetics) or by calling a web service to get the image’s URL (as is done for Google and Open Library), Coce queries the cover image providers and returns the image URLs. Furthermore, Coce caches the URLs, meaning once it determines that the Open Library cover image for ISBN 9780563533191 can be found at http://covers.openlibrary.org/b/id/2520432-L.jpg, it need not ask again, at least for a while.
Having a cache like this provides some advantages:
- Caching the result of web service calls reduces the load on the providers. That’s nice for the likes of the Open Library, and while even the most ambitious ILS is not likely to discomfit Amazon or Google, it doesn’t hurt to reduce the risk of getting rate-limited during summer reading.
- Since Coce queries each provider for valid image URLs, users are less likely to see broken cover images in the catalog.
- Since Coce can query multiple providers (it currently has support for the Open Library, Google Books, and Amazon’s Product Advertising API), more records can have cover images displayed as compared to using just one source.
- It lends itself to using one Coce instance to service multiple Koha instances.
There are also some disadvantages:
- It would be yet another service to maintain.
- It would be another point of failure. On the other hand, it looks like it would be easy to set up multiple, load-balanced instances of Coce.
- There is the possibility that image URLs might get cached for too long — although I don’t think any of the cover image services are in the habit of changing the static image URLs just for fun, they don’t necessarily guarantee that they will work forever.
I set up Coce on a Debian Wheezy VM. It was relatively simple to install; for posterity here is the procedure I used. First, I installed Redis, which Coce uses as its cache:
sudo apt-get install redis-server
Next, I installed Node.js by building a Debian package, then installing it:
sudo apt-get install python g++ make checkinstall mkdir ~/src && cd $_ wget -N http://nodejs.org/dist/node-latest.tar.gz tar xzvf node-latest.tar.gz && cd node-v* ./configure checkinstall sudo dpkg -i ./node_0.10.15-1_amd64.deb
When I got to the point where
checkinstall asked me to confirm the metadata for the package, I made sure to remove the “v” from the version number.
Next, I checked out Coce and installed the Node.js packages it needs:
cd ~ git clone https://github.com/fredericd/coce cd coce npm install express redis aws-lib util
I then copied ”config.json-sample” to ”config.json” and customized it. The only change I made, though, was to remove Amazon from the list of providers.
Finally, I started the service:
On my test Koha system, I installed the patch for bug 9580 and set the two system preferences it introduces to appropriate values to point to my Coce instance with the set of cover providers I wanted to use for the test.
The result? It worked: I did an OPAC search, and some of the titles that got displayed had their cover image provided by Google Books, while others were provided by the Open Library.
There are a few rough edges to work out. For example, the desired cover image size should probably be part of the client request to Coce, not part of Coce’s central configuration, and I suspect a bit more work is needed to get it to work properly if the OPAC is run under HTTPS. That said, this looks promising, and I enjoyed the chance to start playing a bit with Redis and Node.js.
Playing around with Coce by Galen Charlton is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.