/** * Default constructor * * @param bool $echooutput */ public function __construct($echooutput = false) { $this->echooutput = NN_ECHOCLI && $echooutput; $this->pdo = new Settings(); $this->pubkey = $this->pdo->getSetting('amazonpubkey'); $this->privkey = $this->pdo->getSetting('amazonprivkey'); $this->asstag = $this->pdo->getSetting('amazonassociatetag'); $this->imgSavePath = WWW_DIR . 'covers/console/'; }
/** * @param array $options Class instances / Echo to CLI. */ public function __construct(array $options = []) { $defaults = ['Echo' => false, 'Settings' => null]; $options += $defaults; $this->pdo = $options['Settings'] instanceof Settings ? $options['Settings'] : new Settings(); $this->rageqty = $this->pdo->getSetting('maxrageprocessed') != '' ? $this->pdo->getSetting('maxrageprocessed') : 75; $this->echooutput = $options['Echo'] && NN_ECHOCLI; $this->xmlEpisodeInfoUrl = "http://services.tvrage.com/myfeeds/tvrageepisodes.php?key=" . TvAnger::APIKEY; }
/** * @param array $options Class instances / Echo to cli. */ public function __construct(array $options = array()) { $defaults = ['Echo' => false, 'Settings' => null]; $options += $defaults; $this->echooutput = $options['Echo'] && NN_ECHOCLI; $this->pdo = $options['Settings'] instanceof Settings ? $options['Settings'] : new Settings(); $qty = $this->pdo->getSetting('maxanidbprocessed'); $this->aniqty = !empty($qty) ? $qty : 100; $this->status = 'NULL'; }
/** * Default constructor. * * @param newznab\db\Settings $pdo * * @access public */ public function __construct(&$pdo = null) { $this->pdo = $pdo instanceof Settings ? $pdo : new Settings(); $this->tablePerGroup = $this->pdo->getSetting('tablepergroup') == 0 ? false : true; $nzbSplitLevel = $this->pdo->getSetting('nzbsplitlevel'); $this->nzbSplitLevel = empty($nzbSplitLevel) ? 1 : $nzbSplitLevel; $this->siteNzbPath = (string) $this->pdo->getSetting('nzbpath'); if (substr($this->siteNzbPath, -1) !== DS) { $this->siteNzbPath .= DS; } }
/** * Construct. * * @param array $options * array( * 'Echo' => bool ; To echo to CLI or not. * 'NNTP' => NNTP ; Class NNTP. * 'Nfo' => Nfo ; Class Nfo. * 'NZB' => NZB ; Class NZB. * 'Settings' => DB ; Class newznab\db\Settings. * 'PostProcess' => PostProcess ; Class PostProcess. * ) * * @access public */ public function __construct(array $options = []) { $defaults = ['Echo' => false, 'NNTP' => null, 'Nfo' => null, 'NZB' => null, 'Settings' => null, 'PostProcess' => null]; $options += $defaults; $this->echooutput = $options['Echo'] && NN_ECHOCLI; $this->pdo = $options['Settings'] instanceof Settings ? $options['Settings'] : new Settings(); $this->nntp = $options['NNTP'] instanceof \NNTP ? $options['NNTP'] : new \NNTP(['Echo' => $this->echooutput, 'Settings' => $this->pdo]); $this->nfo = $options['Nfo'] instanceof \Nfo ? $options['Nfo'] : new \Nfo(['Echo' => $this->echooutput, 'Settings' => $this->pdo]); $this->pp = $options['PostProcess'] instanceof PostProcess ? $options['PostProcess'] : new PostProcess(['Echo' => $this->echooutput, 'Nfo' => $this->nfo, 'Settings' => $this->pdo]); $this->nzb = $options['NZB'] instanceof \NZB ? $options['NZB'] : new \NZB($this->pdo); $t = new Tmux(); $this->tmux = $t->get(); $this->lookuppar2 = $this->tmux->lookuppar2 == 1 ? true : false; $this->alternateNNTP = $this->pdo->getSetting('alternate_nntp') == 1 ? true : false; }
/** * Retrieve upcoming movie data from rottentomatoes API. */ public function updateUpcoming() { $rtkey = $this->pdo->getSetting('rottentomatokey'); if (isset($rtkey)) { $rt = new RottenTomato($this->pdo->getSetting('rottentomatokey')); $ret = $rt->getBoxOffice(); if ($ret != "") { $this->updateInsUpcoming('rottentomato', Movie::SRC_BOXOFFICE, $ret); } $ret = $rt->getInTheaters(); if ($ret != "") { $this->updateInsUpcoming('rottentomato', Movie::SRC_INTHEATRE, $ret); } $ret = $rt->getOpening(); if ($ret != "") { $this->updateInsUpcoming('rottentomato', Movie::SRC_OPENING, $ret); } $ret = $rt->getUpcoming(); if ($ret != "") { $this->updateInsUpcoming('rottentomato', Movie::SRC_UPCOMING, $ret); } $ret = $rt->getDvdReleases(); if ($ret != "") { $this->updateInsUpcoming('rottentomato', Movie::SRC_DVD, $ret); } } }
/** * Try to get media info xml from a video file. * * @param string $fileLocation * * @return bool */ protected function _getMediaInfo($fileLocation) { if (!$this->_processMediaInfo) { return false; } // Look for the video file. if (is_file($fileLocation)) { // Run media info on it. $xmlArray = Utility::runCmd($this->_killString . $this->pdo->getSetting('mediainfopath') . '" --Output=XML "' . $fileLocation . '"'); // Check if we got it. if (is_array($xmlArray)) { // Convert it to string. $xmlArray = implode("\n", $xmlArray); if (!preg_match('/<track type="(Audio|Video)">/i', $xmlArray)) { return false; } // Insert it into the DB. $this->_releaseExtra->addFull($this->_release['id'], $xmlArray); $this->_releaseExtra->addFromXml($this->_release['id'], $xmlArray); if ($this->_echoCLI) { $this->_echo('m', 'primaryOver', false); } return true; } } return false; }
/** * Retrieves supplemental anime info from the AniDB API * * @param int $id The AniDB id to be inserted * @param string $type The title type * @param string $lang The title language * @param string $title The title of the Anime * * @return array|bool */ private function getAniDbAPI() { $timestamp = $this->pdo->getSetting('banned') + 90000; if ($timestamp > time()) { echo "Banned from AniDB lookups until " . date('Y-m-d H:i:s', $timestamp) . "\n"; return false; } $apiresponse = $this->getAniDbResponse(); $AniDBAPIArray = array(); if (!$apiresponse) { echo "AniDB: Error getting response." . PHP_EOL; } elseif (preg_match("/\\<error\\>Banned\\<\\/error\\>/", $apiresponse)) { $this->banned = true; $time = time(); $this->pdo->queryExec(sprintf('UPDATE settings SET VALUE = %s WHERE setting = banned', $time)); } elseif (preg_match("/\\<error\\>Anime not found\\<\\/error\\>/", $apiresponse)) { echo "AniDB : Anime not yet on site. Remove until next update.\n"; } elseif ($AniDBAPIXML = new \SimpleXMLElement($apiresponse)) { $AniDBAPIArray['similar'] = $this->processAPIResponceElement($AniDBAPIXML->similaranime, 'anime'); $AniDBAPIArray['related'] = $this->processAPIResponceElement($AniDBAPIXML->relatedanime, 'anime'); $AniDBAPIArray['creators'] = $this->processAPIResponceElement($AniDBAPIXML->creators); $AniDBAPIArray['characters'] = $this->processAPIResponceElement($AniDBAPIXML->characters); $AniDBAPIArray['categories'] = $this->processAPIResponceElement($AniDBAPIXML->categories); if ($AniDBAPIXML->episodes && $AniDBAPIXML->episodes[0]->attributes()) { $i = 1; foreach ($AniDBAPIXML->episodes->episode as $episode) { $titleArray = array(); $episodeArray = array(); $episodeArray[$i]['episode_id'] = (int) $episode->attributes()->id[0]; $episodeArray[$i]['episode_no'] = (int) $episode->epno; $episodeArray[$i]['airdate'] = (string) $episode->airdate; if ($AniDBAPIXML->title && $AniDBAPIXML->title[0]->attributes()) { foreach ($AniDBAPIXML->title->children() as $title) { $xmlAttribs = $title->attributes('xml', true); // only english, x-jat imploded episode titles for now if (in_array($xmlAttribs->lang, ['en', 'x-jat'])) { $titleArray[] = $title[0]; } } } $episodeArray[$i]['episode_title'] = empty($titleArray) ? '' : implode(', ', $titleArray); $i++; } } $episodeArray = []; //start and end date come from AniDB API as date strings -- no manipulation needed $AniDBAPIArray['startdate'] = isset($AniDBAPIXML->startdate) ? $AniDBAPIXML->startdate : '0000-00-00'; $AniDBAPIArray['enddate'] = isset($AniDBAPIXML->enddate) ? $AniDBAPIXML->enddate : '0000-00-00'; if (isset($AniDBAPIXML->ratings->permanent)) { $AniDBAPIArray['rating'] = $AniDBAPIXML->ratings->permanent; } else { $AniDBAPIArray['rating'] = isset($AniDBAPIXML->ratings->temporary) ? $AniDBAPIXML->ratings->temporary : ($AniDBAPIArray['rating'] = ''); } $AniDBAPIArray += array('type' => isset($AniDBAPIXML->type[0]) ? (string) $AniDBAPIXML->type : '', 'description' => isset($AniDBAPIXML->description) ? (string) $AniDBAPIXML->description : '', 'picture' => isset($AniDBAPIXML->picture[0]) ? (string) $AniDBAPIXML->picture : '', 'epsarr' => $episodeArray); return $AniDBAPIArray; } return false; }
/** * Default constructor. * * @param array $options Class instance / echo to cli. * * @access public */ public function __construct(array $options = []) { $defaults = ['Echo' => false, 'Settings' => null]; $options += $defaults; $this->echo = $options['Echo'] && NN_ECHOCLI; $this->pdo = $options['Settings'] instanceof Settings ? $options['Settings'] : new Settings(); $this->nzbs = $this->pdo->getSetting('maxnfoprocessed') != '' ? (int) $this->pdo->getSetting('maxnfoprocessed') : 100; $this->maxsize = $this->pdo->getSetting('maxsizetoprocessnfo') != '' ? (int) $this->pdo->getSetting('maxsizetoprocessnfo') : 100; $this->maxsize = $this->maxsize > 0 ? 'AND size < ' . $this->maxsize * 1073741824 : ''; $this->minsize = $this->pdo->getSetting('minsizetoprocessnfo') != '' ? (int) $this->pdo->getSetting('minsizetoprocessnfo') : 100; $this->minsize = $this->minsize > 0 ? 'AND size > ' . $this->minsize * 1048576 : ''; $this->maxRetries = (int) ($this->pdo->getSetting('maxnforetries') >= 0 ? -((int) $this->pdo->getSetting('maxnforetries') + 1) : self::NFO_UNPROC); $this->maxRetries = $this->maxRetries < -8 ? -8 : $this->maxRetries; $this->tmpPath = (string) $this->pdo->getSetting('tmpunrarpath'); if (!preg_match('/[\\/\\\\]$/', $this->tmpPath)) { $this->tmpPath .= DS; } }
/** * Get nzpre data from usenet and parse. */ public function nzpreUpdate() { if (empty($this->pdo->getSetting('nzpregroup')) || empty($this->pdo->getSetting('nzpresubject')) || empty($this->pdo->getSetting('nzpreposter')) || empty($this->pdo->getSetting('nzprefield')) || empty($this->pdo->getSetting('nzprekey'))) { return false; } if ($this->echooutput) { echo "Predb : Checking for new pre data "; } $nntp = new NNTP(); if (!$nntp->doConnect()) { echo "Failed to get NNTP connection\n"; return false; } $ret = $groupData = $nntp->selectGroup($this->pdo->getSetting('nzpregroup')); if ($nntp->isError($ret)) { echo "Predb : Error " . $ret->getMessage() . "\n"; return false; } $ret = $groupMsgs = $nntp->getOverview($groupData['last'] - (!empty($this->pdo->getSetting('nzprearticles')) ? $this->pdo->getSetting('nzprearticles') : 500) . '-' . $groupData['last']); if ($nntp->isError($ret)) { echo "Predb : Error " . $ret->getMessage() . "\n"; return false; } $added_updated = 0; $nzprekey = $this->pdo->getSetting('nzprekey'); while (strlen($nzprekey) < 1024) { $nzprekey = $nzprekey . $nzprekey; } $cnt = !empty($this->pdo->getSetting('nzprearticles')) ? $this->pdo->getSetting('nzprearticles') : 500; foreach ($groupMsgs as $groupMsg) { if ($cnt % 50 == 0 && $cnt != 0 && $this->echooutput) { echo $cnt . ".."; } $cnt--; if (preg_match('/^' . $this->pdo->getSetting('nzpresubject') . '$/', $groupMsg['Subject']) && preg_match('/^' . $this->pdo->getSetting('nzpreposter') . '/', $groupMsg['From'])) { $ret = $msgHeader = $nntp->getHeader($groupMsg['Message-ID']); if ($nntp->isError($ret)) { continue; } for ($i = 0; $i < count($msgHeader); $i++) { if (preg_match('/^' . $this->pdo->getSetting('nzprefield') . ': /', $msgHeader[$i])) { if ($nzpreParse = $this->nzpreParse(str_replace($this->pdo->getSetting('nzprefield') . ': ', '', $msgHeader[$i]), $nzprekey)) { if ($this->updatePreDB($this->pdo, $nzpreParse)) { $added_updated++; } } break; } } } } $nntp->disconnect(); if ($this->echooutput) { echo "\nPredb : Added/Updated " . $added_updated . " records\n"; } }
/** * @param array $options Class instances / Echo to cli. */ public function __construct(array $options = array()) { $defaults = ['Echo' => false, 'ColorCLI' => null, 'Settings' => null]; $options += $defaults; $this->echoOutput = $options['Echo'] && NN_ECHOCLI; $this->pdo = $options['Settings'] instanceof Settings ? $options['Settings'] : new Settings(); $this->publicKey = $this->pdo->getSetting('giantbombkey'); $this->gameQty = $this->pdo->getSetting('maxgamesprocessed') != '' ? $this->pdo->getSetting('maxgamesprocessed') : 150; $this->sleepTime = $this->pdo->getSetting('amazonsleep') != '' ? $this->pdo->getSetting('amazonsleep') : 1000; $this->imgSavePath = NN_COVERS . 'games' . DS; $this->renamed = ''; $this->matchPercentage = 60; $this->maxHitRequest = false; $this->cookie = NN_TMP . 'xxx.cookie'; if ($this->pdo->getSetting('lookupgames') == 2) { $this->renamed = 'AND isrenamed = 1'; } //$this->cleangames = ($this->site->('lookupgames') == 2) ? 'AND isrenamed = 1' : ''; }
/** * @param array $options Echo to cli / Class instances. */ public function __construct(array $options = []) { $defaults = ['Echo' => false, 'ReleaseImage' => null, 'Settings' => null]; $options += $defaults; $this->pdo = $options['Settings'] instanceof Settings ? $options['Settings'] : new Settings(); $this->releaseImage = $options['ReleaseImage'] instanceof ReleaseImage ? $options['ReleaseImage'] : new ReleaseImage($this->pdo); $this->movieqty = $this->pdo->getSetting('maxxxxprocessed') != '' ? $this->pdo->getSetting('maxxxxprocessed') : 100; $this->showPasswords = Releases::showPasswords($this->pdo); $this->debug = NN_DEBUG; $this->echooutput = $options['Echo'] && NN_ECHOCLI; $this->imgSavePath = NN_COVERS . 'xxx' . DS; $this->cookie = NN_TMP . 'xxx.cookie'; if (NN_DEBUG || NN_LOGGING) { $this->debug = true; try { $this->debugging = new \Logger(); } catch (\LoggerException $error) { $this->_debug = false; } } }
/** * Process untagged music releases using information from mediainfo if config permits. */ public function processMusicFromMediaInfo() { $processMediainfo = $this->pdo->getSetting('mediainfopath') != '' ? true : false; $processAudioSample = $this->pdo->getSetting('saveaudiopreview') == 1 ? true : false; $processMusic = $this->pdo->getSetting('lookupmusic') == 1 ? true : false; if ($processMusic && $processMediainfo && $processAudioSample) { $music = new Music($this->echooutput); $ret = $music->processMusicReleaseFromMediaInfo(); return $ret; } return false; }
/** * Add a release_comments row. */ public function addComment($id, $gid, $text, $userid, $host) { if (strlen(trim($text)) == 0) { return false; } if ($this->pdo->getSetting('storeuserips') != "1") { $host = ""; } $comid = $this->pdo->queryInsert(sprintf("INSERT INTO release_comments (releaseid, gid, text, userid, createddate, host) VALUES (%d, %s, %s, %d, now(), %s)", $id, $this->pdo->escapeString($gid), $this->pdo->escapeString($text), $userid, $this->pdo->escapeString($host))); $this->updateReleaseCommentCount($gid); return $comid; }
/** * @param array $options Class instances/ echo to CLI. */ public function __construct(array $options = []) { $defaults = ['Echo' => false, 'Settings' => null]; $options += $defaults; $this->echooutput = $options['Echo'] && NN_ECHOCLI; $this->pdo = $options['Settings'] instanceof Settings ? $options['Settings'] : new Settings(); $this->pubkey = $this->pdo->getSetting('amazonpubkey'); $this->privkey = $this->pdo->getSetting('amazonprivkey'); $this->asstag = $this->pdo->getSetting('amazonassociatetag'); $this->musicqty = $this->pdo->getSetting('maxmusicprocessed') != '' ? $this->pdo->getSetting('maxmusicprocessed') : 150; $this->sleeptime = $this->pdo->getSetting('amazonsleep') != '' ? $this->pdo->getSetting('amazonsleep') : 1000; $this->imgSavePath = NN_COVERS . 'music' . DS; $this->renamed = ''; if ($this->pdo->getSetting('lookupmusic') == 2) { $this->renamed = 'AND isrenamed = 1'; } $this->failCache = []; }
/** * Construct. * * @param array $options Class instances / various options. * * @access public */ public function __construct(array $options = []) { $defaults = ['Browser' => false, 'Echo' => true, 'Binaries' => null, 'Categorize' => null, 'NZB' => null, 'ReleaseCleaning' => null, 'Releases' => null, 'Settings' => null]; $options += $defaults; $this->echoCLI = !$this->browser && NN_ECHOCLI && $options['Echo']; $this->pdo = $options['Settings'] instanceof Settings ? $options['Settings'] : new Settings(); $this->binaries = $options['Binaries'] instanceof Binaries ? $options['Binaries'] : new Binaries(['Settings' => $this->pdo, 'Echo' => $this->echoCLI]); $this->category = $options['Categorize'] instanceof Categorize ? $options['Categorize'] : new Categorize(['Settings' => $this->pdo]); $this->nzb = $options['NZB'] instanceof NZB ? $options['NZB'] : new NZB($this->pdo); $this->releaseCleaner = $options['ReleaseCleaning'] instanceof ReleaseCleaning ? $options['ReleaseCleaning'] : new ReleaseCleaning($this->pdo); $this->releases = $options['Releases'] instanceof Releases ? $options['Releases'] : new Releases(['settings' => $this->pdo]); $this->crossPostt = $this->pdo->getSetting('crossposttime') != '' ? $this->pdo->getSetting('crossposttime') : 2; $this->browser = $options['Browser']; $this->retVal = ''; $this->groups = new Groups(['Settings' => $this->pdo]); }
/** * Constructor. * * @param array $options Class instances / Echo to cli? */ public function __construct(array $options = []) { $defaults = ['Echo' => true, 'Logger' => null, 'Groups' => null, 'NNTP' => null, 'Settings' => null]; $options += $defaults; $this->_echoCLI = $options['Echo'] && NN_ECHOCLI; $this->pdo = $options['Settings'] instanceof Settings ? $options['Settings'] : new Settings(); $this->_groups = $options['Groups'] instanceof Groups ? $options['Groups'] : new Groups(['Settings' => $this->pdo]); $this->_nntp = $options['NNTP'] instanceof NNTP ? $options['NNTP'] : new NNTP(['Settings' => $this->pdo]); $this->_debug = NN_LOGGING || NN_DEBUG; if ($this->_debug) { try { $this->_debugging = $options['Logger'] instanceof Logger ? $options['Logger'] : new Logger(['ColorCLI' => $this->pdo->log]); } catch (\LoggerException $error) { $this->_debug = false; } } $this->_compressedHeaders = $this->pdo->getSetting('compressedheaders') == 1 ? true : false; $this->_safeBackFillDate = $this->pdo->getSetting('safebackfilldate') != '' ? (string) $this->pdo->getSetting('safebackfilldate') : '2008-08-14'; $this->_safePartRepair = $this->pdo->getSetting('safepartrepair') == 1 ? 'update' : 'backfill'; $this->_tablePerGroup = $this->pdo->getSetting('tablepergroup') == 1 ? true : false; $this->_disableBackfillGroup = $this->pdo->getSetting('disablebackfillgroup') == 1 ? true : false; }
/** * Constructor. * * @param array $options Class instances / echo to CLI? */ public function __construct(array $options = []) { $defaults = ['Echo' => true, 'ColorCLI' => null, 'Logger' => null, 'Groups' => null, 'NNTP' => null, 'Settings' => null]; $options += $defaults; $this->_colorCLI = $options['ColorCLI'] instanceof \ColorCLI ? $options['ColorCLI'] : new \ColorCLI(); $this->_echoCLI = $options['Echo'] && NN_ECHOCLI; $this->_pdo = $options['Settings'] instanceof Settings ? $options['Settings'] : new Settings(); $this->_nntp = $options['NNTP'] instanceof \NNTP ? $options['NNTP'] : new \NNTP(['Echo' => $this->_colorCLI, 'Settings' => $this->_pdo, 'ColorCLI' => $this->_colorCLI]); $this->_groups = $options['Groups'] instanceof \Groups ? $options['Groups'] : new \Groups(['Settings' => $this->_pdo]); $this->_debug = NN_DEBUG || NN_LOGGING; if ($this->_debug) { try { $this->_debugging = new \Logger(['ColorCLI' => $this->_colorCLI]); } catch (\LoggerException $error) { $this->_debug = false; } } $this->n = "\n"; $this->messageBuffer = $this->_pdo->getSetting('maxmssgs') != '' ? $this->_pdo->getSetting('maxmssgs') : 20000; $this->_compressedHeaders = $this->_pdo->getSetting('compressedheaders') == "1" ? true : false; $this->MaxMsgsPerRun = !empty($this->_pdo->getSetting('maxmsgsperrun')) ? $this->_pdo->getSetting('maxmsgsperrun') : 200000; $this->_newGroupScanByDays = $this->_pdo->getSetting('newsgroupscanmethod') == "1" ? true : false; $this->_newGroupMessagesToScan = !empty($this->_pdo->getSetting('newgroupmsgstoscan')) ? $this->_pdo->getSetting('newgroupmsgstoscan') : 50000; $this->_newGroupDaysToScan = !empty($this->_pdo->getSetting('newgroupdaystoscan')) ? $this->_pdo->getSetting('newgroupdaystoscan') : 3; $this->_tablePerGroup = $this->_pdo->getSetting('tablepergroup') == 1 ? true : false; $this->_partRepair = $this->_pdo->getSetting('partrepair') == 0 ? false : true; $this->_partRepairLimit = $this->_pdo->getSetting('maxpartrepair') != '' ? (int) $this->_pdo->getSetting('maxpartrepair') : 15000; $this->_partRepairMaxTries = $this->_pdo->getSetting('partrepairmaxtries') != '' ? (int) $this->_pdo->getSetting('partrepairmaxtries') : 3; $this->blackList = array(); //cache of our black/white list $this->blackList_by_group = array(); $this->message = array(); $this->startUpdate = microtime(true); $this->startLoop = microtime(true); $this->startHeaders = microtime(true); $this->onlyProcessRegexBinaries = false; $this->blackList = $this->whiteList = []; }
use newznab\db\Settings; use newznab\processing\PProcess; $pdo = new Settings(); /** Array with possible arguments for run and whether or not those methods of operation require NNTP **/ $args = array('additional' => true, 'all' => true, 'allinf' => true, 'amazon' => false, 'anime' => false, 'book' => false, 'console' => false, 'games' => false, 'movies' => false, 'music' => false, 'nfo' => true, 'pre' => true, 'sharing' => true, 'spotnab' => true, 'tv' => false, 'tvdb' => false, 'xxx' => false); $bool = array('true', 'false'); if (!isset($argv[1]) || !in_array($argv[1], $args) || !isset($argv[2]) || !in_array($argv[2], $bool)) { exit($pdo->log->error("\nIncorrect arguments.\n" . "The second argument (true/false) determines wether to echo or not.\n\n" . "php postprocess.php all true ...: Does all the types of post processing.\n" . "php postprocess.php pre true ...: Processes all Predb sites.\n" . "php postprocess.php nfo true ...: Processes NFO files.\n" . "php postprocess.php movies true ...: Processes movies.\n" . "php postprocess.php music true ...: Processes music.\n" . "php postprocess.php console true ...: Processes console games.\n" . "php postprocess.php games true ...: Processes games.\n" . "php postprocess.php book true ...: Processes books.\n" . "php postprocess.php anime true ...: Processes anime.\n" . "php postprocess.php tv true ...: Processes tv.\n" . "php postprocess.php tvdb true ...: Processes tvdb.\n" . "php postprocess.php xxx true ...: Processes xxx.\n" . "php postprocess.php additional true ...: Processes previews/mediainfo/etc...\n" . "php postprocess.php sharing true ...: Processes uploading/downloading comments.\n" . "php postprocess.php spotnab true ...: Processes uploading/downloading comments from spotnab.\n" . "php postprocess.php allinf true ...: Does all the types of post processing on a loop, sleeping 15 seconds between.\n" . "php postprocess.php amazon true ...: Does all the amazon (books/console/games/music/xxx).\n")); } $nntp = null; if ($args[$argv[1]] === true) { $nntp = new NNTP(['Settings' => $pdo]); if (($pdo->getSetting('alternate_nntp') == 1 ? $nntp->doConnect(true, true) : $nntp->doConnect()) !== true) { exit($pdo->log->error("Unable to connect to usenet." . PHP_EOL)); } } $postProcess = new PProcess(['Settings' => $pdo, 'Echo' => $argv[2] === 'true' ? true : false]); $charArray = ['a', 'b', 'c', 'd', 'e', 'f', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9']; switch ($argv[1]) { case 'all': $postProcess->processAll($nntp); break; case 'allinf': $i = 1; while ($i = 1) { $postProcess->processAll($nntp); sleep(15); }
/** * Set up session / smarty / user variables. */ public function __construct() { $this->https = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? true : false; session_set_cookie_params(0, '/', '', $this->https, true); @session_start(); if (NN_FLOOD_CHECK) { $this->floodCheck(); } if (function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc() || ini_get('magic_quotes_sybase')) { $this->stripSlashes($_GET); $this->stripSlashes($_POST); $this->stripSlashes($_REQUEST); $this->stripSlashes($_COOKIE); } // Buffer settings/DB connection. $this->settings = new Settings(); $this->smarty = new Smarty(); $this->smarty->setTemplateDir(['user_frontend' => NN_WWW . 'templates/' . $this->settings->getSetting('style') . '/views/frontend', 'frontend' => NN_WWW . 'templates/default/views/frontend']); $this->smarty->setCompileDir(SMARTY_DIR . 'templates_c' . DIRECTORY_SEPARATOR); $this->smarty->setConfigDir(SMARTY_DIR . 'configs' . DIRECTORY_SEPARATOR); $this->smarty->setCacheDir(SMARTY_DIR . 'cache' . DIRECTORY_SEPARATOR); $this->smarty->error_reporting = NN_DEBUG ? E_ALL : E_ALL - E_NOTICE; $this->secure_connection = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == 443; if (isset($_SERVER['SERVER_NAME'])) { $this->serverurl = ($this->https === true ? 'https://' : 'http://') . $_SERVER['SERVER_NAME'] . ($_SERVER['SERVER_PORT'] != '80' && $_SERVER['SERVER_PORT'] != '443' ? ':' . $_SERVER['SERVER_PORT'] : '') . WWW_TOP . '/'; $this->smarty->assign('serverroot', $this->serverurl); } $this->page = isset($_GET['page']) ? $_GET['page'] : 'content'; $this->users = new Users(['Settings' => $this->settings]); if ($this->users->isLoggedIn()) { $this->userdata = $this->users->getById($this->users->currentUserId()); $this->userdata["categoryexclusions"] = $this->users->getCategoryExclusion($this->users->currentUserId()); // Change the theme to user's selected theme if they selected one, else use the admin one. if ($this->settings->getSetting('userselstyle') == 1) { if (isset($this->userdata['style']) && $this->userdata['style'] !== 'None') { $this->smarty->setTemplateDir(['user_frontend' => NN_WWW . 'templates/' . $this->userdata['style'] . '/views/frontend', 'frontend' => NN_WWW . 'templates/default/views/frontend']); } } //update lastlogin every 15 mins if (strtotime($this->userdata['now']) - 900 > strtotime($this->userdata['lastlogin'])) { $this->users->updateSiteAccessed($this->userdata['id']); } $this->smarty->assign('userdata', $this->userdata); $this->smarty->assign('loggedin', "true"); if ($this->userdata['nzbvortex_api_key'] != '' && $this->userdata['nzbvortex_server_url'] != '') { $this->smarty->assign('weHasVortex', true); } else { $this->smarty->assign('weHasVortex', false); } $sab = new SABnzbd($this); $this->smarty->assign('sabintegrated', $sab->integratedBool); if ($sab->integratedBool !== false && $sab->url != '' && $sab->apikey != '') { $this->smarty->assign('sabapikeytype', $sab->apikeytype); } switch ((int) $this->userdata['role']) { case Users::ROLE_ADMIN: $this->smarty->assign('isadmin', 'true'); break; case Users::ROLE_MODERATOR: $this->smarty->assign('ismod', 'true'); } if ($this->userdata["hideads"] == "1") { $this->settings->setSetting(['adheader', '']); $this->settings->setSetting(['adbrowse', '']); $this->settings->setSetting(['addetail', '']); } $this->floodCheck($this->userdata["role"]); } else { $this->smarty->assign('isadmin', 'false'); $this->smarty->assign('ismod', 'false'); $this->smarty->assign('loggedin', 'false'); $this->floodCheck(); } $this->smarty->assign('site', $this->settings); $this->smarty->assign('page', $this); }
<?php /* Filesize Fix Script If after import you have a bunch of zero sized releases run this Author: lordgnu <*****@*****.**> */ require_once dirname(__FILE__) . '/../../www/config.php'; use newznab\db\Settings; $pdo = new Settings(); $nzb = new NZB(); $items = $pdo->query("SELECT id,guid FROM releases WHERE size = 0"); $total = count($items); $compl = 0; echo "Updating file size for " . count($items) . " release(s)\n"; while ($item = array_pop($items)) { $nzbpath = $nzb->getNZBPath($item['guid'], $pdo->getSetting('nzbpath')); ob_start(); @readgzfile($nzbpath); $nzbfile = ob_get_contents(); ob_end_clean(); $ret = $nzb->nzbFileList($nzbfile); $filesize = '0'; foreach ($ret as $file) { $filesize = bcadd($filesize, $file['size']); } $pdo->queryExec("UPDATE releases SET size = '{$filesize}' WHERE id = '{$item['id']}' LIMIT 1"); $compl++; echo sprintf("[%6d / %6d] %0.2f", $compl, $total, $compl / $total * 100) . '%' . "\n"; }
/** * Performing parsing. */ public function process() { // Default query for both full db and last 4 hours. $sql = "SELECT r.searchname, r.name, r.fromname, r.id as rid, r.categoryid, r.guid, r.postdate,\n\t\t\t rn.id as nfoid,\n\t\t\t g.name as groupname,\n\t\t\t GROUP_CONCAT(rf.name) as filenames\n\t\tFROM releases r\n\t\tLEFT JOIN releasenfo rn ON (rn.releaseid = r.id)\n\t\tLEFT JOIN groups g ON (g.id = r.groupid)\n\t\tLEFT JOIN releasefiles rf ON (rf.releaseid = r.id)\n\t\tWHERE r.categoryid in (' . Category::CAT_TV_OTHER . ',' . Category::CAT_MOVIE_OTHER . ',' . Category::CAT_MISC_OTHER . ',' . Category::CAT_XXX_OTHER . ')\n\t\t%s\n\t\tGROUP BY r.id"; $res = $this->pdo->query(sprintf($sql, $this->limited ? "AND r.adddate BETWEEN NOW() - INTERVAL 4 HOUR AND NOW()" : "")); $this->releasestocheck = sizeof($res); if ($res) { echo "PostPrc : Parsing last " . $this->releasestocheck . " releases in the Other-Misc categories\n"; foreach ($res as $rel) { $tempname = $foundName = $methodused = ''; //Knoc.One if (preg_match("/KNOC.ONE/i", $rel['name'])) { $title = ''; $items = preg_split("/(\\.| )/", $rel['name']); foreach ($items as $value) { if (preg_match("/^[a-z]+\$/i", $value)) { $len = strlen($value); if ($len > 2) { $title .= substr($value, -2) . substr($value, 0, -2) . " "; } elseif ($len = 2) { $title .= substr($value, -1) . substr($value, 0, -1) . " "; } else { $title .= $value . " "; } } else { $title .= $value . " "; } } $foundName = $title; $methodused = "Knoc.One"; $this->determineCategory($rel, $foundName, $methodused); } /// ///Use the Nfo to try to get the proper Releasename. /// $nfo = $this->pdo->queryOneRow(sprintf("select uncompress(nfo) as nfo from releasenfo where releaseid = %d", $rel['rid'])); if ($nfo && $foundName == "") { $this->nfosprocessed++; $nfo = $nfo['nfo']; //LOUNGE releases if (preg_match('/([a-z0-9.]+\\.MBLURAY)/i', $nfo, $matches)) { $foundName = $matches[1]; $methodused = "LOUNGE"; $this->determineCategory($rel, $foundName, $methodused); } //AsianDVDClub releases if (preg_match('/adc-[a-z0-9]{1,10}/', $rel['name'])) { if (preg_match('/.*\\(\\d{4}\\).*/i', $nfo, $matches)) { $foundName = $matches[0]; $methodused = "AsianDVDClub"; $this->determineCategory($rel, $foundName, $methodused); } } //ACOUSTiC releases if (preg_match('/ACOUSTiC presents \\.\\.\\..*?([a-z0-9].*?\\(.*?\\))/is', $nfo, $matches)) { $foundName = $matches[1] . ".MBLURAY"; $methodused = "ACOUSTiC "; $this->determineCategory($rel, $foundName, $methodused); } //Japhson releases if (preg_match('/Japhson/i', $nfo, $matches)) { $movie = new Movie(); $imdbID = null; if (preg_match('/tt(\\d{7})/i', $nfo, $matches)) { $imdbId = $matches[1]; $movCheck = $movie->fetchImdbProperties($imdbId); $foundName = $movCheck['title']; if (!preg_match('/(19|20)\\d{2}/i', $foundName)) { $foundName = $foundName . "." . $movCheck['year']; } if (preg_match('/language.*?\\b([a-z0-9]+)\\b/i', $nfo, $matches)) { if (!preg_match('/English/i', $matches[1])) { $foundName = $foundName . "." . $matches[1]; } } if (preg_match('/audio.*?\\b(\\w+)\\b/i', $nfo, $matches)) { if (preg_match('/(Chinese|German|Dutch|Spanish|Hebrew|Finnish|Norwegian)/i', $matches[1])) { $foundName = $foundName . "." . $matches[1]; } } if (preg_match('/(video|resolution|video res).*?(1080|720|816|820|272|1280 @|528|1920)/i', $nfo, $matches)) { if ($matches[2] == '1280 @') { $matches[2] = '720'; } if ($matches[2] == '1920') { $matches[2] = '1080'; } $foundName = $foundName . "." . $matches[2]; } if (preg_match('/source.*?\\b(DVD9|DVD5|BDRIP|DVD\\-?RIP|BLURAY)\\b/i', $nfo, $matches)) { $foundName = $foundName . "." . $matches[1]; } if (preg_match('/(video|resolution|video res).*?(XVID|X264|WMV)/i', $nfo, $matches)) { $foundName = $foundName . "." . $matches[2]; } if (preg_match('/audio.*?\\b(DTS|AC3)\\b/i', $nfo, $matches)) { $foundName = $foundName . "." . $matches[1]; } $foundName = $foundName . "-Japhson"; $methodused = "Japhson"; $this->determineCategory($rel, $foundName, $methodused); } } //AIHD releases if (preg_match('/ALWAYS iN HiGH/i', $nfo, $matches)) { $movie = new Movie(); $imdbID = null; if (preg_match('/tt(\\d{7})/i', $nfo, $matches)) { $imdbId = $matches[1]; $movCheck = $movie->fetchImdbProperties($imdbId); $foundName = $movCheck['title']; if (!preg_match('/(19|20)\\d{2}/i', $foundName)) { $foundName = $foundName . "." . $movCheck['year']; } if (preg_match('/L\\.([a-z0-9]+)\\b/i', $nfo, $matches)) { if (!preg_match('/En/i', $matches[1])) { $foundName = $foundName . "." . $matches[1]; } } if (preg_match('/(V).*?(1080|720|816|820|272|1280 @|528|1920)/i', $nfo, $matches)) { if ($matches[2] == '1280 @') { $matches[2] = '720'; } if ($matches[2] == '1920') { $matches[2] = '1080'; } $foundName = $foundName . "." . $matches[2]; } if (preg_match('/V.*?\\b(DVD9|DVD5|BDRIP|DVD\\-?RIP|BLURAY)\\b/i', $nfo, $matches)) { $foundName = $foundName . "." . $matches[1]; } if (preg_match('/(V).*?(XVID|X264|WMV)/i', $nfo, $matches)) { $foundName = $foundName . "." . $matches[2]; } if (preg_match('/A.*?\\b(DTS|AC3)\\b/i', $nfo, $matches)) { $foundName = $foundName . "." . $matches[1]; } $foundName = $foundName . "-AIHD"; $methodused = "AIHD"; $this->determineCategory($rel, $foundName, $methodused); } } //IMAGiNE releases if (preg_match('/\\*\\s+([a-z0-9]+(?:\\.|_| )[a-z0-9\\.\\_\\- ]+ \\- imagine)\\s+\\*/i', $nfo, $matches)) { $foundName = $matches[1]; $methodused = "imagine"; $this->determineCategory($rel, $foundName, $methodused); } //LEGION releases if (preg_match('/([a-z0-9 \\.\\-]+LEGi0N)/is', $nfo, $matches) && $foundName == "") { $foundName = $matches[1]; $methodused = "Legion"; $this->determineCategory($rel, $foundName, $methodused); } //SWAGGER releases if (preg_match('/(S W A G G E R|swg.*?nfo)/i', $nfo) && $foundName == "") { if (preg_match('/presents.*?([a-z0-9].*?\\((19|20)\\d{2}\\))/is', $nfo, $matches)) { $foundName = $matches[1]; } if (preg_match('/language.*?\\b([a-z0-9]+)\\b/i', $nfo, $matches)) { if ($matches[1] != "english") { $foundName = $foundName . "." . $matches[1]; } } if (preg_match('/resolution.*?(1080|720)/i', $nfo, $matches)) { $foundName = $foundName . ".BluRay." . $matches[1]; } if (preg_match('/video.*?\\b([a-z0-9]+)\\b/i', $nfo, $matches)) { $foundName = $foundName . "." . $matches[1]; } if (preg_match('/audio.*?\\b([a-z0-9]+)\\b/i', $nfo, $matches)) { $foundName = $foundName . "." . $matches[1]; } $foundName = $foundName . "-SWAGGER"; $methodused = "SWAGGER"; $this->determineCategory($rel, $foundName, $methodused); } //cm8 releases if (preg_match('/([a-z0-9]+(?:\\.|_| )[a-z0-9\\.\\_\\- \'\\)\\(]+\\-(futv|crimson|qcf|runner|clue|ftp|episode|momentum|PFA|topaz|vision|tdp|haggis|nogrp|shirk|imagine|santi|sys|deimos|ltu|ficodvdr|cm8|dvdr|Nodlabs|aaf|sprinter|exvid|flawl3ss|rx|magicbox|done|unveil))\\b/i', $nfo, $matches) && $foundName == "") { //echo "this: ".$matches[1]."\n"; $foundName = $matches[1]; $methodused = "cm8"; $this->determineCategory($rel, $foundName, $methodused); } //river if (preg_match('/([a-z0-9\\.\\_\\-]+\\-(webios|river|w4f|sometv|ngchd|C4|gf|bov|26k|ftw))\\b/i', $nfo, $matches) && $foundName == "") { $foundName = $matches[1]; $methodused = "river-1"; $this->determineCategory($rel, $foundName, $methodused); } if (preg_match('/([a-z0-9]+(?:\\.|_| )[a-z0-9\\.\\_\\- \'\\)\\(]+\\-(CiA|Anarchy|RemixHD|FTW|Revott|WAF|CtrlHD|Telly|Nif|Line|NPW|Rude|EbP|CRisC|SHK|AssAss1ns|Leverage|BBW|NPW))\\b/i', $nfo, $matches) && $foundName == "") { $foundName = $matches[1]; $methodused = "river-2"; $this->determineCategory($rel, $foundName, $methodused); } if (preg_match('/([a-z0-9]+(?:\\.|_| )[a-z0-9\\.\\_\\- \'\\)\\(]+\\-(XPD|RHyTM))\\b/i', $nfo, $matches) && $foundName == "") { $foundName = $matches[1]; $methodused = "river-3"; $this->determineCategory($rel, $foundName, $methodused); } if (preg_match('/(-PROD$|-BOV$|-NMR$|$-HAGGiS|-JUST$|CRNTV$|-MCA$|int$|-DEiTY$|-VoMiT$|-iNCiTE$|-BRUTUS$|-DCN$|-saints$|-sfm$|-lol$|-fov$|-logies$|-c4tv$|-fqm$|-jetset$|-ils$|-miragetv$|-gfvid$|-btl$|-terra$)/i', $rel['searchname']) && $foundName == "") { $foundName = $rel['searchname']; $methodused = "river-4"; $this->determineCategory($rel, $foundName, $methodused); } //SANTi releases if (preg_match('/\\b([a-z0-9]+(?:\\.|_| )[a-z0-9\\.\\_\\- \']+\\-santi)\\b/i', $nfo, $matches) && $foundName == "") { $foundName = $matches[1]; $methodused = "SANTi"; $this->determineCategory($rel, $foundName, $methodused); } //INSPiRAL releases if (preg_match('/^([a-z0-9]+(?:\\.|_| )[a-z0-9\\.\\_\\- ]+ \\- INSPiRAL)\\s+/im', $nfo, $matches) && $foundName == "") { $foundName = $matches[1]; $methodused = "INSPiRAL"; $this->determineCategory($rel, $foundName, $methodused); } //CIA releases if (preg_match('/Release NAME.*?\\:.*?([a-z0-9][a-z0-9\\.\\ ]+)\\b.*?([a-z0-9][a-z0-9\\.\\ ]+\\-CIA)\\b/is', $nfo, $matches) && $foundName == "") { $foundName = $matches[1] . $matches[2]; $methodused = "CIA"; $this->determineCategory($rel, $foundName, $methodused); } //HDChina releases if (preg_match('/HDChina/', $nfo) && $foundName == "") { if (preg_match('/Disc Title\\:.*?\\b([a-z0-9\\ \\.\\-\\_()]+\\-HDChina)/i', $nfo, $matches)) { $foundName = $matches[1]; $methodused = "HDChina"; $this->determineCategory($rel, $foundName, $methodused); } } //Pringles if (preg_match('/PRiNGLES/', $nfo) && $foundName == "") { if (preg_match('/is giving you.*?\\b([a-z0-9 ]+)\\s/i', $nfo, $matches)) { $foundName = $matches[1]; $foundName = rtrim($foundName); $foundName = ltrim($foundName); } if (preg_match('/this release.*?((19|20)\\d{2})/i', $nfo, $matches)) { $foundName = $foundName . "." . $matches[1]; $foundName = rtrim($foundName); } if (preg_match('/\\[x\\] (Danish|Norwegian|Swedish|Finish|Other)/i', $nfo, $matches)) { $foundName = $foundName . "." . $matches[1]; } if (preg_match('/\\[x\\] (DVD9|DVD5)/i', $nfo, $matches)) { $foundName = $foundName . "." . $matches[1]; } $foundName = $foundName . "-PRiNGLES"; $methodused = "Pringles"; $this->determineCategory($rel, $foundName, $methodused); } //Fairlight releases if (preg_match('/\\/Team FairLight/', $nfo) && $foundName == "") { $title = null; $os = null; $method = null; if (preg_match('/\\b([a-z0-9\\ \\- \\_()\\.]+) \\(c\\)/i', $nfo, $matches)) { $title = $matches['1']; $foundName = $title; } $foundName = $foundName . "-FLT"; $methodused = "FairLight"; $this->determineCategory($rel, $foundName, $methodused); } //CORE releases if (preg_match('/Supplied.*?\\:.*?(CORE)/', $nfo) || preg_match('/Packaged.*?\\:.*?(CORE)/', $nfo) && $foundName == "") { $title = null; $os = null; $method = null; if (preg_match('/\\b([a-z0-9\\.\\-\\_\\+\\ ]+) \\*[a-z0-9]+\\*/i', $nfo, $matches)) { $title = $matches['1']; $foundName = $title; } if (preg_match('/Crack\\/.*?\\:.*?([a-z]+)/i', $nfo, $matches)) { $method = $matches['1']; $foundName = $foundName . " " . $method; } if (preg_match('/OS.*?\\:.*?([a-z]+)/i', $nfo, $matches)) { $os = $matches['1']; $foundName = $foundName . " " . $os; } $foundName = $foundName . "-CORE"; $methodused = "CORE"; $this->determineCategory($rel, $foundName, $methodused); } //CompleteRelease if (preg_match('/Complete name.*?([a-z0-9].*?\\-[a-z0-9]+)\\b/i', $nfo, $matches) && $foundName == "") { $foundName = $matches[1]; $methodused = "CompleteRelease"; $this->determineCategory($rel, $foundName, $methodused); } //Livesets if (preg_match('/\\nLivesets.*?\\n.*?\\n.*?\\n.*?\\n.*?\\n(?P<name>\\w.*?)\\n(?P<album>\\w.*?)\\n/im', $nfo, $matches) && $foundName == "") { $artist = $matches['name']; $title = $matches['album']; $source = null; $year = null; if (preg_match('/Year.*?\\:{1,2} ?(?P<year>(19|20)\\d{2})/i', $nfo, $matches)) { $year = $matches[1]; } elseif (preg_match('/date.*?\\:.*?(?P<year>(19|20)\\d{2})/i', $nfo, $matches)) { $year = $matches[1]; } if (preg_match('/(web|cable|sat)/i', $title)) { $source = ""; } elseif (preg_match('/Source.*?\\:{1,2} ?(?P<source>.*?)(\\s{2,}|\\s{1,})/i', $nfo, $matches)) { $source = $matches[1]; if ($source == "Satellite") { $source = "Sat"; } } if ($artist) { $tempname = $artist; if ($title) { $tempname = $tempname . "-" . $title; } if ($source) { $tempname = $tempname . "-" . $source; } if ($year) { $tempname = $tempname . "-" . $year; } $tempname = preg_replace("/[^a-zA-Z,0-9,\\-,\\s]/", "", $tempname); $foundName = $tempname; $methodused = "Live Sets"; $this->determineCategory($rel, $foundName, $methodused); } } //Typical scene regex if (preg_match('/(?P<source>Source[\\s\\.]*?:|fix for nuke)?(?:\\s|\\]|\\[)?(?P<name>[a-z0-9\'\\-]+(?:\\.|_)[a-z0-9\\.\\-_\'&]+\\-[a-z0-9&]+)(?:\\s|\\[|\\])/i', $nfo, $matches) && $foundName == "") { if (empty($matches['source'])) { if (!preg_match('/usenet\\-space/i', $matches['name'])) { $foundName = $matches['name']; $methodused = "Scene"; $this->determineCategory($rel, $foundName, $methodused); } } } } //The Big One if (preg_match_all('/([a-z0-9\\ ]+)\\.{1,}(\\:|\\[)(?P<name>.*)(\\s{2}|\\s{1})/i', $nfo, $matches) && $foundName == "") { $lut = array(); foreach ($matches[1] as $key => $k) { $lut[str_replace(' ', '', strtolower(trim($k)))] = trim($matches[3][$key]); } $year = null; $vidsource = null; $series = null; $season = null; $episode = null; $language = null; $artist = null; $source = null; foreach ($lut as $k => $v) { $v = rtrim($v); if (!$year && preg_match('/((19|20)\\d{2})/', $v, $matches)) { $year = $matches[1]; } if (!$vidsource && preg_match('/(xvid|x264|h264|wmv|divx)/i', $v, $matches)) { $vidsource = $matches[1]; } if (!$season && preg_match('/(season|seizon).*?(\\d{1,3})/i', $v, $matches)) { $season = $matches[2]; } if (!$episode && preg_match('/(Episode|ep).*?(\\d{1,3})/i', $v, $matches)) { $episode = $matches[2]; } } if (isset($lut['artist'])) { $del = "-"; if (isset($lut['artist'])) { $lut['artist'] = trim($lut['artist'], " "); $tempname = $lut['artist']; } if (isset($lut['title'])) { $tempname = $tempname . $del . $lut['title']; } if (isset($lut['album']) && !isset($lut['title'])) { $tempname = $tempname . $del . $lut['album']; } if (isset($lut['track']) && !isset($lut['title']) && !isset($lut['album'])) { $tempname = $tempname . $del . $lut['track']; } if (!isset($lut['source'])) { $lut['source'] = 'WEB'; } if (isset($lut['source']) && !preg_match('/SAT/i', $tempname)) { $tempname = $tempname . $del . $lut['source']; } if (!preg_match('/(19|20)\\d{2}/', $tempname) && $year) { $tempname = $tempname . $del . $year; } if (isset($lut['ripper'])) { $tempname = $tempname . $del . $lut['ripper']; } $tempname = preg_replace("/[^a-zA-Z,0-9,\\-,\\&,\\s]/", "", $tempname); $tempname = preg_replace("/[ ]{2,}/", "", $tempname); $methodused = "The Big One Music"; $foundName = $tempname; $this->determineCategory($rel, $foundName, $methodused); } else { if (isset($lut['title'])) { $del = " "; if (isset($lut['series'])) { $tempname = $lut['series']; } $tempname = $tempname . $del . $lut['title']; if ($season && $episode) { $tempname = $tempname . $del . "S" . str_pad($season, 2, '0', STR_PAD_LEFT) . 'E' . str_pad($episode, 2, '0', STR_PAD_LEFT); } else { if ($season) { $tempname = $tempname . $del . "S" . $season; } if ($episode) { $tempname = $tempname . $del . "Ep" . $episode; } } if (isset($lut['source']) && !preg_match('/SAT/i', $lut['title'])) { $tempname = $tempname . $del . $lut['source']; } if (!preg_match('/(19|20)\\d{2}/', $tempname) && $year) { $tempname = $tempname . $del . $year; } if (isset($lut['language'])) { $tempname = $tempname . $del . $lut['language']; } if ($vidsource) { $tempname = $tempname . $del . $vidsource; } $tempname = preg_replace("/ /", " ", $tempname); $tempname = preg_replace("/[^a-zA-Z,0-9,\\-,\\&,\\s]/", " ", $tempname); $tempname = preg_replace("/[ ]+/", " ", $tempname); $methodused = "The Big One Other"; $foundName = $tempname; $this->determineCategory($rel, $foundName, $methodused); } } } /// ///unable to extract releasename from nfo, try the rar file /// if ($rel['filenames'] && $foundName == '') { $this->releasefilesprocessed++; $files = explode(',', $rel['filenames']); if (![$files]) { $files = [$files]; } // Scene regex $sceneRegex = '/([a-z0-9\'\\-\\.\\_\\(\\)\\+\\ ]+\\-[a-z0-9\'\\-\\.\\_\\(\\)\\ ]+)(.*?\\\\.*?|)\\.(?:\\w{3,4})$/i'; foreach ($files as $file) { // Petje Releases if (preg_match('/Petje \\<petje\\@pietamientje\\.com\\>/', $rel['fromname'], $matches3) && $foundName == '') { if (preg_match('/.*\\.(mkv|avi|mp4|wmv|divx)/', $file, $matches4)) { $array_new = explode('\\', $matches4[0]); foreach ($array_new as $item) { if (preg_match('/.*\\((19|20\\d{2})\\)$/', $item, $matched)) { //echo $matched[0].".720p.x264-Petje"; //print_r($matched); $foundName = $matched[0] . ".720p.x264-Petje"; $methodused = "Petje"; $this->determineCategory($rel, $foundName, $methodused); break 2; } } } } //3D Remux if (preg_match('/.*Remux\\.mkv/', $file, $matches4)) { $foundName = str_replace(".mkv", "", $matches4[0]); $methodused = "3D Remux"; $this->determineCategory($rel, $foundName, $methodused); } //QoQ Extended if (preg_match('/Q\\-sbuSLN.*/i', $file, $matches4)) { $new1 = preg_match('/( )?(\\.wmv|\\.divx|\\.avi|\\.mkv)/i', $matches4[0], $matched); $new2 = str_replace($matched[0], "", $matches4[0]); $foundName = strrev($new2); $methodused = "QoQ Extended"; $this->determineCategory($rel, $foundName, $methodused); } // Directory\Title.Year.Format.Group.mkv if (preg_match('/(?<=\\\\).*?BLURAY.(1080|720)P.*?KNORLOADING(?=\\.MKV)/i', $file, $matches3) && $foundName == '') { $foundName = $matches3['0']; $methodused = "a.b.hdtv.x264"; $this->determineCategory($rel, $foundName, $methodused); } // ReleaseGroup.Title.Format.mkv if (preg_match('/(?<=swg_|swghd\\-|lost\\-|veto\\-|kaka\\-|abd\\-|airline\\-|daa\\-|data\\-|japhson\\-|ika\\-|lng\\-|nrdhd\\-|saimorny\\-|sparks\\-|ulshd\\-|nscrns\\-|ifpd\\-|invan\\-|an0\\-|besthd\\-|muxhd\\-|s7\\-).*?((1080|720)|P)(?=\\.MKV)/i', $file, $matches3) && $foundName == '') { $foundName = str_replace("_", ".", $matches3['0']); $methodused = "a.b.hdtv.x264"; $this->determineCategory($rel, $foundName, $methodused); } // Title.Format.ReleaseGroup.mkv if (preg_match('/.*?(1080|720)(|P).(SON)/i', $file, $matches3) && $foundName == '') { $foundName = str_replace("_", ".", $matches3['0']); $methodused = "a.b.hdtv.x264"; $this->determineCategory($rel, $foundName, $methodused); } //epubmobi if (preg_match('/.*\\.(epub|mobi|azw3|pdf|prc|lit|rtf|azw|cbr|doc)/', $file, $matches4)) { $foundName = str_replace(".doc", "", str_replace(".cbr", "", str_replace(".prc", "", str_replace(".pdf", "", str_replace(".azw3", "", str_replace(".mobi", "", str_replace(".epub", "", str_replace(".rtf", "", str_replace(".azw", "", str_replace(".lit", "", $matches4[0])))))))))); $methodused = "EpubMobi"; $this->determineCategory($rel, $foundName, $methodused); } //Reversed name if (preg_match('/[a-z0-9\\(\\)\'\\!\\,\\.\\-\\ \\_]+(BEW|p027|p0801)[a-z0-9\\(\\)\\,\'\\!\\ \\-\\.]+/i', $file, $matches4)) { $new1 = preg_match('/( )?(\\.m2ts|\\.wmv|\\.avi|.mp4|\\.mkv)/i', $matches4[0], $matched); $new2 = str_replace($matched[0], "", $matches4[0]); $foundName = strrev($new2); $methodused = "Reversed"; $this->determineCategory($rel, $foundName, $methodused); } //Check rarfile contents for a scene name if (preg_match($sceneRegex, $file, $matches) && $foundName == '') { //Simply Releases Toppers if (preg_match('/(\\\\)(?P<name>.*?ReleaseS Toppers)/', $file, $matches1) && $foundName == '') { $foundName = $matches1['name']; $methodused = "Release Files-1"; $this->determineCategory($rel, $foundName, $methodused); } //Scene format no folder. if (preg_match('/^([a-z0-9\\.\\_\\- ]+\\-[a-z0-9\\_]+)(\\\\|)$/i', $matches[1]) && $foundName == '') { if (strlen($matches['1']) >= 15) { $foundName = $matches['1']; $methodused = "Scene format no folder."; $this->determineCategory($rel, $foundName, $methodused); } } //Check to see if file is inside of a folder. Use folder name if it is if (preg_match('/^(.*?\\\\)(.*?\\\\|)(.*?)$/i', $file, $matches1) && $foundName == '') { if (preg_match('/^([a-z0-9\\.\\_\\- ]+\\-[a-z0-9\\_]+)(\\\\|)$/i', $matches1['1'], $res)) { $foundName = $res['1']; $methodused = "Release Files-1"; $this->determineCategory($rel, $foundName, $methodused); } if (preg_match('/(?!UTC)([a-z0-9]+[a-z0-9\\.\\_\\- \'\\)\\(]+(\\d{4}|HDTV).*?\\-[a-z0-9]+)/i', $matches1['1'], $res) && $foundName == '') { $foundName = $res['1']; $methodused = "Release Files-2"; $this->determineCategory($rel, $foundName, $methodused); } if (preg_match('/^([a-z0-9\\.\\_\\- ]+\\-[a-z0-9\\_]+)(\\\\|)$/i', $matches1['2'], $res) && $foundName == '') { $foundName = $res['1']; $methodused = "Release Files-3"; $this->determineCategory($rel, $foundName, $methodused); } if (preg_match('/^([a-z0-9\\.\\_\\- ]+\\-(?:.+)\\(html\\))\\\\/i', $matches1['1'], $res) && $foundName == '') { $foundName = $res['1']; $methodused = "Release Files-4"; $this->determineCategory($rel, $foundName, $methodused); } } if (preg_match('/(?!UTC)([a-z0-9]+[a-z0-9\\.\\_\\- \'\\)\\(]+(\\d{4}|HDTV).*?\\-[a-z0-9]+)/i', $file, $matches2) && $foundName == '') { $foundName = $matches2['1']; $methodused = "Release Files-4"; $this->determineCategory($rel, $foundName, $methodused); } } } //RAR file contents release name matching /*if (sizeof($files) > 0 && $foundName == '') { echo "RAR checking\n"; //Loop through releaseFiles to find a match foreach($files as $rarFile) { //echo "-{$rarFile}\n"; if ($foundName == '') { //Lookup name via reqid (filename) if (preg_match('/\.(avi|mkv|mp4|mov|wmv|iso|img|gcm|ps3|wad|ac3|nds|bin|cue|mdf)/i', $rarFile)) { $this->pdo->getSetting('reqidurl; $lookupUrl = 'http://allfilled/query.php?t=alt.binaries.srrdb&reqid='.urlencode(basename($rarFile)); echo '-lookup: '.$lookupUrl."\n"; $xml = Utility::getUrl(['url' => $lookupUrl]); //$xml = false; if ($xml !== false) { $xmlObj = @simplexml_load_string($xml); $arrXml = objectsIntoArray($xmlObj); if (isset($arrXml["item"]) && is_array($arrXml["item"]) && isset($arrXml["item"]["@attributes"]) && is_array($arrXml["item"]["@attributes"])) { $foundName = $arrXml["item"]["@attributes"]["title"]; } } } } } }*/ } // do par check if user has elected for downloading extra stuff if ($this->pdo->getSetting('unrarpath') != '' && $foundName == "") { $nzb = new NZB(); $nzbfile = $nzb->getNZBPath($rel['guid']); $nzbInfo = new nzbInfo(); $nzbInfo->loadFromFile($nzbfile); if (!empty($nzbInfo->parfiles) && empty($nzbInfo->rarfiles) && empty($nzbInfo->audiofiles)) { $nntp = new NNTP(); $nntp->doConnect(); if ($this->verbose) { echo "Checking Par\n"; } foreach ($nzbInfo->parfiles as $parfile) { $this->parsprocessed++; $parBinary = $nntp->getMessages($parfile['groups'][0], $parfile['segments'], $this->verbose); if ($parBinary) { $par2 = new Par2info(); $par2->setData($parBinary); if (!$par2->error) { $parFiles = $par2->getFileList(); foreach ($parFiles as $file) { if (isset($file['name']) && (preg_match('/.*part0*1\\.rar$/iS', $file['name'], $matches) || preg_match('/(?!part0*1)\\.rar$/iS', $file['name'], $matches) || preg_match('/\\.001$/iS', $file['name'], $matches))) { $foundName = preg_replace('/^(.*)(\\.part0*1\\.rar|\\.rar|\\.001)$/i', '\\1', $file['name']); $methodused = "Par file"; $this->determineCategory($rel, $foundName, $methodused); break; } } } } unset($parBinary); if ($foundName != "") { break; } } $nntp->doQuit(); } } /// /// This is a last ditch effort, build a ReleaseName from the Nfo /// if ($nfo && ($foundName == "" || $methodused == 'Scene format no folder.')) { //LastNfoAttempt if (preg_match('/tt(\\d{7})/i', $nfo, $matches) && $foundName == "") { $movie = new Movie(); $imdbId = $matches[1]; $movCheck = $movie->fetchImdbProperties($imdbId); $buffer = Utility::getUrl(['url' => 'http://akas.imdb.com/title/tt' . $imdbId . '/']); if (!preg_match('/content\\=\\"video\\.tv\\_show\\"/i', $buffer)) { if (isset($movCheck['title'])) { $foundName = $movCheck['title']; if (!preg_match('/(19|20)\\d{2}/i', $foundName)) { $foundName = $foundName . "." . (isset($movCheck['year']) ? $movCheck['year'] : ""); } if (preg_match('/language.*?\\b([a-z0-9]+)\\b/i', $nfo, $matches)) { if (!preg_match('/English/i', $matches[1])) { $foundName = $foundName . "." . $matches[1]; } } if (preg_match('/audio.*?\\b(\\w+)\\b/i', $nfo, $matches)) { if (preg_match('/(Chinese|German|Dutch|Spanish|Hebrew|Finnish|Norwegian)/i', $matches[1])) { $foundName = $foundName . "." . $matches[1]; } } if (preg_match('/(video|resolution|video res).*?(1080|720|816|820|272|1280 @|528|1920)/i', $nfo, $matches)) { if ($matches[2] == '1280 @') { $matches[2] = '720'; } if ($matches[2] == '1920') { $matches[2] = '1080'; } $foundName = $foundName . "." . $matches[2]; } if (preg_match('/source.*?\\b(DVD9|DVD5|BDRIP|DVD\\-?RIP|BLURAY|BD)\\b/i', $nfo, $matches)) { if ($matches[1] == 'BD') { $matches[1] = 'Bluray.x264'; } $foundName = $foundName . "." . $matches[1]; } if (preg_match('/(video|resolution|video res).*?(XVID|X264|WMV)/i', $nfo, $matches)) { $foundName = $foundName . "." . $matches[2]; } if (preg_match('/audio.*?\\b(DTS|AC3)\\b/i', $nfo, $matches)) { $foundName = $foundName . "." . $matches[1]; } $foundName = $foundName . "-NoGroup"; $methodused = "LastNfoAttempt"; $this->determineCategory($rel, $foundName, $methodused); } } } } if ($foundName == '' && $this->verbose) { echo "ReleaseID: \t\t" . $rel["rid"] . "\n" . " Group: \t\t" . $rel["groupname"] . "\n" . " Old Name: \t\t" . $rel["name"] . "\n" . " Old SearchName: \t" . $rel["searchname"] . "\n" . " Status: \t\tNo new name found.\n\n"; } } } if ($this->verbose) { echo $this->releasestocheck . " releases checked\n" . $this->nfosprocessed . " of " . $this->releasestocheck . " releases had nfo's processed\n" . $this->parsprocessed . " of " . $this->releasestocheck . " releases had par's processed\n" . $this->releasefilesprocessed . " of " . $this->releasestocheck . " releases had releasefiles processed\n" . $this->numupdated . " of " . $this->releasestocheck . " releases " . ($this->releasestocheck > 0 ? floor($this->numupdated / $this->releasestocheck * 100) . "%" : "") . " changed\n"; } }
/** * Process RequestID's. * * @param int|string $groupID * @param int $limit * @param bool $local * * @access public * @void */ public function processRequestIDs($groupID = '', $limit = 5000, $local = true) { $echoCLI = NN_ECHOCLI; $groups = new Groups(); $s = new Settings(); $consoleTools = new ConsoleTools(['ColorCLI' => $this->pdo->log]); if ($local === false && $s->getSetting('lookup_reqids') == 0) { return; } $startTime = time(); if ($echoCLI) { $this->pdo->log->doEcho($this->pdo->log->header(sprintf("Process Releases -> Request id %s lookup -- limit %s", $local === true ? 'local' : 'web', $limit))); } if ($local === true) { $foundRequestIDs = (new \RequestIDLocal(['Echo' => $echoCLI, 'ConsoleTools' => $consoleTools, 'Groups' => $groups, 'Settings' => $this->pdo]))->lookupRequestIDs(['GroupID' => $groupID, 'limit' => $limit, 'time' => 168]); } else { $foundRequestIDs = (new \RequestIDWeb(['Echo' => $echoCLI, 'ConsoleTools' => $consoleTools, 'Groups' => $groups, 'Settings' => $this->pdo]))->lookupRequestIDs(['GroupID' => $groupID, 'limit' => $limit, 'time' => 168]); } if ($echoCLI) { $this->pdo->log->doEcho($this->pdo->log->primary(number_format($foundRequestIDs) . ' releases updated in ' . $consoleTools->convertTime(time() - $startTime)), true); } }
/** * Get a string like this: * "AND r.nzbstatus = 1 AND r.nfostatus BETWEEN -8 AND -1 AND r.size < 1073741824 AND r.size > 1048576" * To use in a query. * * @param Settings $pdo * * @return string * @access public * @static */ public static function NfoQueryString(Settings &$pdo) { $maxSize = $pdo->getSetting('maxsizetoprocessnfo'); $minSize = $pdo->getSetting('minsizetoprocessnfo'); $maxRetries = (int) ($pdo->getSetting('maxnforetries') >= 0 ? -((int) $pdo->getSetting('maxnforetries') + 1) : self::NFO_UNPROC); return sprintf('AND r.nzbstatus = %d AND r.nfostatus BETWEEN %d AND %d %s %s', NZB::NZB_ADDED, $maxRetries < -8 ? -8 : $maxRetries, self::NFO_UNPROC, $maxSize != '' && $maxSize > 0 ? 'AND r.size < ' . $maxSize * 1073741824 : '', $minSize != '' && $minSize > 0 ? 'AND r.size > ' . $minSize * 1048576 : ''); }
<?php require_once dirname(__FILE__) . '/../../www/config.php'; use newznab\db\Settings; $releases = new Releases(); $pdo = new Settings(); $nzb = new NZB(); $nntp = new NNTP(); // read pars for a release GUID, echo out any that look like a rar $relguid = "249f9ec1f0d68d33b5fa85594ba1a47d"; $nzbfile = $nzb->getNZBPath($relguid, $pdo->getSetting('nzbpath'), true); $nzbInfo = new nzbInfo(); $nzbInfo->loadFromFile($nzbfile); $nntp->doConnect(); echo $nzbInfo->summarize(); foreach ($nzbInfo->parfiles as $parfile) { echo "Fetching " . $parfile['subject'] . "\n"; $parBinary = $nntp->getMessages($parfile['groups'][0], $parfile['segments']); if ($parBinary) { $par2 = new Par2info(); $par2->setData($parBinary); if (!$par2->error) { $parFiles = $par2->getFileList(); foreach ($parFiles as $file) { if (preg_match('/.*part0*1\\.rar$/iS', $file['name']) || preg_match('/(?!part0*1)\\.rar$/iS', $file['name']) || preg_match('/\\.001$/iS', $file['name'])) { print_r($file); } } } } unset($parBinary);
<?php require_once dirname(__FILE__) . '/../../../../www/config.php'; use newznab\db\Settings; use newznab\utility\Utility; $pdo = new Settings(); $DIR = NN_TMUX; $c = new ColorCLI(); $t = new Tmux(); $tmux = $t->get(); $import = isset($tmux->import) ? $tmux->import : 0; $tmux_session = isset($tmux->tmux_session) ? $tmux->tmux_session : 0; $seq = isset($tmux->sequential) ? $tmux->sequential : 0; $powerline = isset($tmux->powerline) ? $tmux->powerline : 0; $colors = isset($tmux->colors) ? $tmux->colors : 0; $nntpproxy = $pdo->getSetting('nntpproxy'); $tablepergroup = $pdo->getSetting('tablepergroup'); $tablepergroup = $tablepergroup != '' ? $tablepergroup : 0; // Check that Db patch level is current. Also checks nZEDb.xml is valid. Utility::isPatched(); Utility::clearScreen(); echo "Starting Tmux...\n"; // Create a placeholder session so tmux commands do not throw server not found errors. exec('tmux new-session -ds placeholder 2>/dev/null'); // Search for NNTPProxy session that might be running from a user threaded.php run. Setup a clean environment to run in. exec("tmux list-session | grep NNTPProxy", $nntpkill); if (count($nntpkill) !== 0) { exec("tmux kill-session -t NNTPProxy"); echo $pdo->log->notice("Found NNTPProxy tmux session and killing it."); } else { exec("tmux list-session", $session);
require_once dirname(__FILE__) . "/../../../bin/config.php"; use newznab\db\Settings; $pdo = new Settings(); if (isset($argv[1]) && ($argv[1] == "true" || $argv[1] == "drop")) { $pdo->queryExec("UPDATE groups SET first_record = 0, first_record_postdate = NULL, last_record = 0, last_record_postdate = NULL, last_updated = NULL"); echo $pdo->log->primary("Reseting all groups completed."); $arr = array("parts", "partrepair", "binaries"); foreach ($arr as &$value) { $rel = $pdo->queryExec("TRUNCATE TABLE {$value}"); if ($rel !== false) { echo $pdo->log->primary("Truncating {$value} completed."); } } unset($value); $tpg = $pdo->getSetting('tablepergroup'); $tablepergroup = !empty($tpg) ? $tpg : 0; if ($tablepergroup == 1) { $sql = 'SHOW table status'; $tables = $pdo->query($sql); foreach ($tables as $row) { $tbl = $row['name']; if (preg_match('/binaries_\\d+/', $tbl) || preg_match('/parts_\\d+/', $tbl) || preg_match('/partrepair_\\d+/', $tbl) || preg_match('/\\d+_binaries/', $tbl) || preg_match('/\\d+_parts/', $tbl) || preg_match('/\\d+_partrepair_\\d+/', $tbl)) { if ($argv[1] == "drop") { $rel = $pdo->queryDirect(sprintf('DROP TABLE %s', $tbl)); if ($rel !== false) { echo $pdo->log->primary("Dropping {$tbl} completed."); } } else { $rel = $pdo->queryDirect(sprintf('TRUNCATE TABLE %s', $tbl)); if ($rel !== false) {
/** * Delete releases using admin settings. * This deletes releases, regardless of group. * * @void * @access public */ public function deleteReleases() { $startTime = time(); $category = new \Category(['Settings' => $this->pdo]); $genres = new \Genres(['Settings' => $this->pdo]); $passwordDeleted = $duplicateDeleted = $retentionDeleted = $completionDeleted = $disabledCategoryDeleted = 0; $disabledGenreDeleted = $miscRetentionDeleted = $miscHashedDeleted = $categoryMinSizeDeleted = 0; // Delete old releases and finished collections. if ($this->echoCLI) { $this->pdo->log->doEcho($this->pdo->log->header("Process Releases -> Delete old releases and passworded releases.")); } // Releases past retention. if ($this->pdo->getSetting('releaseretentiondays') != 0) { $releases = $this->pdo->queryDirect(sprintf('SELECT id, guid FROM releases WHERE postdate < (NOW() - INTERVAL %d DAY)', $this->pdo->getSetting('releaseretentiondays'))); if ($releases instanceof \Traversable) { foreach ($releases as $release) { $this->deleteSingle(['g' => $release['guid'], 'i' => $release['id']], $this->nzb, $this->releaseImage); $retentionDeleted++; } } } // Passworded releases. if ($this->pdo->getSetting('deletepasswordedrelease') == 1) { $releases = $this->pdo->queryDirect(sprintf('SELECT id, guid FROM releases WHERE passwordstatus = %d', \Releases::PASSWD_RAR)); if ($releases instanceof \Traversable) { foreach ($releases as $release) { $this->deleteSingle(['g' => $release['guid'], 'i' => $release['id']], $this->nzb, $this->releaseImage); $passwordDeleted++; } } } // Possibly passworded releases. if ($this->pdo->getSetting('deletepossiblerelease') == 1) { $releases = $this->pdo->queryDirect(sprintf('SELECT id, guid FROM releases WHERE passwordstatus = %d', \Releases::PASSWD_POTENTIAL)); if ($releases instanceof \Traversable) { foreach ($releases as $release) { $this->deleteSingle(['g' => $release['guid'], 'i' => $release['id']], $this->nzb, $this->releaseImage); $passwordDeleted++; } } } if ($this->crossPostTime != 0) { // Crossposted releases. do { $releases = $this->pdo->queryDirect(sprintf('SELECT id, guid FROM releases WHERE adddate > (NOW() - INTERVAL %d HOUR) GROUP BY name HAVING COUNT(name) > 1', $this->crossPostTime)); $total = 0; if ($releases && $releases->rowCount()) { $total = $releases->rowCount(); foreach ($releases as $release) { $this->deleteSingle(['g' => $release['guid'], 'i' => $release['id']], $this->nzb, $this->releaseImage); $duplicateDeleted++; } } } while ($total > 0); } if ($this->completion > 0) { $releases = $this->pdo->queryDirect(sprintf('SELECT id, guid FROM releases WHERE completion < %d AND completion > 0', $this->completion)); if ($releases instanceof \Traversable) { foreach ($releases as $release) { $this->deleteSingle(['g' => $release['guid'], 'i' => $release['id']], $this->nzb, $this->releaseImage); $completionDeleted++; } } } // Disabled categories. $disabledCategories = $category->getDisabledIDs(); if (count($disabledCategories) > 0) { foreach ($disabledCategories as $disabledCategory) { $releases = $this->pdo->queryDirect(sprintf('SELECT id, guid FROM releases WHERE categoryid = %d', $disabledCategory['id'])); if ($releases instanceof \Traversable) { foreach ($releases as $release) { $disabledCategoryDeleted++; $this->deleteSingle(['g' => $release['guid'], 'i' => $release['id']], $this->nzb, $this->releaseImage); } } } } // Delete smaller than category minimum sizes. $categories = $this->pdo->queryDirect(' SELECT c.id AS id, CASE WHEN c.minsizetoformrelease = 0 THEN cp.minsizetoformrelease ELSE c.minsizetoformrelease END AS minsize FROM category c INNER JOIN category cp ON cp.id = c.parentid WHERE c.parentid IS NOT NULL'); if ($categories instanceof \Traversable) { foreach ($categories as $category) { if ($category['minsize'] > 0) { $releases = $this->pdo->queryDirect(sprintf(' SELECT r.id, r.guid FROM releases r WHERE r.categoryid = %d AND r.size < %d', $category['id'], $category['minsize'])); if ($releases instanceof \Traversable) { foreach ($releases as $release) { $this->deleteSingle(['g' => $release['guid'], 'i' => $release['id']], $this->nzb, $this->releaseImage); $categoryMinSizeDeleted++; } } } } } // Disabled music genres. $genrelist = $genres->getDisabledIDs(); if (count($genrelist) > 0) { foreach ($genrelist as $genre) { $releases = $this->pdo->queryDirect(sprintf(' SELECT id, guid FROM releases INNER JOIN (SELECT id AS mid FROM musicinfo WHERE musicinfo.genreID = %d) mi ON musicinfoid = mid', $genre['id'])); if ($releases instanceof \Traversable) { foreach ($releases as $release) { $disabledGenreDeleted++; $this->deleteSingle(['g' => $release['guid'], 'i' => $release['id']], $this->nzb, $this->releaseImage); } } } } // Misc other. if ($this->pdo->getSetting('miscotherretentionhours') > 0) { $releases = $this->pdo->queryDirect(sprintf(' SELECT id, guid FROM releases WHERE categoryid = %d AND adddate <= NOW() - INTERVAL %d HOUR', \Category::CAT_MISC_OTHER, $this->pdo->getSetting('miscotherretentionhours'))); if ($releases instanceof \Traversable) { foreach ($releases as $release) { $this->deleteSingle(['g' => $release['guid'], 'i' => $release['id']], $this->nzb, $this->releaseImage); $miscRetentionDeleted++; } } } // Misc hashed. if ($this->pdo->getSetting('mischashedretentionhours') > 0) { $releases = $this->pdo->queryDirect(sprintf(' SELECT id, guid FROM releases WHERE categoryid = %d AND adddate <= NOW() - INTERVAL %d HOUR', \Category::CAT_MISC_HASHED, $this->pdo->getSetting('mischashedretentionhours'))); if ($releases instanceof \Traversable) { foreach ($releases as $release) { $this->deleteSingle(['g' => $release['guid'], 'i' => $release['id']], $this->nzb, $this->releaseImage); $miscHashedDeleted++; } } } if ($this->echoCLI) { $this->pdo->log->doEcho($this->pdo->log->primary('Removed releases: ' . number_format($retentionDeleted) . ' past retention, ' . number_format($passwordDeleted) . ' passworded, ' . number_format($duplicateDeleted) . ' crossposted, ' . number_format($disabledCategoryDeleted) . ' from disabled categories, ' . number_format($categoryMinSizeDeleted) . ' smaller than category settings, ' . number_format($disabledGenreDeleted) . ' from disabled music genres, ' . number_format($miscRetentionDeleted) . ' from misc->other' . number_format($miscHashedDeleted) . ' from misc->hashed' . ($this->completion > 0 ? ', ' . number_format($completionDeleted) . ' under ' . $this->completion . '% completion.' : '.'))); $totalDeleted = $retentionDeleted + $passwordDeleted + $duplicateDeleted + $disabledCategoryDeleted + $disabledGenreDeleted + $miscRetentionDeleted + $miscHashedDeleted + $completionDeleted + $categoryMinSizeDeleted; if ($totalDeleted > 0) { $this->pdo->log->doEcho($this->pdo->log->primary("Removed " . number_format($totalDeleted) . ' releases in ' . $this->consoleTools->convertTime(time() - $startTime))); } } }
/** * Lookup xxx if enabled. */ public function processXXX() { if ($this->pdo->getSetting('lookupxxx') == 1) { (new \XXX(['Echo' => $this->echooutput, 'Settings' => $this->pdo]))->processXXXReleases(); } }
<?php require_once dirname(__FILE__) . '/../../www/config.php'; use newznab\db\Settings; $pdo = new Settings(); $rtkey = $pdo->getSetting('rottentomatokey'); if (isset($rtkey)) { $rt = new RottenTomato($pdo->getSetting('rottentomatokey')); //print_r($rt->getMoviesBoxOffice()); //print_r($rt->getMoviesInTheaters()); //print_r($rt->getOpeningMovies()); //print_r($rt->getUpcomingMovies()); //print_r($rt->getNewDvdReleasess()); //print_r($rt->getMovieInfo("770805418")); //print_r($rt->getMovieReviews("770805418")); //print_r($rt->getMovieCast("770805418")); print_r($rt->movieSearch("moviename")); }