if (!$page->users->isLoggedIn()) { $page->show403(); } $releases = new Releases(['Settings' => $page->settings]); $tvrage = new TvRage(['Settings' => $page->settings]); $cat = new Category(['Settings' => $page->settings]); $us = new UserSeries(['Settings' => $page->settings]); if (isset($_GET["id"]) && ctype_digit($_GET['id'])) { $category = -1; if (isset($_REQUEST["t"]) && ctype_digit($_REQUEST["t"])) { $category = $_REQUEST["t"]; } $catarray = array(); $catarray[] = $category; $rel = $releases->searchbyRageId($_GET["id"], '', '', 0, 1000, "", $catarray, -1); $rage = $tvrage->getByRageID($_GET['id']); if (!$rage) { $page->smarty->assign("nodata", "No tvrage information for this series."); } elseif (!$rel) { $page->smarty->assign("nodata", "No releases for this series."); } else { $myshows = $us->getShow($page->users->currentUserId(), $rage[0]['rageid']); // Sort releases by season, episode, date posted. $season = $episode = $posted = array(); foreach ($rel as $rlk => $rlv) { $season[$rlk] = $rlv['season']; $episode[$rlk] = $rlv['episode']; $posted[$rlk] = $rlv['postdate']; } array_multisort($season, SORT_DESC, $episode, SORT_DESC, $posted, SORT_DESC, $rel); $seasons = array();
} $rc = new ReleaseComments($page->settings); if ($page->isPostBack()) { $rc->addComment($data['id'], $_POST['txtAddComment'], $page->users->currentUserId(), $_SERVER['REMOTE_ADDR']); } $nfo = $releases->getReleaseNfo($data['id'], false); $re = new ReleaseExtra($page->settings); $reVideo = $re->getVideo($data['id']); $reAudio = $re->getAudio($data['id']); $reSubs = $re->getSubs($data['id']); $comments = $rc->getComments($data['id']); $similars = $releases->searchSimilar($data['id'], $data['searchname'], 6, $page->userdata['categoryexclusions']); $rage = $ani = $mov = $mus = $con = $game = $xxx = $boo = ''; if ($data['rageid'] != '') { $tvrage = new TvRage(['Settings' => $page->settings]); $rageinfo = $tvrage->getByRageID($data['rageid']); if (count($rageinfo) > 0) { $seriesnames = $seriesdescription = $seriescountry = $seriesgenre = $seriesimg = $seriesid = []; foreach ($rageinfo as $r) { $seriesnames[] = $r['releasetitle']; if (!empty($r['description'])) { $seriesdescription[] = $r['description']; } if (!empty($r['country'])) { $seriescountry[] = $r['country']; } if (!empty($r['genre'])) { $seriesgenre[] = $r['genre']; } if (!empty($r['imgdata'])) { $seriesimg[] = $r['imgdata'];
/** * Attempt to find NFO files inside the NZB's of releases. * * @param object $nntp Instance of class NNTP. * @param string $groupID (optional) Group ID. * @param string $guidChar (optional) First character of the release GUID (used for multi-processing). * @param int $processImdb (optional) Attempt to find IMDB id's in the NZB? * @param int $processTvrage (optional) Attempt to find TvRage id's in the NZB? * * @return int How many NFO's were processed? * * @access public */ public function processNfoFiles($nntp, $groupID = '', $guidChar = '', $processImdb = 1, $processTvrage = 1) { $ret = 0; $guidCharQuery = $guidChar === '' ? '' : 'AND r.guid ' . $this->pdo->likeString($guidChar, false, true); $groupIDQuery = $groupID === '' ? '' : 'AND r.group_id = ' . $groupID; $optionsQuery = self::NfoQueryString($this->pdo); $res = $this->pdo->query(sprintf(' SELECT r.id, r.guid, r.group_id, r.name FROM releases r WHERE 1=1 %s %s %s ORDER BY r.nfostatus ASC, r.postdate DESC LIMIT %d', $optionsQuery, $guidCharQuery, $groupIDQuery, $this->nzbs)); $nfoCount = count($res); if ($nfoCount > 0) { $this->pdo->log->doEcho($this->pdo->log->primary(PHP_EOL . ($guidChar === '' ? '' : '[' . $guidChar . '] ') . ($groupID === '' ? '' : '[' . $groupID . '] ') . 'Processing ' . $nfoCount . ' NFO(s), starting at ' . $this->nzbs . ' * = hidden NFO, + = NFO, - = no NFO, f = download failed.')); if ($this->echo) { // Get count of releases per nfo status $nfoStats = $this->pdo->queryDirect(sprintf(' SELECT r.nfostatus AS status, COUNT(*) AS count FROM releases r WHERE 1=1 %s %s %s GROUP BY r.nfostatus ORDER BY r.nfostatus ASC', $optionsQuery, $guidCharQuery, $groupIDQuery)); if ($nfoStats instanceof \Traversable) { $outString = PHP_EOL . 'Available to process'; foreach ($nfoStats as $row) { $outString .= ', ' . $row['status'] . ' = ' . number_format($row['count']); } $this->pdo->log->doEcho($this->pdo->log->header($outString . '.')); } } $groups = new Groups(['Settings' => $this->pdo]); $nzbContents = new NZBContents(['Echo' => $this->echo, 'NNTP' => $nntp, 'Nfo' => $this, 'Settings' => $this->pdo, 'PostProcess' => new PostProcess(['Echo' => $this->echo, 'Nfo' => $this, 'Settings' => $this->pdo])]); $movie = new Movie(['Echo' => $this->echo, 'Settings' => $this->pdo]); $tvRage = new TvRage(['Echo' => $this->echo, 'Settings' => $this->pdo]); foreach ($res as $arr) { $fetchedBinary = $nzbContents->getNFOfromNZB($arr['guid'], $arr['id'], $arr['group_id'], $groups->getByNameByID($arr['group_id'])); if ($fetchedBinary !== false) { // Insert nfo into database. $cp = 'COMPRESS(%s)'; $nc = $this->pdo->escapeString($fetchedBinary); $ckreleaseid = $this->pdo->queryOneRow(sprintf('SELECT id FROM release_nfos WHERE releaseid = %d', $arr['id'])); if (!isset($ckreleaseid['id'])) { $this->pdo->queryInsert(sprintf('INSERT INTO release_nfos (nfo, releaseid) VALUES (' . $cp . ', %d)', $nc, $arr['id'])); } $this->pdo->queryExec(sprintf('UPDATE releases SET nfostatus = %d WHERE id = %d', self::NFO_FOUND, $arr['id'])); $ret++; $movie->doMovieUpdate($fetchedBinary, 'nfo', $arr['id'], $processImdb); // If set scan for tvrage info. if ($processTvrage == 1) { $rageId = $this->parseRageId($fetchedBinary); if ($rageId !== false) { $show = $tvRage->parseNameEpSeason($arr['name']); if (is_array($show) && $show['name'] != '') { // Update release with season, ep, and air date info (if available) from release title. $tvRage->updateEpInfo($show, $arr['id']); $rid = $tvRage->getByRageID($rageId); if (!$rid) { $tvrShow = $tvRage->getRageInfoFromService($rageId); $tvRage->updateRageInfo($rageId, $show, $tvrShow, $arr['id']); } } } } } } } // Remove nfo that we cant fetch after 5 attempts. $releases = $this->pdo->queryDirect(sprintf('SELECT r.id FROM releases r WHERE r.nzbstatus = %d AND r.nfostatus < %d %s %s', NZB::NZB_ADDED, $this->maxRetries, $groupIDQuery, $guidCharQuery)); if ($releases instanceof \Traversable) { foreach ($releases as $release) { $this->pdo->queryExec(sprintf('DELETE FROM release_nfos WHERE nfo IS NULL AND releaseid = %d', $release['id'])); } } // Set releases with no NFO. $this->pdo->queryExec(sprintf(' UPDATE releases r SET r.nfostatus = %d WHERE r.nzbstatus = %d AND r.nfostatus < %d %s %s', self::NFO_FAILED, NZB::NZB_ADDED, $this->maxRetries, $groupIDQuery, $guidCharQuery)); if ($this->echo) { if ($nfoCount > 0) { echo PHP_EOL; } if ($ret > 0) { $this->pdo->log->doEcho($ret . ' NFO file(s) found/processed.', true); } } return $ret; }
use nzedb\Releases; use nzedb\TvRage; if (!$page->users->isLoggedIn()) { $page->show403(); } if (!isset($_REQUEST["id"])) { $page->show404(); } $r = new Releases(['Settings' => $page->settings]); $rel = $r->getByGuid($_REQUEST["id"]); if (!$rel) { print "No tv info"; } else { //print "<h3 class=\"tooltiphead\">episode info...</h3>\n"; print "<ul>\n"; if (isset($rel['tvtitle'])) { print "<li>" . htmlentities($rel["tvtitle"], ENT_QUOTES) . "</li>\n"; } print "<li>Aired on " . date("F j, Y", strtotime($rel["tvairdate"])) . "</li>\n"; print "</ul>"; if ($rel["rageid"] > 0) { $t = new TvRage(['Settings' => $page->settings]); $rage = $t->getByRageID($rel["rageid"]); if (count($rage) > 0) { if ($rage[0]["imgdata"] != "") { print "<img class=\"shadow\" src=\"" . WWW_TOP . "/getimage?type=tvrage&id=" . $rage[0]["id"] . "\" width=\"180\"/>"; } } } }