This commit is contained in:
DariusIII
2014-01-30 00:33:07 +01:00
parent 456befd480
commit e0cd73ddaf
3 changed files with 24 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.3r646";
$version="0.3r650";
$db = new DB();
$s = new Sites();
+7 -6
View File
@@ -203,8 +203,9 @@ Class Predb
{
if (preg_match('/<title>(?P<title>.+?)<\/title.+?pubDate>(?P<date>.+?)<\/pubDate.+?gory:<\/b> (?P<category>.+?)<br \/.+?<\/b> (?P<size1>.+?) (?P<size2>[a-zA-Z]+)<b/s', $m, $matches2))
{
$md5 = md5($matches2["title"]);
$oldname = $db->queryOneRow(sprintf("SELECT title, source, ID FROM prehash WHERE title = %s", $db->escapeString($md5)));
$title = preg_replace('/\s+- omgwtfnzbs\.org/', '', $matches2['title']);
$md5 = md5($title);
$oldname = $db->queryOneRow(sprintf('SELECT md5, source, ID FROM prehash WHERE md5 = %s', $db->escapeString($md5)));
if ($oldname !== false && $oldname["md5"] == $md5)
{
if ($oldname["source"] == "womble")
@@ -221,7 +222,6 @@ Class Predb
else
{
$size = $db->escapeString(round($matches2["size1"]).$matches2["size2"]);
$title = preg_replace("/ - omgwtfnzbs.org/", "", $matches2["title"]);
$db->exec(sprintf("INSERT IGNORE INTO prehash (title, size, category, predate, adddate, source, md5) VALUES (%s, %s, %s, FROM_UNIXTIME(".strtotime($matches2["date"])."), now(), %s, %s)", $db->escapeString($title), $size, $db->escapeString($matches2["category"]), $db->escapeString("omgwtfnzbs"), $db->escapeString($md5)));
$newnames++;
}
@@ -728,11 +728,12 @@ Class Predb
{
$db = new DB();
$f = new Functions();
$x = '';
if ($db->queryOneRow(sprintf('SELECT ID FROM prehash WHERE title = %s', $db->escapeString($cleanerName))) !== false)
{
$x = $db->queryOneRow(sprintf('SELECT ID FROM prehash WHERE title = %s', $db->escapeString($cleanerName)));
if (isset($x['ID'])) {
$db->exec(sprintf('UPDATE releases SET preID = %d WHERE ID = %d', $x['ID'], $releaseID));
return true;
}
return false;
}
// When a searchname is the same as the title, tie it to the predb. Try to update the categoryID at the same time.
+16
View File
@@ -5,9 +5,11 @@ require_once(WWW_DIR. "lib/framework/db.php");
require_once(WWW_DIR."lib/category.php");
require_once("ColorCLI.php");
require_once("consoletools.php");
require_once("prehash.php");
$db = new DB();
$consoletools = new ConsoleTools();
$predb = new PreDb();
$c = new ColorCLI();
if (!isset($argv[1]) || $argv[1] != 'true') {
@@ -39,3 +41,17 @@ foreach ($res as $row) {
echo $c->info("\nCreating index ix_prehash_md5.");
$db->queryDirect("ALTER IGNORE TABLE prehash ADD CONSTRAINT ix_prehash_md5 UNIQUE (md5)");
echo $c->header("\nDone.");
$releases = $db->queryDirect("SELECT ID, searchname FROM releases WHERE preID IS NOT NULL");
$newtotal = $releases->rowCount();
$matched = $counter = 0;
foreach ($releases as $release) {
$run = $predb->matchPre($release['searchname'], $release['ID']);
if ($run === false) {
$db->exec(sprintf('UPDATE releases SET preID = NULL WHERE ID = %d', $release['ID']));
} else {
$matched++;
}
$consoletools->overWritePrimary("Matching Releases: [" . number_format($matched) . "] " . $consoletools->percentString( ++$counter, $newtotal));
}
echo $c->header("\nDone.");