Ejemplo n.º 1
0
 public function fetchAmazonProperties($title, $node)
 {
     $conf = new GenericConfiguration();
     try {
         $conf->setCountry('com')->setAccessKey($this->pubkey)->setSecretKey($this->privkey)->setAssociateTag($this->asstag)->setResponseTransformer('\\newznab\\libraries\\ApaiIO\\ResponseTransformer\\XmlToSimpleXmlObject');
     } catch (\Exception $e) {
         echo $e->getMessage();
     }
     $search = new Search();
     $search->setCategory('VideoGames');
     $search->setKeywords($title);
     $search->setBrowseNode($node);
     $search->setResponseGroup(['Large']);
     $apaiIo = new ApaiIO($conf);
     $response = $apaiIo->runOperation($search);
     if ($response === false) {
         throw new \Exception("Could not connect to Amazon");
     } else {
         if (isset($response->Items->Item->ItemAttributes->Title)) {
             return $response;
         } else {
             return false;
         }
     }
 }
Ejemplo n.º 2
0
<?php

require_once dirname(__FILE__) . '/../../../www/config.php';
use newznab\libraries\ApaiIO\Configuration\GenericConfiguration;
use newznab\libraries\ApaiIO\Operations\Search;
use newznab\libraries\ApaiIO\ApaiIO;
use newznab\db\Settings;
$pdo = new Settings();
$pubkey = $pdo->getSetting('amazonpubkey');
$privkey = $pdo->getSetting('amazonprivkey');
$asstag = $pdo->getSetting('amazonassociatetag');
$conf = new GenericConfiguration();
$conf->setCountry('com')->setAccessKey($pubkey)->setSecretKey($privkey)->setAssociateTag($asstag)->setResponseTransformer('\\newznab\\libraries\\ApaiIO\\ResponseTransformer\\XmlToSimpleXmlObject');
$search = new Search();
$search->setCategory('VideoGames');
$search->setKeywords('Guilty Gear 2 Oveture');
$search->setResponseGroup(['Large']);
$search->setPage(1);
$apaiIo = new ApaiIO($conf);
$response = $apaiIo->runOperation($search);
var_dump($response);
Ejemplo n.º 3
0
 /**
  * @param $title
  *
  * @return bool|mixed
  * @throws Exception
  */
 public function fetchAmazonProperties($title)
 {
     $response = false;
     $conf = new GenericConfiguration();
     try {
         $conf->setCountry('com')->setAccessKey($this->pubkey)->setSecretKey($this->privkey)->setAssociateTag($this->asstag)->setResponseTransformer('\\newznab\\libraries\\ApaiIO\\ResponseTransformer\\XmlToSimpleXmlObject');
     } catch (\Exception $e) {
         echo $e->getMessage();
     }
     $apaiIo = new ApaiIO($conf);
     // Try Music category.
     try {
         $search = new Search();
         $search->setCategory('Music');
         $search->setKeywords($title);
         $search->setResponseGroup(['Large']);
         $response = $apaiIo->runOperation($search);
     } catch (\Exception $e) {
         // Empty because we try another method.
     }
     // Try MP3 category.
     if ($response === false) {
         usleep(700000);
         try {
             $search = new Search();
             $search->setCategory('MP3Downloads');
             $search->setKeywords($title);
             $search->setResponseGroup(['Large']);
             $response = $apaiIo->runOperation($search);
         } catch (\Exception $e) {
             // Empty because we try another method.
         }
     }
     // Try Digital Music category.
     if ($response === false) {
         usleep(700000);
         try {
             $search = new Search();
             $search->setCategory('DigitalMusic');
             $search->setKeywords($title);
             $search->setResponseGroup(['Large']);
             $response = $apaiIo->runOperation($search);
         } catch (\Exception $e) {
             // Empty because we try another method.
         }
     }
     // Try Music Tracks category.
     if ($response === false) {
         usleep(700000);
         try {
             $search = new Search();
             $search->setCategory('MusicTracks');
             $search->setKeywords($title);
             $search->setResponseGroup(['Large']);
             $response = $apaiIo->runOperation($search);
         } catch (\Exception $e) {
             // Empty because we exhausted all possibilities.
         }
     }
     if ($response === false) {
         throw new \Exception("Could not connect to Amazon");
     } else {
         if (isset($response->Items->Item->ItemAttributes->Title)) {
             return $response;
         } else {
             return false;
         }
     }
 }
Ejemplo n.º 4
0
 /**
  * @param string $name
  * @param int    $id
  * @param string $nfo
  * @param        $q
  * @param string $region
  * @param bool   $case
  * @param string $row
  *
  * @return bool
  */
 private function doAmazon($name = '', $id = 0, $nfo = "", $q, $region = 'com', $case = false, $row = '')
 {
     $conf = new GenericConfiguration();
     try {
         $conf->setCountry($region)->setAccessKey($this->pubkey)->setSecretKey($this->privkey)->setAssociateTag($this->asstag)->setResponseTransformer('\\newznab\\libraries\\ApaiIO\\ResponseTransformer\\XmlToSimpleXmlObject');
     } catch (\Exception $e) {
         echo $e->getMessage();
     }
     //$amazon = new AmazonProductAPI($this->pdo->getSetting('amazonpubkey, $this->pdo->getSetting('amazonprivkey, $this->pdo->getSetting('amazonassociatetag);
     $amalookup = new Lookup();
     $apaiIo = new ApaiIO($conf);
     $ok = false;
     try {
         switch ($case) {
             case 'upc':
                 //$amaz = $amazon->getItemByUpc(trim($q), $region);
                 $amalookup->getName();
                 $amalookup->setItemId(trim($q));
                 $amalookup->setSearchIndex($region);
                 $amalookup->setIdType('UPC');
                 $amalookup->setResponseGroup(['Medium']);
                 $response = $apaiIo->runOperation($amalookup);
                 break;
             case 'asin':
                 //$amaz = $amazon->getItemByAsin(trim($q), $region);
                 $amalookup->getName();
                 $amalookup->setItemId(trim($q));
                 $amalookup->setResponseGroup(['Medium']);
                 $response = $apaiIo->runOperation($amalookup);
                 break;
             case 'isbn':
                 //$amaz = $amazon->searchProducts(trim($q), '', "ISBN");
                 $amalookup->getName();
                 $amalookup->setItemId(trim($q));
                 $amalookup->setSearchIndex($region);
                 $amalookup->setIdType('ISBN');
                 $amalookup->setResponseGroup(['Medium']);
                 $response = $apaiIo->runOperation($amalookup);
                 break;
             default:
                 $response = false;
         }
     } catch (\Exception $e) {
         echo 'Caught exception: ', $e->getMessage() . PHP_EOL;
     }
     if (isset($response) && isset($response->Items->Item)) {
         $type = $response->Items->Item->ItemAttributes->ProductGroup;
         switch ($type) {
             case 'Audible':
             case 'Book':
             case 'eBooks':
                 $ok = $this->_doAmazonBooks($response, $id);
                 break;
             case 'Digital Music Track':
             case 'Digital Music Album':
             case 'Music':
                 $ok = $this->_doAmazonMusic($response, $id);
                 break;
             case 'Bluray':
             case 'Movies':
             case 'DVD':
             case 'DVD & Bluray':
                 $ok = $this->_doAmazonMovies($response, $id, $nfo);
                 break;
             case 'Video Games':
                 $ok = $this->_doAmazonVG($response, $id);
                 break;
             default:
                 echo PHP_EOL . $this->pdo->log->error("Amazon category {$type} could not be parsed for " . $name) . PHP_EOL;
         }
     }
     return $ok;
 }