$consoletools = new ConsoleTools(['ColorCLI' => $pdo->log]); $rc = new ReleaseCleaning($pdo); foreach ($res as $row) { $newname = $rc->releaseCleaner($row['name'], $row['fromname'], $row['size'], $row['gname']); if (is_array($newname)) { $newname = $newname['cleansubject']; } $newname = $pdo->escapeString($newname); $pdo->queryExec(sprintf("UPDATE releases SET searchname = %s WHERE id = %d", $newname, $row['id'])); $sphinx->updateReleaseSearchName($newname, $row['id']); $done++; $consoletools->overWritePrimary("Renaming:" . $consoletools->percentString($done, count($res))); } $timenc = $consoletools->convertTime(time() - $timestart); echo $pdo->log->header($done . " releases renamed in " . $timenc . ".\nNow the releases will be recategorized."); $releases = new ProcessReleases(['Settings' => $pdo, 'ConsoleTools' => $consoletools, 'ReleaseCleaning' => $rc]); $releases->resetCategorize("WHERE isrenamed = 0"); $categorized = $releases->categorizeRelease("name", "WHERE isrenamed = 0"); $timecat = $consoletools->convertTime(time() - $timestart); echo $pdo->log->header("Finished categorizing " . $categorized . " releases in " . $timecat . ".\nFinally, the releases will be fixed using the NFO/filenames."); $namefixer = new NameFixer(['Settings' => $pdo, 'ConsoleTools' => $consoletools]); $namefixer->fixNamesWithNfo(2, 1, 1, 1, $show); $namefixer->fixNamesWithFiles(2, 1, 1, 1, $show); $timetotal = $consoletools->convertTime(time() - $timestart); echo $pdo->log->header("Finished recreating search names / recategorizing / refixing names in " . $timetotal); } else { exit($pdo->log->info("You have no releases in the DB.")); } } else { if (isset($argv[1]) && $argv[1] == "reset") { $pdo = new Settings();
/** * Create / process releases for a groupID. * * @param ProcessReleases $releases * @param int $groupID */ function processReleases($releases, $groupID) { $releases->processIncompleteCollections($groupID); $releases->processCollectionSizes($groupID); $releases->deleteUnwantedCollections($groupID); $releases->createReleases($groupID); $releases->createNZBs($groupID); $releases->deleteCollections($groupID); }