function categorizeRelease($update = true, $where, $echooutput = false) { $pdo = new Settings(); $cat = new Categorize(); $consoletools = new consoleTools(); $relcount = $chgcount = 0; $c = new ColorCLI(); echo $c->primary("SELECT id, searchname, groupid, categoryid FROM releases " . $where); $resrel = $pdo->queryDirect("SELECT id, searchname, groupid, categoryid FROM releases " . $where); $total = $resrel->rowCount(); if ($total > 0) { foreach ($resrel as $rowrel) { $catId = $cat->determineCategory($rowrel['groupid'], $rowrel['searchname']); if ($rowrel['categoryid'] != $catId) { if ($update === true) { $pdo->queryExec(sprintf("\n\t\t\t\t\t\t\tUPDATE releases\n\t\t\t\t\t\t\tSET iscategorized = 1,\n\t\t\t\t\t\t\t\trageid = -1,\n\t\t\t\t\t\t\t\tseriesfull = NULL,\n\t\t\t\t\t\t\t\tseason = NULL,\n\t\t\t\t\t\t\t\tepisode = NULL,\n\t\t\t\t\t\t\t\ttvtitle = NULL,\n\t\t\t\t\t\t\t\ttvairdate = NULL,\n\t\t\t\t\t\t\t\timdbid = NULL,\n\t\t\t\t\t\t\t\tmusicinfoid = NULL,\n\t\t\t\t\t\t\t\tconsoleinfoid = NULL,\n\t\t\t\t\t\t\t\tgamesinfo_id = 0,\n\t\t\t\t\t\t\t\txxxinfo_id = 0,\n\t\t\t\t\t\t\t\tbookinfoid = NULL,\n\t\t\t\t\t\t\t\tanidbid = NULL,\n\t\t\t\t\t\t\t\tcategoryid = %d\n\t\t\t\t\t\t\tWHERE 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 "\n"; } return $chgcount; }
function catRelease($type, $where, $echooutput = false) { global $pdo; $cat = new Categorize(['Settings' => $pdo]); $consoletools = new consoleTools(['ColorCLI' => $pdo->log]); $relcount = 0; echo $pdo->log->primary("SELECT id, " . $type . ", group_id FROM releases " . $where); $resrel = $pdo->queryDirect("SELECT id, " . $type . ", group_id FROM releases " . $where); $total = $resrel->rowCount(); if ($total > 0) { foreach ($resrel as $rowrel) { $catId = $cat->determineCategory($rowrel[$type], $rowrel['group_id']); $pdo->queryExec(sprintf("UPDATE releases SET iscategorized = 1, categoryid = %d WHERE id = %d", $catId, $rowrel['id'])); $relcount++; if ($echooutput) { $consoletools->overWritePrimary("Categorizing: " . $consoletools->percentString($relcount, $total)); } } } if ($echooutput !== false && $relcount > 0) { echo "\n"; } return $relcount; }