[open-ils-commits] [GIT] Evergreen ILS branch master updated. 856ca6d995b8723e3fc17eef70ee738fe24219dc
Evergreen Git
git at git.evergreen-ils.org
Tue Nov 1 13:57:11 EDT 2011
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Evergreen ILS".
The branch, master has been updated
via 856ca6d995b8723e3fc17eef70ee738fe24219dc (commit)
from e000ec5da7ec06c3179276e22a91dd76f80b4981 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 856ca6d995b8723e3fc17eef70ee738fe24219dc
Author: Dan Scott <dscott at laurentian.ca>
Date: Tue Nov 1 13:29:25 2011 -0400
Force Amazon AC requests to use 10-digit ISBNs
Inspired by a patch submitted by Ian Bays <ian.bays at ptfs-europe.com>
via https://bugs.launchpad.net/evergreen/+bug/870171, this patch takes
the incoming key and, if it is longer than 10 characters (a 10-digit
ISBN or Amazon ID), attempts to normalize it and return a 10-digit ISBN.
We don't normalize all incoming keys because some sites are horribly
abusing the 020 MARC field to include an Amazon ID instead of an ISBN -
but that works in practice and we'd rather not break working
installations if we can avoid it.
Signed-off-by: Dan Scott <dscott at laurentian.ca>
diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/AddedContent/Amazon.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/AddedContent/Amazon.pm
index 77c6bef..9e2c13c 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/AddedContent/Amazon.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/AddedContent/Amazon.pm
@@ -6,6 +6,7 @@ use OpenILS::WWW::AddedContent;
use OpenSRF::Utils::JSON;
use OpenSRF::EX qw/:try/;
use XML::LibXML;
+use Business::ISBN;
my $AC = 'OpenILS::WWW::AddedContent';
@@ -66,6 +67,22 @@ sub fetch_content {
sub fetch_response {
my( $self, $page, $key ) = @_;
my $uname = $self->userid;
+
+ # Some sites have entered Amazon IDs in 020 $a, thus we cannot
+ # simply pass all incoming keys to Business::ISBN for normalization
+ if (length($key) > 10) {
+ # Use Business::ISBN to normalize the incoming ISBN
+ my $isbn = Business::ISBN->new( $key );
+ if (!defined $isbn) {
+ $logger->warning("'$key' is not a valid ISBN");
+ return 0;
+ }
+
+ # Amazon prefers ISBN10
+ $isbn = $isbn->as_isbn10 if $isbn->type eq 'ISBN13';
+ $key = $isbn->as_string([]);
+ }
+
my $url = $self->base_url . "$key.01.$page";
return $AC->get_url($url);
}
-----------------------------------------------------------------------
Summary of changes:
.../lib/OpenILS/WWW/AddedContent/Amazon.pm | 17 +++++++++++++++++
1 files changed, 17 insertions(+), 0 deletions(-)
hooks/post-receive
--
Evergreen ILS
More information about the open-ils-commits
mailing list