1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
define_tag(
'albumcover',
-namespace='amazon_',
-required='key',
-type='string',
-required='artist',
-type='string',
-required='album',
-type='string',
-priority='replace',
-description='Returns the first Large Image URL for the given album from Amazon Web Services.'
);
local('baseurl' = 'http://webservices.amazon.com/onca/xml');
local('params') = array(
'Service' = 'AWSECommerceService',
'AWSAccessKeyId' = #key,
'Operation' = 'ItemSearch',
'SearchIndex' = 'Music',
'Artist' = encode_url(#artist),
'Title' = encode_url(#album),
'ResponseGroup' = 'Images'
);
local('response') = include_url(
#baseurl,
-getparams=#params
);
#response = string_replaceregexp(
#response,
-find='xmlns=".+?"',
-replace=''
);
#response = xml(#response);
local('imagedata') = #response->extract('//LargeImage/URL/text()');
#imagedata->size ? return(#imagedata->first) | return;
/define_tag;
|