diffInSeconds($timestart); if ($update === true) { echo ColorCLI::header('Finished re-categorizing '.number_format($chgcount).' releases in '.$time.' , using the searchname.'.PHP_EOL); } else { echo ColorCLI::header('Finished re-categorizing in '.$time.' seconds , using the searchname.'.PHP_EOL .'This would have changed '.number_format($chgcount).' releases but no updates were done.'.PHP_EOL); } } // Categorizes releases. // Returns the quantity of categorized releases. function categorizeRelease($where, $update = true, $echooutput = false) { $cat = new Categorize(); $consoletools = new ConsoleTools(); $relcount = $chgcount = 0; echo ColorCLI::primary('SELECT id, searchname, fromname, groups_id, categories_id FROM releases '.$where); $resrel = DB::select('SELECT id, searchname, fromname, groups_id, categories_id FROM releases '.$where); $total = \count($resrel); if ($total > 0) { foreach ($resrel as $rowrel) { $catId = $cat->determineCategory($rowrel->groups_id, $rowrel->searchname, $rowrel->fromname); if ((int) $rowrel->categories_id !== $catId) { if ($update === true) { DB::update( sprintf( ' UPDATE releases SET iscategorized = 1, videos_id = 0, tv_episodes_id = 0, imdbid = NULL, musicinfo_id = NULL, consoleinfo_id = NULL, gamesinfo_id = 0, bookinfo_id = NULL, anidbid = NULL, xxxinfo_id = 0, categories_id = %d WHERE id = %d', $catId, $rowrel->id ) ); } $chgcount++; } $relcount++; if ($echooutput) { $consoletools->overWritePrimary('Re-Categorized: ['.number_format($chgcount).'] '.$consoletools->percentString($relcount, $total)); } } } if ($echooutput !== false && $relcount > 0) { echo PHP_EOL; } return $chgcount; }