[Koha-cvs] koha/C4 Amazon.pm [dev_week]

Joshua Ferraro jmf at kados.org
Wed Dec 13 04:17:27 CET 2006


CVSROOT:	/sources/koha
Module name:	koha
Branch:		dev_week
Changes by:	Joshua Ferraro <kados>	06/12/13 03:17:27

Modified files:
	C4             : Amazon.pm 

Log message:
	check for the existance of a reader page before loading the reader link

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/C4/Amazon.pm?cvsroot=koha&only_with_tag=dev_week&r1=1.3.2.4.2.1&r2=1.3.2.4.2.2

Patches:
Index: Amazon.pm
===================================================================
RCS file: /sources/koha/koha/C4/Amazon.pm,v
retrieving revision 1.3.2.4.2.1
retrieving revision 1.3.2.4.2.2
diff -u -b -r1.3.2.4.2.1 -r1.3.2.4.2.2
--- Amazon.pm	24 Sep 2006 20:00:51 -0000	1.3.2.4.2.1
+++ Amazon.pm	13 Dec 2006 03:17:27 -0000	1.3.2.4.2.2
@@ -18,6 +18,10 @@
 
 use XML::Simple;
 use LWP::Simple;
+
+use LWP::UserAgent;
+use HTTP::Request::Common;
+
 use strict;
 require Exporter;
 
@@ -38,6 +42,7 @@
 
 @EXPORT = qw(
   &get_amazon_details
+  &check_search_inside
 );
 
 =head1 get_amazon_details($isbn);
@@ -70,6 +75,28 @@
 	return $response;
 }
 
+sub check_search_inside {
+        my $isbn = shift;
+		my $ua = LWP::UserAgent->new(
+        agent => "Mozilla/4.76 [en] (Win98; U)",
+        keep_alive => 1,
+        env_proxy => 1,
+		);
+		my $available = 1;
+		my $uri = "http://www.amazon.com/gp/reader/$isbn/ref=sib_dp_pt/002-7879865-0184864#reader-link";
+        my $req = HTTP::Request->new(GET => $uri);
+        $req->header (
+                'Accept' => 'image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, image/png, */*',
+                'Accept-Charset' => 'iso-8859-1,*,utf-8',
+                'Accept-Language' => 'en-US' );
+        my $res = $ua->request($req);
+		my $content = $res->content();
+		if ($content =~ m/This book is temporarily unavailable/) {
+			undef $available;
+		}
+        return $available;
+}
+
 =head1 NOTES
 
 =head1 AUTHOR





More information about the Koha-cvs mailing list