Search for Amazon Cover Art from a server in your country.

From LinuxMCE
Jump to: navigation, search


If english is not your mothertongue, you might want to fetch cover art from one of the other amazon servers instead of fetching them from the US server. Currently there exist servers in the following country codes: US, UK, DE, JP, FR, CA.

To enable another server, you have to adjust the following file: /var/www/pluto-admin/coverArtExtractor.php

In there you will find at line 36:

$orderBy=($searchIndex=='Music')?'titlerank':'relevancerank';
// Make the request for cover arts
$request='http://webservices.amazon.com/onca/xml?Service=AWSECommerceService&AssociateTag='.ASSOCIATES_ID.'&Version='.AES_VERSION.'&SubscriptionId='. SUBID.'&Operation=ItemSearch&SearchIndex='.$searchIndex.'&ResponseGroup=Medium&Sort='.$orderBy.'&'.$searchString;

Those lines you should comment out but leaving them in place won't do any harm as we will overwrite those variables now with our desired server information.

I also had to change the search from "relevancerank" to "salesrank" as "relevancerank" is only supported for electronics (see: [1])

The diff for the file looks like this:

--- /var/www/pluto-admin/coverArtExtractor.php.old        2008-11-18 00:54:40.000000000 +0100
+++ /var/www/pluto-admin/coverArtExtractor.php  2009-01-03 05:54:22.000000000 +0100
@@ -33,9 +33,24 @@
 $searchString.=(isset($_REQUEST['Keyword2Type']))?'&'.$_REQUEST['Keyword2Type'].'='.$Keyword2Search:'';
 $searchString.=(isset($_REQUEST['Keyword3Type']))?'&'.$_REQUEST['Keyword3Type'].'='.$Keyword3Search:'';

-$orderBy=($searchIndex=='Music')?'titlerank':'relevancerank';
 // Make the request for cover arts
-$request='http://webservices.amazon.com/onca/xml?Service=AWSECommerceService&AssociateTag='.ASSOCIATES_ID.'&Version='.AES_VERSION.'&SubscriptionId='. SUBID.'&Operation=ItemSearch&SearchIndex='.$searchIndex.'&ResponseGroup=Medium&Sort='.$orderBy.'&'.$searchString;
+$orderBy=($searchIndex=='Music')?'titlerank':'salesrank';
+// Uncomment the desired server below.
+// US
+// $request='http://webservices.amazon.com/onca/xml?Service=AWSECommerceService&AssociateTag='.ASSOCIATES_ID.'&Version='.AES_VERSION.'&SubscriptionId='. SUBID.'&Operation=ItemSearch&SearchIndex='.$searchIndex.'&ResponseGroup=Medium&Sort='.$orderBy.'&'.$searchString;
+// UK
+// $request='http://webservices.amazon.co.uk/onca/xml?Service=AWSECommerceService&AssociateTag='.ASSOCIATES_ID.'&Version='.AES_VERSION.'&SubscriptionId='. SUBID.'&Operation=ItemSearch&SearchIndex='.$searchIndex.'&ResponseGroup=Medium&Sort='.$orderBy.'&'.$searchString;
+// DE
+// $request='http://webservices.amazon.de/onca/xml?Service=AWSECommerceService&AssociateTag='.ASSOCIATES_ID.'&Version='.AES_VERSION.'&SubscriptionId='. SUBID.'&Operation=ItemSearch&SearchIndex='.$searchIndex.'&ResponseGroup=Medium&Sort='.$orderBy.'&'.$searchString;
+// JP
+// $request='http://webservices.amazon.co.jp/onca/xml?Service=AWSECommerceService&AssociateTag='.ASSOCIATES_ID.'&Version='.AES_VERSION.'&SubscriptionId='. SUBID.'&Operation=ItemSearch&SearchIndex='.$searchIndex.'&ResponseGroup=Medium&Sort='.$orderBy.'&'.$searchString;
+// FR
+// $request='http://webservices.amazon.fr/onca/xml?Service=AWSECommerceService&AssociateTag='.ASSOCIATES_ID.'&Version='.AES_VERSION.'&SubscriptionId='. SUBID.'&Operation=ItemSearch&SearchIndex='.$searchIndex.'&ResponseGroup=Medium&Sort='.$orderBy.'&'.$searchString;
+// CA
+// $request='http://webservices.amazon.ca/onca/xml?Service=AWSECommerceService&AssociateTag='.ASSOCIATES_ID.'&Version='.AES_VERSION.'&SubscriptionId='. SUBID.'&Operation=ItemSearch&SearchIndex='.$searchIndex.'&ResponseGroup=Medium&Sort='.$orderBy.'&'.$searchString;
+
+
 echo $request;
 writeFile($GLOBALS['WebExecLogFile'],date('d-m-Y H:i:s')."\t".$request."\n",'a+');

@@ -94,4 +109,4 @@

 $end_time=getmicrotime();
 //print 'Finished in '.round(($end_time-$start_time),3).'s, found: '.$found.' cover arts.';
-?>
\ No newline at end of file
+?>

I hope this is of some use to someone and maybe it will make it into the pluto configuration some time if a dev has the time to add it.