Exemplo n.º 1
0
 /**
  * @param string $operation
  * @param \nzedb\RottenTomato $rt
  */
 protected function _getRTData($operation = '', $rt)
 {
     $count = 0;
     $check = false;
     do {
         $count++;
         switch ($operation) {
             case 'boxoffice':
                 $data = $rt->getBoxOffice();
                 $update = Movie::SRC_BOXOFFICE;
                 break;
             case 'theaters':
                 $data = $rt->getInTheaters();
                 $update = Movie::SRC_INTHEATRE;
                 break;
             case 'opening':
                 $data = $rt->getOpening();
                 $update = Movie::SRC_OPENING;
                 break;
             case 'upcoming':
                 $data = $rt->getUpcoming();
                 $update = Movie::SRC_UPCOMING;
                 break;
             case 'dvd':
                 $data = $rt->getDVDReleases();
                 $update = Movie::SRC_DVD;
                 break;
             default:
                 $data = false;
                 $update = 0;
         }
         if ($data !== false && $data !== '') {
             $test = @json_decode($data);
             if (isset($test)) {
                 $count = 2;
                 $check = true;
             }
         }
     } while ($count < 2);
     if ($check === true) {
         $success = $this->updateInsUpcoming('rottentomato', $update, $data);
         if ($this->echooutput) {
             if ($success !== false) {
                 $this->pdo->log->doEcho($this->pdo->log->header(sprintf("Added/updated movies to the %s list.", $operation)));
             } else {
                 $this->pdo->log->doEcho($this->pdo->log->primary(sprintf("No new updates for %s list.", $operation)));
             }
         }
     } else {
         exit(PHP_EOL . $this->pdo->log->error("Unable to fetch from Rotten Tomatoes, verify your API Key." . PHP_EOL));
     }
 }
Exemplo n.º 2
0
<?php

require_once realpath(dirname(dirname(dirname(__DIR__))) . DIRECTORY_SEPARATOR . 'indexer.php');
use nzedb\ColorCLI;
use nzedb\RottenTomato;
use nzedb\db\Settings;
$cli = new ColorCLI();
$rtkey = (new Settings())->getSetting('rottentomatokey');
if (isset($rtkey)) {
    $rt = new RottenTomato($rtkey);
    print_r(json_decode($rt->searchMovie("inception")));
    $url = RottenTomato::API_URL . "movies.json?apikey=" . $rt->getApiKey() . "&q=inception&page_limit=50";
    exit($cli->header("\nIf nothing was displayed above then there might be an error. If so, go to the following url: {$url}\n"));
} else {
    exit($cli->error("\nNo rotten tomato key.\n"));
}