This mashup was completed as an assignment for LIBR 246 and brings together the New Fiction RSS feed from the San Jose Public Library and Amazon ratings. When deciding what book to read, patrons may browse a list of new books. However, they may not have any context with which to choose a book from that list. This mashup can provide some assistance by ordering the items based on average rating and number of customer reviews for the item on Amazon.
To create this mashup, I used Yahoo! Pipes. The interface for it was really easy to use. Perhaps what I was trying to do isn’t quite the way it’s meant to be used, however, because I found that the operations which I wanted to do resulted in work that was somewhat tedious: repeatedly looping through information in the feed to mold it slightly into something new.
Before I share the gory details, check out the Rated New Fiction feed and find a new fiction book you might like from the San Jose Public Library.
After that, if you’re interested, read about the details of the pipe I created…
To start off with, first fetch the New Fiction Feed from the library’s website. That’s easy enough. Next, get information about the book from Amazon. To do that, some kind of distinctive information must be passed to Amazon so that information is accessed about the correct book. If you peek at the XML for the feed, it turns out that each item has a “guid” entry, which–neatly enough–maps to the book’s ISBN. However, the “guid” entry needs to have the extra information filtered out, such as whether it’s a paperback or hardback, so loop through each item using the pipes String Tokenizer with argument ” ” (that’s a space). Put the first result — that is, whatever came before the first space — into item.isbn.
Now there is a distinct piece of information to identify the book, which can be passed to Amazon. In order to use Amazon Web Services, a unique key is needed. Amazon’s documentation about how to use their web services is quite extensive. The call we’re interested in is ItemLookup.
This is the ItemLookup call to be used:
http://webservices.amazon.com/onca/xml?
Service=AWSECommerceService
&AWSAccessKeyId=[Your access key]
&Operation=ItemLookup
&IdType=ISBN
&MerchantId=Amazon
&ResponseGroup=Large
&ItemId=[item.isbn.content]
&ContentType=text/xml
&SearchIndex=Books
From that, access the average rating for the item (Items.Item.CustomerReviews.AverageRating) and the total number of customer reviews for the item (Items.Item.CustomerReviews.TotalReviews).
To make the feed a little more snazzy, wouldn’t it be nice to show the star ratings, not just a number? With a little detective work, it’s easy to figure out the pattern that Amazon uses for constructing the URL for its star images. The URL for a book with 4 stars is this: http://g-ecx.images-amazon.com/images/G/01/x-locale/common/customer-reviews/ratings/stars-4-0._V25749327_.gif
Just replace the 4-0 with our average rating to access the correct little star image. That’s done by taking the average rating (for example, 3.5) and replacing the period with a dash. Next, construct a URL by putting that number into the star URL.
It would also be nice to make sure that items which don’t have any reviews show a useful string, instead of just being blank. Yahoo! Pipes doesn’t have any direct test for determining if a string is empty, which is what happens when there are no reviews. I searched around and found a great reference on Using Regular Expressions with Yahoo Pipes, which told me how to check for something being empty. If the number of reviews for an item is empty, the text should say “None” and instead of showing nothing where the stars would be, show a little graphic that says “N/A”.
Once all the strings and data are built up, two things need to be done: update the item’s description to show the ratings, and sort the items based on their rating and number of reviews. The sort is easy: sort based on item.rating (which is where the average rating was stashed) and item.numReviews (which is where the number of reviews was stashed).
To update the item’s description, use the string builder to put together this string:
Average rating: <img src=”item.ratingURL”> (Reviews: item.numReviews)<br/><br/>item.description
This will prepend our rating information to the item’s description, giving the user some additional context.
After that… run the pipe! If you look at the RSS feed, you’ll see that the first items listed are those with higher ratings. A tie between two books which have the same rating is broken by the number of customer reviews: those with more reviews will be listed first.
In the end, it was fun to tinker with Yahoo Pipes and to have it result in something that could be useful in helping people find new material in the library.
Of course, there’s always more that could be done. It’d be great to be able to link the stars and review info to the customer reviews on Amazon. Likewise, if the item description doesn’t have a summary, it’d be great to include Amazon’s. What other ways could this be improved?
I don’t think I could bring myself to do this process for each of the many new item RSS feeds available at King Library. Perhaps the process could be simplified by using Flex instead of Yahoo! Pipes, where a set of steps could be applied rather than repeated loops of individual steps. Either way, it was still fun to tinker with Yahoo! Pipes and learn about it! And who knows, maybe it will help someone find a good book to read!
My name is Heather and I ♥ monkeys. I am a computer scientist in San Jose and my background is in cognitive science, computer science, usability, and library and information science. My interests include preservation, oral history, indigenous knowledge and technology. 
It‘s quiet in here! Why not leave a response?