From: Galen Charlton Date: Fri, 11 Apr 2014 21:48:00 +0000 (-0700) Subject: LP#1306823: try to increase changes of fetching added content from the OL X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=4eb3797733e6eddfaced73c780b2e2ea0c527459;p=working%2FEvergreen.git LP#1306823: try to increase changes of fetching added content from the OL For works that have more than one edition in the Open Library's database, using 'isbn' as the search key can sometimes fail to bring up the edition that has a cover image. This patch instead uses "isbn_10" or "isbn_13", depending on the length of the ISBN, to try to retrieve the right edition. This is known to work with ISBN 9264023607. However, it is also entirely possible that this works only because of a quirk in OL as of the date of this patch; for example, neither "isbn_10" nor "isbn_13" are listed as valid ID types in https://openlibrary.org/dev/docs/api/read. Signed-off-by: Galen Charlton --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/AddedContent/OpenLibrary.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/AddedContent/OpenLibrary.pm index c2c2cc688b..fcfbcb1795 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/AddedContent/OpenLibrary.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/AddedContent/OpenLibrary.pm @@ -259,7 +259,11 @@ sub fetch_response { # TODO: OpenLibrary can also accept lccn, oclc, olid... # Hardcoded to only accept ISBNs for now. - $key = "isbn:$key"; + if (length($key) <= 10) { + $key = "isbn_10:$key"; + } else { + $key = "isbn_13:$key"; + } my $url = $read_api . $key; my $response = $AC->get_url($url)->content();