/** * Reset some variables for the current release. */ protected function _resetReleaseStatus() { // Only process for samples, previews and images if not disabled. $this->_foundVideo = $this->_processVideo ? false : true; $this->_foundMediaInfo = $this->_processMediaInfo ? false : true; $this->_foundAudioInfo = $this->_processAudioInfo ? false : true; $this->_foundAudioSample = $this->_processAudioSample ? false : true; $this->_foundJPGSample = $this->_processJPGSample ? false : true; $this->_foundSample = $this->_processThumbnails ? false : true; $this->_foundSample = $this->_release['disablepreview'] == 1 ? true : false; $this->_foundPAR2Info = false; $this->_passwordStatus = [Releases::PASSWD_NONE]; $this->_releaseHasPassword = false; $this->_releaseGroupName = $this->_groups->getByNameByID($this->_release['group_id']); $this->_releaseHasNoNFO = false; // Make sure we don't already have an nfo. if ($this->_release['nfostatus'] != 1) { $this->_releaseHasNoNFO = true; } $this->_NZBHasCompressedFile = false; $this->_sampleMessageIDs = $this->_JPGMessageIDs = $this->_MediaInfoMessageIDs = []; $this->_AudioInfoMessageIDs = $this->_RARFileMessageIDs = []; $this->_AudioInfoExtension = ''; $this->_addedFileInfo = 0; $this->_totalFileInfo = 0; $this->_compressedFilesChecked = 0; }
echo $pdo->log->info("Creating new collections, binaries, and parts tables for each group that has collections."); foreach ($actgroups as $group) { $pdo->queryExec("DROP TABLE IF EXISTS collections_" . $group['group_id']); $pdo->queryExec("DROP TABLE IF EXISTS binaries_" . $group['group_id']); $pdo->queryExec("DROP TABLE IF EXISTS parts_" . $group['group_id']); if ($groups->createNewTPGTables($group['group_id']) === false) { exit($pdo->log->error("\nThere is a problem creating new parts/files tables for group {$group['name']}.\n")); } } $collections_rows = $pdo->queryDirect("SELECT group_id FROM collections GROUP BY group_id"); echo $pdo->log->info("Counting parts, this could table a few minutes."); $parts_count = $pdo->queryOneRow("SELECT COUNT(*) AS cnt FROM parts"); $i = 0; if ($collections_rows instanceof \Traversable) { foreach ($collections_rows as $row) { $groupName = $groups->getByNameByID($row['group_id']); echo $pdo->log->header("Processing {$groupName}"); //collection $pdo->queryExec("INSERT IGNORE INTO collections_" . $row['group_id'] . " (subject, fromname, date, xref, totalfiles, group_id, collectionhash, dateadded, filecheck, filesize, releaseid) " . "SELECT subject, fromname, date, xref, totalfiles, group_id, collectionhash, dateadded, filecheck, filesize, releaseid FROM collections WHERE group_id = {$row['group_id']}"); $collections = $pdo->queryOneRow("SELECT COUNT(*) AS cnt FROM collections where group_id = " . $row['group_id']); $ncollections = $pdo->queryOneRow("SELECT COUNT(*) AS cnt FROM collections_" . $row['group_id']); echo $pdo->log->primary("Group {$groupName}, Collections = {$collections['cnt']} [{$ncollections['cnt']}]"); //binaries $pdo->queryExec("INSERT IGNORE INTO binaries_{$row['group_id']} (name, filenumber, totalparts, currentparts, binaryhash, partcheck, partsize, collection_id) " . "SELECT name, filenumber, totalparts, currentparts, binaryhash, partcheck, partsize, n.id FROM binaries b " . "INNER JOIN collections c ON b.collection_id = c.id " . "INNER JOIN collections_{$row['group_id']} n ON c.collectionhash = n.collectionhash AND c.group_id = {$row['group_id']}"); $binaries = $pdo->queryOneRow("SELECT COUNT(*) AS cnt FROM binaries b INNER JOIN collections c ON b.collection_id = c.id where c.group_id = {$row['group_id']}"); $nbinaries = $pdo->queryOneRow("SELECT COUNT(*) AS cnt FROM binaries_{$row['group_id']}"); echo $pdo->log->primary("Group {$groupName}, Binaries = {$binaries['cnt']} [{$nbinaries['cnt']}]"); //parts $pdo->queryExec("INSERT IGNORE INTO parts_{$row['group_id']} (messageid, number, partnumber, size, binaryid, collection_id) " . "SELECT messageid, number, partnumber, size, n.id, c.id FROM parts p " . "INNER JOIN binaries b ON p.binaryid = b.id " . "INNER JOIN binaries_{$row['group_id']} n ON b.binaryhash = n.binaryhash " . "INNER JOIN collections_{$row['group_id']} c on c.id = n.collection_id AND c.group_id = {$row['group_id']}"); $parts = $pdo->queryOneRow("SELECT COUNT(*) AS cnt FROM parts p INNER JOIN binaries b ON p.binaryid = b.id INNER JOIN collections c ON b.collection_id = c.id WHERE c.group_id = {$row['group_id']}"); $nparts = $pdo->queryOneRow("SELECT COUNT(*) AS cnt FROM parts_{$row['group_id']}");
/** * 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; }
/** * Update the release with the new information. * * @param array $release * @param string $name * @param string $method * @param boolean $echo * @param string $type * @param int $nameStatus * @param int $show * @param int $preId */ public function updateRelease($release, $name, $method, $echo, $type, $nameStatus, $show, $preId = 0) { if ($this->relid !== $release['releaseid']) { $releaseCleaning = new ReleaseCleaning($this->pdo); $newName = $releaseCleaning->fixerCleaner($name); if (strtolower($newName) != strtolower($release["searchname"])) { $this->matched = true; $this->relid = $release["releaseid"]; $determinedCategory = $this->category->determineCategory($release['group_id'], $newName); if ($type === "PAR2, ") { $newName = ucwords($newName); if (preg_match('/(.+?)\\.[a-z0-9]{2,3}(PAR2)?$/i', $name, $match)) { $newName = $match[1]; } } $this->fixed++; $newName = explode("\\", $newName); $newName = preg_replace(['/^[-=_\\.:\\s]+/', '/[-=_\\.:\\s]+$/'], '', $newName[0]); if ($this->echooutput === true && $show === 1) { $groupName = $this->_groups->getByNameByID($release['group_id']); $oldCatName = $this->category->getNameByID($release['categoryid']); $newCatName = $this->category->getNameByID($determinedCategory); if ($type === "PAR2, ") { echo PHP_EOL; } echo $this->pdo->log->headerOver("\nNew name: ") . $this->pdo->log->primary(substr($newName, 0, 255)) . $this->pdo->log->headerOver("Old name: ") . $this->pdo->log->primary($release["searchname"]) . $this->pdo->log->headerOver("Use name: ") . $this->pdo->log->primary($release["name"]) . $this->pdo->log->headerOver("New cat: ") . $this->pdo->log->primary($newCatName) . $this->pdo->log->headerOver("Old cat: ") . $this->pdo->log->primary($oldCatName) . $this->pdo->log->headerOver("Group: ") . $this->pdo->log->primary($groupName) . $this->pdo->log->headerOver("Method: ") . $this->pdo->log->primary($type . $method) . $this->pdo->log->headerOver("ReleaseID: ") . $this->pdo->log->primary($release["releaseid"]); if (isset($release['filename']) && $release['filename'] != "") { echo $this->pdo->log->headerOver("Filename: ") . $this->pdo->log->primary($release["filename"]); } if ($type !== "PAR2, ") { echo "\n"; } } $newTitle = $this->pdo->escapeString(substr($newName, 0, 255)); if ($echo == true) { if ($nameStatus == 1) { $status = ''; switch ($type) { case "NFO, ": $status = "isrenamed = 1, iscategorized = 1, proc_nfo = 1,"; break; case "PAR2, ": $status = "isrenamed = 1, iscategorized = 1, proc_par2 = 1,"; break; case "Filenames, ": case "file matched source: ": $status = "isrenamed = 1, iscategorized = 1, proc_files = 1,"; break; case "SHA1, ": case "MD5, ": $status = "isrenamed = 1, iscategorized = 1, dehashstatus = 1,"; break; case "PreDB FT Exact, ": $status = "isrenamed = 1, iscategorized = 1,"; break; case "sorter ": $status = "isrenamed = 1, iscategorized = 1, proc_sorter = 1,"; break; } $this->pdo->queryExec(sprintf(' UPDATE releases SET videos_id = 0, tv_episodes_id = 0, imdbid = NULL, musicinfoid = NULL, consoleinfoid = NULL, bookinfoid = NULL, anidbid = NULL, preid = %d, searchname = %s, %s categoryid = %d WHERE id = %d', $preId, $newTitle, $status, $determinedCategory, $release['releaseid'])); $this->sphinx->updateRelease($release['releaseid'], $this->pdo); } else { $newTitle = $this->pdo->escapeString(substr($newName, 0, 255)); $this->pdo->queryExec(sprintf(' UPDATE releases SET videos_id = 0, tv_episodes_id = 0, imdbid = NULL, musicinfoid = NULL, consoleinfoid = NULL, bookinfoid = NULL, anidbid = NULL, preid = %d, searchname = %s, iscategorized = 1, categoryid = %d WHERE id = %d', $preId, $newTitle, $determinedCategory, $release['releaseid'])); $this->sphinx->updateRelease($release['releaseid'], $this->pdo); } } } } $this->done = true; }
/** * Attempt to get a better name from a par2 file and categorize the release. * * @note Called from NZBContents.php * * @param string $messageID MessageID from NZB file. * @param int $relID ID of the release. * @param int $groupID Group ID of the release. * @param \nzedb\NNTP $nntp Class NNTP * @param int $show Only show result or apply iy. * * @return bool */ public function parsePAR2($messageID, $relID, $groupID, &$nntp, $show) { if ($messageID === '') { return false; } $query = $this->pdo->queryOneRow(sprintf(' SELECT id, group_id, categoryid, name, searchname, UNIX_TIMESTAMP(postdate) AS post_date, id AS releaseid FROM releases WHERE isrenamed = 0 AND id = %d', $relID)); if ($query === false) { return false; } // Only get a new name if the category is OTHER. $foundName = true; if (!in_array((int) $query['categoryid'], [Category::CAT_BOOKS_OTHER, Category::CAT_GAME_OTHER, Category::CAT_MOVIE_OTHER, Category::CAT_MUSIC_OTHER, Category::CAT_PC_PHONE_OTHER, Category::CAT_TV_OTHER, Category::CAT_OTHER_HASHED, Category::CAT_XXX_OTHER, Category::CAT_MISC])) { $foundName = false; } // Get the PAR2 file. $par2 = $nntp->getMessages($this->groups->getByNameByID($groupID), $messageID, $this->alternateNNTP); if ($nntp->isError($par2)) { return false; } // Put the PAR2 into Par2Info, check if there's an error. $this->_par2Info->setData($par2); if ($this->_par2Info->error) { return false; } // Get the file list from Par2Info. $files = $this->_par2Info->getFileList(); if ($files !== false && count($files) > 0) { $filesAdded = 0; // Loop through the files. foreach ($files as $file) { if (!isset($file['name'])) { continue; } // If we found a name and added 10 files, stop. if ($foundName === true && $filesAdded > 10) { break; } if ($this->addpar2) { // Add to release files. if ($filesAdded < 11 && $this->pdo->queryOneRow(sprintf(' SELECT id FROM release_files WHERE releaseid = %d AND name = %s', $relID, $this->pdo->escapeString($file['name']))) === false) { // Try to add the files to the DB. if ($this->releaseFiles->add($relID, $file['name'], $file['size'], $query['post_date'], 0)) { $filesAdded++; } } } else { $filesAdded++; } // Try to get a new name. if ($foundName === false) { $query['textstring'] = $file['name']; if ($this->nameFixer->checkName($query, 1, 'PAR2, ', 1, $show) === true) { $foundName = true; } } } // If we found some files. if ($filesAdded > 0) { $this->debugging->log('PostProcess', 'parsePAR2', 'Added ' . $filesAdded . ' release_files from PAR2 for ' . $query['searchname'], Logger::LOG_INFO); // Update the file count with the new file count + old file count. $this->pdo->queryExec(sprintf(' UPDATE releases SET rarinnerfilecount = rarinnerfilecount + %d WHERE id = %d', $filesAdded, $relID)); } if ($foundName === true) { return true; } } return false; }
function preName($argv, $argc) { global $pdo; $groups = new Groups(['Settings' => $pdo]); $category = new Categorize(['Settings' => $pdo]); $internal = $external = $pre = 0; $show = 2; if ($argv[$argc - 1] === 'show') { $show = 1; } else { if ($argv[$argc - 1] === 'bad') { $show = 3; } } $counter = 0; $pdo->log = new ColorCLI(); $full = $all = $usepre = false; $what = $where = ''; if ($argv[1] === 'full') { $full = true; } else { if ($argv[1] === 'all') { $all = true; } else { if ($argv[1] === 'preid') { $usepre = true; } else { if (is_numeric($argv[1])) { $what = ' AND adddate > NOW() - INTERVAL ' . $argv[1] . ' HOUR'; } } } } if ($usepre === true) { $where = ''; $why = ' WHERE preid = 0 AND nzbstatus = 1'; } else { if (isset($argv[1]) && is_numeric($argv[1])) { $where = ''; $why = ' WHERE nzbstatus = 1 AND isrenamed = 0'; } else { if (isset($argv[2]) && is_numeric($argv[2]) && $full === true) { $where = ' AND group_id = ' . $argv[2]; $why = ' WHERE nzbstatus = 1 AND isrenamed = 0'; } else { if (isset($argv[2]) && preg_match('/\\([\\d, ]+\\)/', $argv[2]) && $full === true) { $where = ' AND group_id IN ' . $argv[2]; $why = ' WHERE nzbstatus = 1 AND isrenamed = 0'; } else { if (isset($argv[2]) && preg_match('/\\([\\d, ]+\\)/', $argv[2]) && $all === true) { $where = ' AND group_id IN ' . $argv[2]; $why = ' WHERE nzbstatus = 1'; } else { if (isset($argv[2]) && is_numeric($argv[2]) && $all === true) { $where = ' AND group_id = ' . $argv[2]; $why = ' WHERE nzbstatus = 1 and preid = 0'; } else { if (isset($argv[2]) && is_numeric($argv[2])) { $where = ' AND group_id = ' . $argv[2]; $why = ' WHERE nzbstatus = 1 AND isrenamed = 0'; } else { if ($full === true) { $why = ' WHERE nzbstatus = 1 AND (isrenamed = 0 OR categoryid between 7000 AND 7999)'; } else { if ($all === true) { $why = ' WHERE nzbstatus = 1'; } else { $why = ' WHERE 1=1'; } } } } } } } } } resetSearchnames(); echo $pdo->log->header("SELECT id, name, searchname, fromname, size, group_id, categoryid FROM releases" . $why . $what . $where . ";\n"); $res = $pdo->queryDirect("SELECT id, name, searchname, fromname, size, group_id, categoryid FROM releases" . $why . $what . $where); $total = $res->rowCount(); if ($total > 0) { $consoletools = new ConsoleTools(['ColorCLI' => $pdo->log]); foreach ($res as $row) { $groupname = $groups->getByNameByID($row['group_id']); $cleanerName = releaseCleaner($row['name'], $row['fromname'], $row['size'], $groupname, $usepre); $preid = 0; $predb = $predbfile = $increment = false; if (!is_array($cleanerName)) { $cleanName = trim((string) $cleanerName); $propername = $increment = true; if ($cleanName != '' && $cleanerName != false) { $run = $pdo->queryOneRow("SELECT id FROM predb WHERE title = " . $pdo->escapeString($cleanName)); if (isset($run['id'])) { $preid = $run['id']; $predb = true; } } } else { $cleanName = trim($cleanerName["cleansubject"]); $propername = $cleanerName["properlynamed"]; if (isset($cleanerName["increment"])) { $increment = $cleanerName["increment"]; } if (isset($cleanerName["predb"])) { $preid = $cleanerName["predb"]; $predb = true; } } if ($cleanName != '') { if (preg_match('/alt\\.binaries\\.e\\-?book(\\.[a-z]+)?/', $groupname)) { if (preg_match('/^[0-9]{1,6}-[0-9]{1,6}-[0-9]{1,6}$/', $cleanName, $match)) { $rf = new ReleaseFiles($pdo); $files = $rf->get($row['id']); foreach ($files as $f) { if (preg_match('/^(?P<title>.+?)(\\[\\w\\[\\]\\(\\). -]+)?\\.(pdf|htm(l)?|epub|mobi|azw|tif|doc(x)?|lit|txt|rtf|opf|fb2|prc|djvu|cb[rz])/', $f["name"], $match)) { $cleanName = $match['title']; break; } } } } //try to match clean name against predb filename $prefile = $pdo->queryOneRow("SELECT id, title FROM predb WHERE filename = " . $pdo->escapeString($cleanName)); if (isset($prefile['id'])) { $preid = $prefile['id']; $cleanName = $prefile['title']; $predbfile = true; $propername = true; } if ($cleanName != $row['name'] && $cleanName != $row['searchname']) { if (strlen(utf8_decode($cleanName)) <= 3) { } else { $determinedcat = $category->determineCategory($row["group_id"], $cleanName); if ($propername == true) { $pdo->queryExec(sprintf("UPDATE releases SET videos_id = 0, tv_episodes_id = 0, imdbid = NULL, musicinfoid = NULL, consoleinfoid = NULL, bookinfoid = NULL, anidbid = NULL, " . "iscategorized = 1, isrenamed = 1, searchname = %s, categoryid = %d, preid = " . $preid . " WHERE id = %d", $pdo->escapeString($cleanName), $determinedcat, $row['id'])); } else { $pdo->queryExec(sprintf("UPDATE releases SET videos_id = 0, tv_episodes_id = 0, imdbid = NULL, musicinfoid = NULL, consoleinfoid = NULL, bookinfoid = NULL, anidbid = NULL, " . "iscategorized = 1, searchname = %s, categoryid = %d, preid = " . $preid . " WHERE id = %d", $pdo->escapeString($cleanName), $determinedcat, $row['id'])); } if ($increment === true) { $internal++; } else { if ($predb === true) { $pre++; } else { if ($predbfile === true) { $pre++; } else { if ($propername === true) { $external++; } } } } if ($show === 1) { $oldcatname = $category->getNameByID($row["categoryid"]); $newcatname = $category->getNameByID($determinedcat); NameFixer::echoChangedReleaseName(['new_name' => $cleanName, 'old_name' => $row["searchname"], 'new_category' => $newcatname, 'old_category' => $oldcatname, 'group' => $groupname, 'release_id' => $row["id"], 'method' => 'misc/testing/Various/renametopre.php']); } } } else { if ($show === 3 && preg_match('/^\\[?\\d*\\].+?yEnc/i', $row['name'])) { echo $pdo->log->primary($row['name']); } } } if ($cleanName == $row['name']) { $pdo->queryExec(sprintf("UPDATE releases SET isrenamed = 1, iscategorized = 1 WHERE id = %d", $row['id'])); } if ($show === 2 && $usepre === false) { $consoletools->overWritePrimary("Renamed Releases: [Internal=" . number_format($internal) . "][External=" . number_format($external) . "][Predb=" . number_format($pre) . "] " . $consoletools->percentString(++$counter, $total)); } else { if ($show === 2 && $usepre === true) { $consoletools->overWritePrimary("Renamed Releases: [" . number_format($pre) . "] " . $consoletools->percentString(++$counter, $total)); } } } } echo $pdo->log->header("\n" . number_format($pre) . " renamed using preDB Match\n" . number_format($external) . " renamed using ReleaseCleaning.php\n" . number_format($internal) . " using renametopre.php\nout of " . number_format($total) . " releases.\n"); if (isset($argv[1]) && is_numeric($argv[1]) && !isset($argv[2])) { echo $pdo->log->header("Categorizing all releases using searchname from the last {$argv[1]} hours. This can take a while, be patient."); } else { if (isset($argv[1]) && $argv[1] !== "all" && isset($argv[2]) && !is_numeric($argv[2]) && !preg_match('/\\([\\d, ]+\\)/', $argv[2])) { echo $pdo->log->header("Categorizing all non-categorized releases in other->misc using searchname. This can take a while, be patient."); } else { if (isset($argv[1]) && isset($argv[2]) && (is_numeric($argv[2]) || preg_match('/\\([\\d, ]+\\)/', $argv[2]))) { echo $pdo->log->header("Categorizing all non-categorized releases in {$argv[2]} using searchname. This can take a while, be patient."); } else { echo $pdo->log->header("Categorizing all releases using searchname. This can take a while, be patient."); } } } $timestart = TIME(); if (isset($argv[1]) && is_numeric($argv[1])) { $relcount = catRelease("searchname", "WHERE (iscategorized = 0 OR categoryID = 0010) AND adddate > NOW() - INTERVAL " . $argv[1] . " HOUR", true); } else { if (isset($argv[2]) && preg_match('/\\([\\d, ]+\\)/', $argv[2]) && $full === true) { $relcount = catRelease("searchname", str_replace(" AND", "WHERE", $where) . " AND iscategorized = 0 ", true); } else { if (isset($argv[2]) && preg_match('/\\([\\d, ]+\\)/', $argv[2]) && $all === true) { $relcount = catRelease("searchname", str_replace(" AND", "WHERE", $where), true); } else { if (isset($argv[2]) && is_numeric($argv[2]) && $argv[1] == "full") { $relcount = catRelease("searchname", str_replace(" AND", "WHERE", $where) . " AND iscategorized = 0 ", true); } else { if (isset($argv[2]) && is_numeric($argv[2]) && $argv[1] == "all") { $relcount = catRelease("searchname", str_replace(" AND", "WHERE", $where), true); } else { if (isset($argv[1]) && $argv[1] == "full") { $relcount = catRelease("searchname", "WHERE categoryID = 0010 OR iscategorized = 0", true); } else { if (isset($argv[1]) && $argv[1] == "all") { $relcount = catRelease("searchname", "", true); } else { if (isset($argv[1]) && $argv[1] == "preid") { $relcount = catRelease("searchname", "WHERE preid = 0 AND nzbstatus = 1", true); } else { $relcount = catRelease("searchname", "WHERE (iscategorized = 0 OR categoryID = 0010) AND adddate > NOW() - INTERVAL " . $argv[1] . " HOUR", true); } } } } } } } } $consoletools = new ConsoleTools(['ColorCLI' => $pdo->log]); $time = $consoletools->convertTime(TIME() - $timestart); echo $pdo->log->header("Finished categorizing " . number_format($relcount) . " releases in " . $time . " seconds, using the usenet subject.\n"); resetSearchnames(); }