]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/perlmods/OpenILS/WWW/AddedContent/Amazon.pm
added a basic Amazon plugin so that new installs can use this module by default for...
[working/Evergreen.git] / Open-ILS / src / perlmods / OpenILS / WWW / AddedContent / Amazon.pm
1 package OpenILS::WWW::AddedContent::Amazon;
2 use strict; use warnings;
3 use OpenSRF::Utils::Logger qw/$logger/;
4 use OpenSRF::Utils::SettingsParser;
5 use OpenILS::WWW::AddedContent;
6 use OpenSRF::Utils::JSON;
7 use OpenSRF::EX qw/:try/;
8 use XML::LibXML;
9
10 my $AC = 'OpenILS::WWW::AddedContent';
11
12 sub new {
13     my( $class, $args ) = @_;
14     $class = ref $class || $class;
15     return bless($args, $class);
16 }
17
18 sub base_url {
19     my $self = shift;
20     return $self->{base_url};
21 }
22
23 sub userid {
24     my $self = shift;
25     return $self->{userid};
26 }
27
28
29 # --------------------------------------------------------------------------
30 sub jacket_small {
31     my( $self, $key ) = @_;
32     return $self->send_img(
33         $self->fetch_response('_SCMZZZZZZZ_.jpg', $key));
34 }
35
36 sub jacket_medium {
37     my( $self, $key ) = @_;
38     return $self->send_img(
39         $self->fetch_response('_SCMZZZZZZZ_.jpg', $key));
40
41 }
42 sub jacket_large {
43     my( $self, $key ) = @_;
44     return $self->send_img(
45         $self->fetch_response('_SCZZZZZZZ_.jpg', $key));
46 }
47
48 # --------------------------------------------------------------------------
49
50 sub toc_html {
51     my( $self, $key ) = @_;
52 }
53
54 sub toc_xml {
55     my( $self, $key ) = @_;
56 }
57
58 sub toc_json {
59     my( $self, $key ) = @_;
60 }
61
62 # --------------------------------------------------------------------------
63
64 sub anotes_html {
65     my( $self, $key ) = @_;
66 }
67
68 sub anotes_xml {
69     my( $self, $key ) = @_;
70 }
71
72 sub anotes_json {
73     my( $self, $key ) = @_;
74 }
75
76
77 # --------------------------------------------------------------------------
78
79 sub excerpt_html {
80     my( $self, $key ) = @_;
81 }
82
83 sub excerpt_xml {
84     my( $self, $key ) = @_;
85 }
86
87 sub excerpt_json {
88     my( $self, $key ) = @_;
89 }
90
91 # --------------------------------------------------------------------------
92
93 sub reviews_html {
94     my( $self, $key ) = @_;
95 }
96
97 # we have to aggregate the reviews
98 sub reviews_xml {
99     my( $self, $key ) = @_;
100 }
101
102
103 sub reviews_json {
104     my( $self, $key ) = @_;
105 }
106
107 # --------------------------------------------------------------------------
108
109 sub send_img {
110     my($self, $response) = @_;
111     return { 
112         content_type => $response->header('Content-type'),
113         content => $response->content, 
114         binary => 1 
115     };
116 }
117
118 # returns the raw content returned from the URL fetch
119 sub fetch_content {
120     my( $self, $page, $key ) = @_;
121     return $self->fetch_response($page, $key)->content;
122 }
123
124 # returns the HTTP response object from the URL fetch
125 sub fetch_response {
126     my( $self, $page, $key ) = @_;
127     my $uname = $self->userid;
128     my $url = $self->base_url . "$key.01.$page";
129     return $AC->get_url($url);
130 }
131
132
133
134 1;