} } $rage = array('releasetitle' => array_shift($seriesnames), 'description' => array_shift($seriesdescription), 'country' => array_shift($seriescountry), 'genre' => array_shift($seriesgenre), 'imgdata' => array_shift($seriesimg), 'id' => array_shift($seriesid)); } } $episodeArray = ''; if ($data['episodeinfoid'] > 0) { $episode = new Episode(); $episodeArray = $episode->getEpisodeInfoByID($data['episodeinfoid']); } $mov = ''; if ($data['imdbid'] != '' && $data['imdbid'] != 00) { $movie = new Film(); $mov = $movie->getMovieInfo($data['imdbid']); $trakt = new TraktTv(); $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'] = \newznab\utility\Utility::imdb_trailers($data['imdbid']); } if ($mov && isset($mov['title'])) { $mov['title'] = str_replace(array('/', '\\'), '', $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(array('/', '\\'), '', $traktSummary['title']); } else { $mov = false;
/** * 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; } $trakTv = new \TraktTv(['Settings' => $this->pdo]); // 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\tAND r.categoryid BETWEEN 2000 AND 2999\n\t\t\t\t%s %s %s\n\t\t\t\tLIMIT %d", $groupID === '' ? '' : 'AND r.groupid = ' . $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 ($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", $arr["id"])); 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 = Utility::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. $getIMDBid = $trakTv->movieSummary($movieName); if ($getIMDBid !== false) { $imdbID = $this->doMovieUpdate($getIMDBid, '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", $arr["id"])); } } } }
//This script will update all records in the movieinfo table require_once dirname(__FILE__) . '/../../../www/config.php'; use newznab\db\Settings; $pdo = new Settings(); $trakt = new TraktTv(['Settings' => $pdo]); $mreleases = $pdo->queryDirect(sprintf('SELECT id, imdbid FROM releases WHERE traktid = 0 AND imdbid IS NOT NULL AND imdbid != 0000000 ORDER BY id ASC')); $treleases = $pdo->queryDirect(sprintf('SELECT id, rageid FROM releases WHERE traktid = 0 AND rageid NOT IN(0,-1,-2)')); $mtotal = $mreleases->rowCount(); $ttotal = $treleases->rowCount(); $mcount = 0; if ($mtotal > 0) { echo $pdo->log->header("Updating Trakt ID for " . number_format($mtotal) . " movies."); foreach ($mreleases as $rel) { $mcount++; $data = $trakt->movieSummary('tt' . $rel['imdbid'], 'min'); if ($data != false) { if (isset($data['ids']['trakt'])) { $pdo->queryExec(sprintf('UPDATE releases SET traktid = %s WHERE id = %s', $pdo->escapeString($data['ids']['trakt']), $pdo->escapeString($rel['id']))); echo $pdo->log->info('Updated ' . $data['title'] . ' with Trakt ID:' . $data['ids']['trakt']); } } } echo $pdo->log->header('Updated ' . $mcount . ' movie(s).'); } else { echo $pdo->log->info('No movies need updating'); } $tcount = 0; if ($ttotal > 0) { echo $pdo->log->header("Updating Trakt ID for " . number_format($ttotal) . " shows."); foreach ($treleases as $rel) {