Our PowerPACs use cover images provided by ChiliFresh, and they’re a fantastic cover image service. But I ran into a problem, how can I find those records in the PAC (and in Polaris Leap) that do not have a cover image attached to them? I asked about it on the Discord and @eyoung from Phoenix Public Library offered a suggestion:
…in theory, wouldn’t you have to pass the cover image criteria through your provider and detect the HTTP response, hoping to log a value other than 200?
I hadn’t even thought of that and it’s a great idea, but it won’t work.
In those cases, where a record doesn’t have a cover image, ChiliFresh still provides an image. Specifically they provide a single pixel gif. That means that all of those queries would return a 200 response.
So I reworked the idea a bit. Since you’re going to get a 200 response no matter what, the thing you want to look at is the size of the image returned. I fired up my IDE and, after quite a lot of swearing, I made this. (I’m not a good Python programmer.)
I call it ChiliCheck. It’s just a dumb Python script that will take a text file full of ISBNs, check them against ChiliFresh, and then it’ll produce another text file indicating the ISBN and the size of the image returned. If that image size is 1px x 1px, you know it doesn’t have an image.
This is the programming equivalent of “If it’s stupid, but works, it’s not stupid.”
Anyway, the link below will take you to the project repo. I do intend to make some updates to it over the next few days, so… meh, figured I’d drop it into a git server for that reason. Make sure you read the README, especially the part about being a good library citizen and not hammering the hell out of ChiliFresh’s content servers. Batch your ISBNs, folks. Be nice.