Updates to jb_fix_names, added script to update pehash md5

This commit is contained in:
DariusIII
2014-01-07 23:14:23 +01:00
parent 66aa1bc25f
commit fda0814c86
3 changed files with 66 additions and 7 deletions
+1 -1
View File
@@ -5,7 +5,7 @@ require(WWW_DIR.'/lib/postprocess.php');
require_once (WWW_DIR.'/lib/site.php');
require_once("../test/ColorCLI.php");
$version="0.3r576";
$version="0.3r577";
$db = new DB();
$s = new Sites();
+24 -6
View File
@@ -29,7 +29,7 @@ function preName($argv)
$groups = new Groups();
$category = new Category();
$functions = new Functions();
$updated = $counted = $none = 0;
$internal = $external = $pre = $none = 0;
$counter = 0;
$c = new ColorCLI();
$n = "\n";
@@ -70,6 +70,11 @@ function preName($argv)
} else {
$increment = false;
}
if (isset($cleanerName["predb"])) {
$predb = $cleanerName["predb"];
} else {
$predb = false;
}
}
if ($cleanName != '') {
@@ -120,9 +125,11 @@ function preName($argv)
$c->headerOver("Method: ") . $c->primary("renametopre regexes").
$c->headerOver("ReleaseID: ") . $c->primary($row["id"]); */
if ($increment === true) {
$updated++;
$internal++;
} else if ($predb === true) {
$pre++;
} else if ($propername === true) {
$counted++;
$external++;
}
}
}
@@ -134,10 +141,10 @@ function preName($argv)
echo $c->header(" [internal][external] processed/total");
}
$consoletools->overWritePrimary("Renamed NZBs: [${updated}][${counted}] " . $consoletools->percentString( ++$counter, $total));
$consoletools->overWritePrimary("Renamed Releases: [Internal=" . number_format($internal) . "][External=" . number_format($external) . "][Predb=" . number_format($pre) . "] " . $consoletools->percentString( ++$counter, $total));
}
}
echo $c->header("\n" . number_format($updated) . " renamed using namecleaning.php\n" . number_format($counted) . " using renametopre.php\nout of " . number_format($total) . " releases.\n");
echo $c->header("\n" . number_format($internal) . " renamed using namecleaning.php\n" . number_format($external) . " using renametopre.php\nout of " . number_format($total) . " releases.\n");
echo $c->header("Categorizing all non-categorized releases in other->misc using usenet subject. This can take a while, be patient.");
$timestart = TIME();
if (isset($argv[1]) && $argv[1] == "full") {
@@ -225,9 +232,20 @@ function resetSearchnames()
function releaseCleaner($subject, $groupID, $groupname)
{
$groups = new Groups();
$db = new DB();
$match = '';
// Get pre style name from releases.name
if (preg_match('/(\w+\.(\w+\.)+\w+-\w+)/', $subject, $match)) {
$title = $db->queryOneRow("SELECT title, ID from prehash WHERE title = " . $db->escapeString(trim($match[1])) . " OR title = " . $db->escapeString(trim($match[2])));
if (isset($title['title'])) {
$cleanerName = $title['title'];
if (!empty($cleanerName)) {
return array("cleansubject" => $cleanerName, "properlynamed" => true, "increment" => false, "predb" => true);
}
}
}
$functions = new Functions();
$groupName = $functions->getByNameByID($groupID);
$db = new DB();
$namecleaning = new nameCleaning();
$propername = true;
$cleanName = '';
+41
View File
@@ -0,0 +1,41 @@
<?php
require_once(dirname(__FILE__)."/../bin/config.php");
require_once(WWW_DIR. "lib/framework/db.php");
require_once(WWW_DIR."lib/category.php");
require_once("ColorCLI.php");
require_once("consoletools.php");
$db = new DB();
$consoletools = new ConsoleTools();
$c = new ColorCLI();
if (!isset($argv[1]) || $argv[1] != 'true') {
exit($c->error("\nThis script will recalculate and update the MD5 column for each pre.\n\n"
. "php $argv[0] true ...: To reset every predb MD5.\n"));
}
// Drop the unique index
$has_index = $db->queryDirect("SHOW INDEXES IN prehash WHERE Key_name = 'ix_prehash_md5'");
if ($has_index->rowCount() > 0) {
echo $c->info("Dropping index ix_prehash_md5.");
$db->queryDirect("DROP index ix_prehash_md5 ON prehash");
}
$res = $db->queryDirect("SELECT ID, title FROM prehash");
$total = $res->rowCount();
$deleted = $count = 0;
echo $c->header("Updating MD5's on $total preDB's.");
foreach ($res as $row) {
$name = trim($row['title']);
$md5 = $db->escapeString(md5($name));
$title = $db->escapeString($name);
$db->queryDirect(sprintf("UPDATE prehash SET title = %s, hash = %s WHERE ID = %d", $title, $md5, $row['ID']));
$consoletools->overWriteHeader("Reset MD5s: " . $consoletools->percentString(++$count, $total));
}
//Re-create the unique index, dropping dupes
echo $c->info("\nCreating index ix_prehash_md5.");
$db->queryDirect("ALTER IGNORE TABLE prehash ADD CONSTRAINT ix_prehash_md5 UNIQUE (hash)");
echo $c->header("\nDone.");