示例#1
0
 /**
  * Process releases with no IMDB ID's.
  *
  * @param string $groupID    (Optional) ID of a group to work on.
  * @param string $guidChar   (Optional) First letter of a release GUID to use to get work.
  * @param int    $lookupIMDB (Optional) 0 Don't lookup IMDB, 1 lookup IMDB, 2 lookup IMDB on releases that were renamed.
  */
 public function processMovieReleases($groupID = '', $guidChar = '', $lookupIMDB = 1)
 {
     if ($lookupIMDB == 0) {
         return;
     }
     // Get all releases without an IMDB id.
     $res = $this->pdo->query(sprintf("\n\t\t\t\tSELECT r.searchname, r.id\n\t\t\t\tFROM releases r\n\t\t\t\tWHERE r.imdbid IS NULL\n\t\t\t\tAND r.nzbstatus = 1\n\t\t\t\t%s %s %s %s\n\t\t\t\tLIMIT %d", $this->catWhere, $groupID === '' ? '' : 'AND r.group_id = ' . $groupID, $guidChar === '' ? '' : 'AND r.guid ' . $this->pdo->likeString($guidChar, false, true), $lookupIMDB == 2 ? 'AND r.isrenamed = 1' : '', $this->movieqty));
     $movieCount = count($res);
     if ($movieCount > 0) {
         if (is_null($this->traktTv)) {
             $this->traktTv = new TraktTv(['Settings' => $this->pdo]);
         }
         if ($this->echooutput && $movieCount > 1) {
             $this->pdo->log->doEcho($this->pdo->log->header("Processing " . $movieCount . " movie releases."));
         }
         // Loop over releases.
         foreach ($res as $arr) {
             // Try to get a name/year.
             if ($this->parseMovieSearchName($arr['searchname']) === false) {
                 //We didn't find a name, so set to all 0's so we don't parse again.
                 $this->pdo->queryExec(sprintf("UPDATE releases SET imdbid = 0000000 WHERE id = %d %s", $arr["id"], $this->catWhere));
                 continue;
             } else {
                 $this->currentRelID = $arr['id'];
                 $movieName = $this->currentTitle;
                 if ($this->currentYear !== false) {
                     $movieName .= ' (' . $this->currentYear . ')';
                 }
                 if ($this->echooutput) {
                     $this->pdo->log->doEcho($this->pdo->log->primaryOver("Looking up: ") . $this->pdo->log->headerOver($movieName), true);
                 }
                 // Check local DB.
                 $getIMDBid = $this->localIMDBsearch();
                 if ($getIMDBid !== false) {
                     $imdbID = $this->doMovieUpdate('tt' . $getIMDBid, 'Local DB', $arr['id']);
                     if ($imdbID !== false) {
                         continue;
                     }
                 }
                 // Check OMDB api.
                 $buffer = Misc::getUrl(['url' => 'http://www.omdbapi.com/?t=' . urlencode($this->currentTitle) . ($this->currentYear !== false ? '&y=' . $this->currentYear : '') . '&r=json']);
                 if ($buffer !== false) {
                     $getIMDBid = json_decode($buffer);
                     if (isset($getIMDBid->imdbID)) {
                         $imdbID = $this->doMovieUpdate($getIMDBid->imdbID, 'OMDbAPI', $arr['id']);
                         if ($imdbID !== false) {
                             continue;
                         }
                     }
                 }
                 // Check on trakt.
                 $data = $this->traktTv->movieSummary($movieName, 'full,images');
                 if ($data !== false) {
                     $this->parseTraktTv($data);
                     if (isset($data['ids']['imdb'])) {
                         $imdbID = $this->doMovieUpdate($data['ids']['imdb'], 'Trakt', $arr['id']);
                         if ($imdbID !== false) {
                             continue;
                         }
                     }
                 }
                 // Try on search engines.
                 if ($this->searchEngines && $this->currentYear !== false) {
                     if ($this->imdbIDFromEngines() === true) {
                         continue;
                     }
                 }
                 // We failed to get an IMDB id from all sources.
                 $this->pdo->queryExec(sprintf("UPDATE releases SET imdbid = 0000000 WHERE id = %d %s", $arr["id"], $this->catWhere));
             }
         }
     }
 }
示例#2
0
文件: details.php 项目: sebst3r/nZEDb
             if (!empty($r['imgdata'])) {
                 $seriesimg[] = $r['imgdata'];
                 $seriesid[] = $r['id'];
             }
         }
         $rage = ['releasetitle' => array_shift($seriesnames), 'description' => array_shift($seriesdescription), 'country' => array_shift($seriescountry), 'genre' => array_shift($seriesgenre), 'imgdata' => array_shift($seriesimg), 'id' => array_shift($seriesid)];
     }
 }
 if ($data['anidbid'] > 0) {
     $AniDB = new AniDB(['Settings' => $releases->pdo]);
     $ani = $AniDB->getAnimeInfo($data['anidbid']);
 }
 if ($data['imdbid'] != '' && $data['imdbid'] != 00) {
     $movie = new Movie(['Settings' => $page->settings]);
     $mov = $movie->getMovieInfo($data['imdbid']);
     $trakt = new TraktTv(['Settings' => $page->settings]);
     $traktSummary = $trakt->traktMoviesummary('tt' . $data['imdbid'], true);
     if ($traktSummary !== false && isset($traktSummary['trailer']) && $traktSummary['trailer'] !== '' && preg_match('/[\\/?]v[\\/\\=](\\w+)$/i', $traktSummary['trailer'], $youtubeM)) {
         $mov['trailer'] = '<embed width="480" height="345" src="' . 'https://www.youtube.com/v/' . $youtubeM[1] . '" type="application/x-shockwave-flash"></embed>';
     } else {
         $mov['trailer'] = nzedb\utility\Utility::imdb_trailers($data['imdbid']);
     }
     if ($mov && isset($mov['title'])) {
         $mov['title'] = str_replace(['/', '\\'], '', $mov['title']);
         $mov['actors'] = $movie->makeFieldLinks($mov, 'actors');
         $mov['genre'] = $movie->makeFieldLinks($mov, 'genre');
         $mov['director'] = $movie->makeFieldLinks($mov, 'director');
     } else {
         if ($traktSummary !== false) {
             $mov['title'] = str_replace(['/', '\\'], '', $traktSummary['title']);
         } else {
示例#3
0
文件: TvRage.php 项目: sebst3r/nZEDb
 public function processTvReleases($groupID = '', $guidChar = '', $lookupTvRage = 1, $local = false)
 {
     $ret = 0;
     if ($lookupTvRage == 0) {
         return $ret;
     }
     $trakt = new TraktTv(['Settings' => $this->pdo]);
     // Get all releases without a rageid which are in a tv category.
     $res = $this->pdo->query(sprintf("\n\t\t\t\tSELECT r.searchname, r.id\n\t\t\t\tFROM releases r\n\t\t\t\tWHERE r.nzbstatus = 1\n\t\t\t\tAND r.rageid = -1\n\t\t\t\tAND r.size > 1048576\n\t\t\t\tAND r.categoryid BETWEEN 5000 AND 5999\n\t\t\t\t%s %s %s\n\t\t\t\tORDER BY r.postdate DESC\n\t\t\t\tLIMIT %d", $groupID === '' ? '' : 'AND r.group_id = ' . $groupID, $guidChar === '' ? '' : 'AND r.guid ' . $this->pdo->likeString($guidChar, false, true), $lookupTvRage == 2 ? 'AND r.isrenamed = 1' : '', $this->rageqty));
     $tvcount = count($res);
     if ($this->echooutput && $tvcount > 1) {
         echo $this->pdo->log->header("Processing TV for " . $tvcount . " release(s).");
     }
     foreach ($res as $arr) {
         $show = $this->parseNameEpSeason($arr['searchname']);
         if (is_array($show) && $show['name'] != '') {
             // Update release with season, ep, and airdate info (if available) from releasetitle.
             $this->updateEpInfo($show, $arr['id']);
             // Find the rageID.
             $id = $this->getByTitle($show['cleanname']);
             // Force local lookup only
             if ($local == true) {
                 $lookupTvRage = false;
             }
             if ($id === false && $lookupTvRage) {
                 // If it doesnt exist locally and lookups are allowed lets try to get it.
                 if ($this->echooutput) {
                     echo $this->pdo->log->primaryOver("TVRage ID for ") . $this->pdo->log->headerOver($show['cleanname']) . $this->pdo->log->primary(" not found in local db, checking web.");
                 }
                 $tvrShow = $this->getRageMatch($show);
                 if ($tvrShow !== false && is_array($tvrShow)) {
                     // Get all tv info and add show.
                     $this->updateRageInfo($tvrShow['showid'], $show, $tvrShow, $arr['id']);
                 } else {
                     if ($tvrShow === false) {
                         // If tvrage fails, try trakt.
                         $traktArray = $trakt->traktTVSEsummary($show['name'], $show['season'], $show['episode']);
                         if ($traktArray !== false) {
                             if (isset($traktArray['show']['tvrage_id']) && $traktArray['show']['tvrage_id'] !== 0) {
                                 if ($this->echooutput) {
                                     echo $this->pdo->log->primary('Found TVRage ID on trakt:' . $traktArray['show']['tvrage_id']);
                                 }
                                 $this->updateRageInfoTrakt($traktArray['show']['tvrage_id'], $show, $traktArray, $arr['id']);
                             } else {
                                 $this->add(-2, $show['cleanname'], '', '', '', '');
                             }
                         } else {
                             $this->add(-2, $show['cleanname'], '', '', '', '');
                         }
                     } else {
                         // $tvrShow probably equals -1 but we'll do this as a catchall instead of a specific else if.
                         // Skip because we couldnt connect to tvrage.com.
                     }
                 }
             } else {
                 if ($id > 0) {
                     //if ($this->echooutput) {
                     //    echo $this->pdo->log->AlternateOver("TV series: ") . $this->pdo->log->header($show['cleanname'] . " " . $show['seriesfull'] . (($show['year'] != '') ? ' ' . $show['year'] : '') . (($show['country'] != '') ? ' [' . $show['country'] . ']' : ''));
                     // }
                     $tvairdate = isset($show['airdate']) && !empty($show['airdate']) ? $this->pdo->escapeString($this->checkDate($show['airdate'])) : "NULL";
                     $tvtitle = "NULL";
                     if ($lookupTvRage) {
                         $epinfo = $this->getEpisodeInfo($id, $show['season'], $show['episode']);
                         if ($epinfo !== false) {
                             if (isset($epinfo['airdate'])) {
                                 $tvairdate = $this->pdo->escapeString($this->checkDate($epinfo['airdate']));
                             }
                             if (!empty($epinfo['title'])) {
                                 $tvtitle = $this->pdo->escapeString(trim($epinfo['title']));
                             }
                         }
                     }
                     if ($tvairdate == "NULL") {
                         $this->pdo->queryExec(sprintf('UPDATE releases SET tvtitle = %s, rageid = %d WHERE id = %d', $tvtitle, $id, $arr['id']));
                     } else {
                         $this->pdo->queryExec(sprintf('UPDATE releases SET tvtitle = %s, tvairdate = %s, rageid = %d WHERE id = %d', $tvtitle, $tvairdate, $id, $arr['id']));
                     }
                     // Cant find rageid, so set rageid to n/a.
                 } else {
                     $this->pdo->queryExec(sprintf('UPDATE releases SET rageid = -2 WHERE id = %d', $arr['id']));
                 }
             }
             // Not a tv episode, so set rageid to n/a.
         } else {
             $this->pdo->queryExec(sprintf('UPDATE releases SET rageid = -2 WHERE id = %d', $arr['id']));
         }
         $ret++;
     }
     return $ret;
 }
示例#4
0
文件: details.php 项目: EeGgSs/nZEDb
             if (!empty($r['imgdata'])) {
                 $seriesimg[] = $r['imgdata'];
                 $seriesid[] = $r['id'];
             }
         }
         $rage = ['releasetitle' => array_shift($seriesnames), 'description' => array_shift($seriesdescription), 'country' => array_shift($seriescountry), 'genre' => array_shift($seriesgenre), 'imgdata' => array_shift($seriesimg), 'id' => array_shift($seriesid)];
     }
 }
 if ($data['anidbid'] > 0) {
     $AniDB = new AniDB(['Settings' => $releases->pdo]);
     $ani = $AniDB->getAnimeInfo($data['anidbid']);
 }
 if ($data['imdbid'] != '' && $data['imdbid'] != 00) {
     $movie = new Movie(['Settings' => $page->settings]);
     $mov = $movie->getMovieInfo($data['imdbid']);
     $trakt = new TraktTv(['Settings' => $page->settings]);
     $traktSummary = $trakt->movieSummary('tt' . $data['imdbid'], 'full');
     if ($traktSummary !== false && isset($traktSummary['trailer']) && $traktSummary['trailer'] !== '' && preg_match('/[\\/?]v[\\/\\=](\\w+)$/i', $traktSummary['trailer'], $youtubeM)) {
         $mov['trailer'] = '<embed width="480" height="345" src="' . 'https://www.youtube.com/v/' . $youtubeM[1] . '" type="application/x-shockwave-flash"></embed>';
     } else {
         $mov['trailer'] = nzedb\utility\Misc::imdb_trailers($data['imdbid']);
     }
     if ($mov && isset($mov['title'])) {
         $mov['title'] = str_replace(['/', '\\'], '', $mov['title']);
         $mov['actors'] = $movie->makeFieldLinks($mov, 'actors');
         $mov['genre'] = $movie->makeFieldLinks($mov, 'genre');
         $mov['director'] = $movie->makeFieldLinks($mov, 'director');
     } else {
         if ($traktSummary !== false) {
             $mov['title'] = str_replace(['/', '\\'], '', $traktSummary['title']);
         } else {