Example #1
0
 /**
  *  Reload the content of this class.<br>
  *  Could be used to update or complete the information.
  *
  *  @param \newznab\libraries\Tmdb\TMDB $tmdb An instance of the API handler, necesary to make the API call.
  */
 public function reload($tmdb)
 {
     $tmdb->getEpisode($this->getTVShowID(), $this->getSeasonNumber(), $this->getEpisodeNumber());
 }
Example #2
0
 /**
  * Fetch info for IMDB id from TMDB.
  *
  * @param      $imdbId
  * @param bool $text
  *
  * @return array|bool
  */
 public function fetchTMDBProperties($imdbId, $text = false)
 {
     $lookupId = $text === false ? 'tt' . $imdbId : $imdbId;
     $tmdb = new TMDB($this->pdo->getSetting('tmdbkey'));
     try {
         $tmdbLookup = $tmdb->getMovie($lookupId);
     } catch (exception $e) {
         return false;
     }
     /*$status = $tmdbLookup->get('status_code');
     		if (!$status || (isset($status) && $status !== 1)) {
     			return false;
     		}*/
     $ret = [];
     $ret['title'] = $tmdbLookup->get('title');
     if ($this->currentTitle !== '') {
         // Check the similarity.
         similar_text($this->currentTitle, $ret['title'], $percent);
         if ($percent < 40) {
             if ($this->debug) {
                 $this->debugging->log(get_class(), __FUNCTION__, 'Found (' . $ret['title'] . ') from TMDB, but it\'s only ' . $percent . '% similar to (' . $this->currentTitle . ')', \Logger::LOG_INFO);
             }
             return false;
         }
     }
     $ret['tmdbid'] = $tmdbLookup->getID();
     $ImdbID = str_replace('tt', '', $tmdbLookup->get('imdb_id'));
     $ret['imdb_id'] = $ImdbID;
     $vote = $tmdbLookup->getVoteAverage();
     if (isset($vote)) {
         $ret['rating'] = $vote == 0 ? '' : $vote;
     }
     $overview = $tmdbLookup->get('overview');
     if (isset($overview)) {
         $ret['plot'] = $overview;
     }
     $tagline = $tmdbLookup->getTagline();
     if (isset($tagline)) {
         $ret['tagline'] = $tagline;
     }
     $released = $tmdbLookup->get('release_date');
     if (isset($released)) {
         $ret['year'] = date("Y", strtotime($released));
     }
     $genresa = $tmdbLookup->get('genres');
     if (isset($genresa) && sizeof($genresa) > 0) {
         $genres = [];
         foreach ($genresa as $genre) {
             $genres[] = $genre['name'];
         }
         $ret['genre'] = $genres;
     }
     $posterp = $tmdbLookup->getPoster();
     if (isset($posterp) && sizeof($posterp > 0)) {
         $ret['cover'] = "http://image.tmdb.org/t/p/w185" . $posterp;
     }
     $backdrop = $tmdbLookup->get('backdrop_path');
     if (isset($backdrop) && sizeof($backdrop) > 0) {
         $ret['backdrop'] = "http://image.tmdb.org/t/p/original" . $backdrop;
     }
     if ($this->echooutput) {
         $this->pdo->log->doEcho($this->pdo->log->primaryOver("TMDb Found ") . $this->pdo->log->headerOver($ret['title']), true);
     }
     return $ret;
 }
Example #3
0
 if (isset($_REQUEST['add'])) {
     // Derive cats from user preferences.
     $cats = [];
     $cats[] = '2030';
     $cats[] = '2040';
     $m = new Movie(['Settings' => $page->settings]);
     $mi = $m->getMovieInfo($_REQUEST['add']);
     if (!$mi) {
         $m->updateMovieInfo($_REQUEST['add']);
     }
     $usermovies = $um->addMovie($page->users->currentUserId(), $_REQUEST['add'], $cats);
 } else {
     if (!isset($_REQUEST['id'])) {
         $page->show404();
     }
     $tmdb = new TMDB($page->settings->getSetting('tmdbkey'), $page->settings->getSetting('imdblanguage'));
     $m = new Movie(['Settings' => $page->settings, 'TMDb' => $tmdb]);
     if (is_numeric($_REQUEST['id'])) {
         $movie = $m->fetchTMDBProperties($_REQUEST['id']);
         if ($movie !== false) {
             $obj = array($movie);
         }
     } else {
         $searchm = $tmdb->searchMovie($_REQUEST['id']);
         if ($searchm !== false) {
             if (isset($searchm['results'])) {
                 $obj = [];
                 $limit = 0;
                 foreach ($searchm['results'] as $movie) {
                     $limit++;
                     $movieinfo = $m->fetchTMDBProperties($movie['id'], true);