I have a Google form where people can submit books by author and book title. I would like to use this to retrieve the ISBN.
function atSubmitForm(e) {
var formResponses = e.response;
var itemResponses = formResponses.getItemResponses();
var bookTitle = itemResponses[0].getResponse();
var authorFirst = itemResponses[1].getResponse();
var authorLast = itemResponses[2].getResponse();
var url = "https://www.googleapis.com/books/v1/volumes?q=intitle:\"" + bookTitle + "\" inauthor:\"" + authorFirst + " " + authorLast + "\"" + "&country=CA";
var urlEncoded = encodeURI(url);
var response = UrlFetchApp.fetch(urlEncoded);
var result = JSON.parse(response);
var items = result.items;
var item = items[0].volumeInfo;
for (var i = 0; i < item.industryIdentifiers.length; i++) {
var id = item.industryIdentifiers[i];
if (id.type === "ISBN_13") {
var isbn = id.identifier;
}
}
}
This isn't the whole function, obviously, but the ISBN is what's giving me problems. It doesn't seem to be pulling the information I'm expecting. For example, the book Children of Time by Adrian Tchaikovsky will generate a urlEncoded = https://www.googleapis.com/books/v1/volumes?q=intitle:"Children+of+Time"+inauthor:"Adrian+Tchaikovsky"&country=CA and it will return an isbn = 9780316452496. I don't know where this ISBN comes from but it isn't listed on the urlEncoded page.
Similarly, On the Road by Jack Kerouac generates a urlEncoded = https://www.googleapis.com/books/v1/volumes?q=intitle:"On+the+Road"+inauthor:"Jack+Kerouac"&country=CA and then returns an isbn = 9780142437254, also not found on the previous page (i.e., urlEncoded).
Why doesn't it pull the first ISBN from these pages, or even from these pages at all?
Edit: For Tchaikovsky's Children of Time I was expecting isbn = 9781447273318. For Kerouac's On the Road I was expecting isbn = 9781101127575