From 4eb3797733e6eddfaced73c780b2e2ea0c527459 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Fri, 11 Apr 2014 14:48:00 -0700 Subject: [PATCH] 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 --- Open-ILS/src/perlmods/lib/OpenILS/WWW/AddedContent/OpenLibrary.pm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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(); -- 2.11.0