Exemplo n.º 1
0
                $releases = $pdo->queryDirect(sprintf('
								SELECT r.id AS releaseid, r.guid, r.group_id
								FROM releases r
								WHERE r.guid %s
								AND r.nzbstatus = 1
								AND r.proc_par2 = 0
								AND r.preid = 0
								ORDER BY r.postdate ASC
								LIMIT %s', $pdo->likeString($guidChar, false, true), $maxperrun));
                if ($releases instanceof \Traversable) {
                    $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."));
                    }
                    $Nfo = new Nfo(['Settings' => $pdo, 'Echo' => true]);
                    $nzbcontents = new NZBContents(['Echo' => true, 'NNTP' => $nntp, 'Nfo' => $Nfo, 'Settings' => $pdo, 'PostProcess' => new PostProcess(['Settings' => $pdo, 'Nfo' => $Nfo, 'NameFixer' => $namefixer])]);
                    foreach ($releases as $release) {
                        $res = $nzbcontents->checkPAR2($release['guid'], $release['releaseid'], $release['group_id'], 1, 1);
                        if ($res === false) {
                            echo '.';
                        }
                    }
                }
                break;
            case $pieces[0] === 'miscsorter' && isset($guidChar) && isset($maxperrun) && is_numeric($maxperrun):
                $releases = $pdo->queryDirect(sprintf('
								SELECT r.id AS releaseid
								FROM releases r
								WHERE r.guid %s
								AND r.nzbstatus = 1 AND r.nfostatus = 1
								AND r.proc_sorter = 0 AND r.isrenamed = 0
Exemplo n.º 2
0
    /**
     * Attempts to fix release names using the Par2 File.
     *
     * @param int $time   1: 24 hours, 2: no time limit
     * @param int $echo   1: change the name, anything else: preview of what could have been changed.
     * @param int $cats   1: other categories, 2: all categories
     * @param $nameStatus
     * @param $show
     * @param NNTP $nntp
     */
    public function fixNamesWithPar2($time, $echo, $cats, $nameStatus, $show, $nntp)
    {
        $this->_echoStartMessage($time, 'par2 files');
        if ($cats === 3) {
            $query = sprintf('
					SELECT rel.id AS releaseid, rel.guid, rel.group_id
					FROM releases rel
					WHERE nzbstatus = %d
					AND preid = 0', NZB::NZB_ADDED);
            $cats = 2;
        } else {
            $query = sprintf('
					SELECT rel.id AS releaseid, rel.guid, rel.group_id
					FROM releases rel
					WHERE (rel.isrenamed = %d OR rel.categoryid = %d)
					AND proc_par2 = %d', self::IS_RENAMED_NONE, Category::CAT_OTHER_MISC, self::PROC_PAR2_NONE);
        }
        $releases = $this->_getReleases($time, $cats, $query);
        if ($releases instanceof \Traversable && $releases !== false) {
            $total = $releases->rowCount();
            if ($total > 0) {
                $this->_totalReleases = $total;
                echo $this->pdo->log->primary(number_format($total) . ' releases to process.');
                $Nfo = new Nfo(['Echo' => $this->echooutput, 'Settings' => $this->pdo]);
                $nzbContents = new NZBContents(['Echo' => $this->echooutput, 'NNTP' => $nntp, 'Nfo' => $Nfo, 'Settings' => $this->pdo, 'PostProcess' => new PostProcess(['Settings' => $this->pdo, 'Nfo' => $Nfo])]);
                foreach ($releases as $release) {
                    if ($nzbContents->checkPAR2($release['guid'], $release['releaseid'], $release['group_id'], $nameStatus, $show) === true) {
                        $this->fixed++;
                    }
                    $this->checked++;
                    $this->_echoRenamed($show);
                }
                $this->_echoFoundCount($echo, ' files');
            } else {
                echo $this->pdo->log->alternate('Nothing to fix.');
            }
        }
    }
Exemplo n.º 3
0
Arquivo: Nfo.php Projeto: egandt/nZEDb
    /**
     * 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]);
            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 releaseid FROM release_nfos WHERE releaseid = %d', $arr['id']));
                    if (!isset($ckreleaseid['releaseid'])) {
                        $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. Disabled for now while TvRage is down. TODO: Add Other Scraper Checks
                    if ($processTvrage == 1) {
                        /*$tvRage = new TvRage(['Echo' => $this->echo, 'Settings' => $this->pdo]);
                        		$showId = $this->parseShowId($fetchedBinary);
                        		if ($showId !== 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 AND r.nfostatus > %d %s %s', NZB::NZB_ADDED, $this->maxRetries, self::NFO_FAILED, $groupIDQuery, $guidCharQuery));
        if ($releases instanceof \Traversable) {
            foreach ($releases as $release) {
                // remove any release_nfos for failed
                $this->pdo->queryExec(sprintf('
					DELETE FROM release_nfos WHERE nfo IS NULL AND releaseid = %d', $release['id']));
                // set release.nfostatus to failed
                $this->pdo->queryExec(sprintf('
					UPDATE releases r SET r.nfostatus = %d WHERE r.id = %d', self::NFO_FAILED, $release['id']));
            }
        }
        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;
    }
Exemplo n.º 4
0
                 $pdo->queryExec(sprintf("UPDATE releases SET dehashstatus = %d - 1 WHERE id = %d", $res['dehashstatus'], $res['releaseid']));
                 echo '.';
             }
         }
     }
 } else {
     if (isset($pieces[1]) && $pieces[0] == 'par2') {
         //echo PHP_EOL . microtime();
         $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."));
         }
         $relID = $pieces[1];
         $guid = $pieces[2];
         $groupID = $pieces[3];
         $nzbcontents = new NZBContents(array('Echo' => true, 'NNTP' => $nntp, 'Settings' => $pdo, 'Nfo' => new Nfo(['Settings' => $pdo, 'Echo' => true]), 'PostProcess' => new PostProcess(['Settings' => $pdo, 'NameFixer' => $namefixer])));
         //echo " " . microtime();
         $res = $nzbcontents->checkPAR2($guid, $relID, $groupID, 1, 1);
         //echo " " . microtime() . " ";
         if ($res === false) {
             echo '.';
         }
     } else {
         if (isset($pieces[1]) && $pieces[0] == 'miscsorter') {
             $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."));
             }
             $sorter = new MiscSorter(true);
             $relID = $pieces[1];
             $res = $sorter->nfosorter(null, $relID, $nntp);