Add patches to handle tables changes, adjust rest of the code for changes

This commit is contained in:
DariusIII
2016-01-15 10:03:36 +01:00
parent e9b59142a4
commit d044bbcaf1
41 changed files with 203 additions and 279 deletions
+10 -10
View File
@@ -29,7 +29,7 @@ if (isset($argv[1]) && $argv[1] == 'export' && isset($argv[2])) {
if (isset($argv[3])) {
$table = $argv[3];
} else {
$table = 'prehash';
$table = 'predb';
}
echo $pdo->log->header("SELECT title, nfo, size, files, filename, nuked, nukereason, category, predate, source, requestid, g.name FROM " . $table . " p LEFT OUTER JOIN groups g ON p.groupid = g.id INTO OUTFILE '" . $path . "' FIELDS TERMINATED BY '\\t\\t' ENCLOSED BY \"'\" LINES TERMINATED BY '\\r\\n';n");
$pdo->queryExec("SELECT title, nfo, size, files, filename, nuked, nukereason, category, predate, source, requestid, g.name FROM " . $table . " p LEFT OUTER JOIN groups g ON p.groupid = g.id INTO OUTFILE '" . $path . "' FIELDS TERMINATED BY '\t\t' ENCLOSED BY \"'\" LINES TERMINATED BY '\r\n'");
@@ -80,15 +80,15 @@ SQL_ADD_GROUPS;
INSERT INTO $table (title, nfo, size, files, filename, nuked, nukereason, category, predate, SOURCE, requestid, groupid)
SELECT t.title, t.nfo, t.size, t.files, t.filename, t.nuked, t.nukereason, t.category, t.predate, t.source, t.requestid, IF(g.id IS NOT NULL, g.id, 0)
FROM predb_imports AS t
LEFT OUTER JOIN groups g ON t.groupname = g.name ON DUPLICATE KEY UPDATE prehash.nfo = IF(prehash.nfo IS NULL, t.nfo, prehash.nfo),
prehash.size = IF(prehash.size IS NULL, t.size, prehash.size),
prehash.files = IF(prehash.files IS NULL, t.files, prehash.files),
prehash.filename = IF(prehash.filename = '', t.filename, prehash.filename),
prehash.nuked = IF(t.nuked > 0, t.nuked, prehash.nuked),
prehash.nukereason = IF(t.nuked > 0, t.nukereason, prehash.nukereason),
prehash.category = IF(prehash.category IS NULL, t.category, prehash.category),
prehash.requestid = IF(prehash.requestid = 0, t.requestid, prehash.requestid),
prehash.groupid = IF(g.id IS NOT NULL, g.id, 0);
LEFT OUTER JOIN groups g ON t.groupname = g.name ON DUPLICATE KEY UPDATE predb.nfo = IF(predb.nfo IS NULL, t.nfo, predb.nfo),
predb.size = IF(predb.size IS NULL, t.size, predb.size),
predb.files = IF(predb.files IS NULL, t.files, predb.files),
predb.filename = IF(predb.filename = '', t.filename, predb.filename),
predb.nuked = IF(t.nuked > 0, t.nuked, predb.nuked),
predb.nukereason = IF(t.nuked > 0, t.nukereason, predb.nukereason),
predb.category = IF(predb.category IS NULL, t.category, predb.category),
predb.requestid = IF(predb.requestid = 0, t.requestid, predb.requestid),
predb.groupid = IF(g.id IS NOT NULL, g.id, 0);
SQL_INSERT;
echo $pdo->log->primary($sqlInsert);
$pdo->queryExec($sqlInsert);
+7 -7
View File
@@ -66,7 +66,7 @@ function preName($argv, $argc)
}
if ($usepre === true) {
$where = '';
$why = ' WHERE prehashid = 0 AND nzbstatus = 1';
$why = ' WHERE preid = 0 AND nzbstatus = 1';
} else if (isset($argv[1]) && is_numeric($argv[1])) {
$where = '';
$why = ' WHERE nzbstatus = 1 AND isrenamed = 0';
@@ -81,7 +81,7 @@ function preName($argv, $argc)
$why = ' WHERE nzbstatus = 1';
} else if (isset($argv[2]) && is_numeric($argv[2]) && $all === true) {
$where = ' AND groupid = ' . $argv[2];
$why = ' WHERE nzbstatus = 1 and prehashid = 0';
$why = ' WHERE nzbstatus = 1 and preid = 0';
} else if (isset($argv[2]) && is_numeric($argv[2])) {
$where = ' AND groupid = ' . $argv[2];
$why = ' WHERE nzbstatus = 1 AND isrenamed = 0';
@@ -160,14 +160,14 @@ function preName($argv, $argc)
$pdo->queryExec(
sprintf(
"UPDATE releases SET videos_id = 0, tv_episodes_id = 0, imdbid = NULL, musicinfoid = NULL, consoleinfoid = NULL, bookinfoid = NULL, anidbid = NULL, "
. "iscategorized = 1, isrenamed = 1, searchname = %s, categoryid = %d, prehashid = " . $preid . " WHERE id = %d", $pdo->escapeString($cleanName), $determinedcat, $row['id']
. "iscategorized = 1, isrenamed = 1, searchname = %s, categoryid = %d, preid = " . $preid . " WHERE id = %d", $pdo->escapeString($cleanName), $determinedcat, $row['id']
)
);
} else {
$pdo->queryExec(
sprintf(
"UPDATE releases SET videos_id = 0, tv_episodes_id = 0, imdbid = NULL, musicinfoid = NULL, consoleinfoid = NULL, bookinfoid = NULL, anidbid = NULL, "
. "iscategorized = 1, searchname = %s, categoryid = %d, prehashid = " . $preid . " WHERE id = %d", $pdo->escapeString($cleanName), $determinedcat, $row['id']
. "iscategorized = 1, searchname = %s, categoryid = %d, preid = " . $preid . " WHERE id = %d", $pdo->escapeString($cleanName), $determinedcat, $row['id']
)
);
}
@@ -236,7 +236,7 @@ function preName($argv, $argc)
} else if (isset($argv[1]) && $argv[1] == "all") {
$relcount = catRelease("searchname", "", true);
} else if (isset($argv[1]) && $argv[1] == "preid") {
$relcount = catRelease("searchname", "WHERE prehashid = 0 AND nzbstatus = 1", true);
$relcount = catRelease("searchname", "WHERE preid = 0 AND nzbstatus = 1", true);
} else {
$relcount = catRelease("searchname", "WHERE (iscategorized = 0 OR categoryid = 8010) AND adddate > NOW() - INTERVAL " . $argv[1] . " HOUR", true);
}
@@ -252,7 +252,7 @@ function resetSearchnames()
echo $pdo->log->header("Resetting blank searchnames.");
$bad = $pdo->queryDirect(
"UPDATE releases SET videos_id = 0, tv_episodes_id = 0, imdbid = NULL, musicinfoid = NULL, consoleinfoid = NULL, bookinfoid = NULL, anidbid = NULL, "
. "prehashid = 0, searchname = name, isrenamed = 0, iscategorized = 0 WHERE searchname = ''"
. "preid = 0, searchname = name, isrenamed = 0, iscategorized = 0 WHERE searchname = ''"
);
$tot = $bad->rowCount();
if ($tot > 0) {
@@ -261,7 +261,7 @@ function resetSearchnames()
echo $pdo->log->header("Resetting searchnames that are 8 characters or less.");
$run = $pdo->queryDirect(
"UPDATE releases SET videos_id = 0, tv_episodes_id = 0, imdbid = NULL, musicinfoid = NULL, consoleinfoid = NULL, bookinfoid = NULL, anidbid = NULL, "
. "prehashid = 0, searchname = name, isrenamed = 0, iscategorized = 0 WHERE LENGTH(searchname) <= 8 AND LENGTH(name) > 8"
. "preid = 0, searchname = name, isrenamed = 0, iscategorized = 0 WHERE LENGTH(searchname) <= 8 AND LENGTH(name) > 8"
);
$total = $run->rowCount();
if ($total > 0) {
+1 -1
View File
@@ -31,7 +31,7 @@ function getPreName($argv)
$res = false;
if (isset($argv[1]) && $argv[1] === "all") {
$res = $pdo->queryDirect('SELECT id AS releaseid, name, searchname, groupid, categoryid, dehashstatus FROM releases WHERE prehashid = 0 AND ishashed = 1');
$res = $pdo->queryDirect('SELECT id AS releaseid, name, searchname, groupid, categoryid, dehashstatus FROM releases WHERE preid = 0 AND ishashed = 1');
} else if (isset($argv[1]) && $argv[1] === "full") {
$res = $pdo->queryDirect('SELECT id AS releaseid, name, searchname, groupid, categoryid, dehashstatus FROM releases WHERE categoryid = 7020 AND ishashed = 1 AND dehashstatus BETWEEN -6 AND 0');
} else if (isset($argv[1]) && is_numeric($argv[1])) {
@@ -87,7 +87,7 @@ if (!isset($argv[1])) {
} else if (isset($pieces[1]) && $pieces[0] == 'predbft') {
$pre = $pieces[1];
if ($res = $db->queryOneRow(sprintf('SELECT id AS preid, title, source, searched FROM prehash '
if ($res = $db->queryOneRow(sprintf('SELECT id AS preid, title, source, searched FROM predb '
. 'WHERE id = %d', $pre
)
)
@@ -104,7 +104,7 @@ if (!isset($argv[1])) {
$searched = $res['searched'] - 1;
echo ".";
}
$db->queryExec(sprintf("UPDATE prehash SET searched = %d WHERE id = %d", $searched, $res['preid']));
$db->queryExec(sprintf("UPDATE predb SET searched = %d WHERE id = %d", $searched, $res['preid']));
$namefixer->checked++;
}
@@ -32,7 +32,7 @@ if (!isset($argv[1])) {
AND r.nzbstatus = 1
AND r.proc_nfo = 0
AND r.nfostatus = 1
AND r.prehashid = 0
AND r.preid = 0
ORDER BY r.postdate DESC
LIMIT %s',
$pdo->likeString($guidChar, false, true),
@@ -71,7 +71,7 @@ if (!isset($argv[1])) {
WHERE r.guid %s
AND nzbstatus = 1 AND r.ishashed = 1
AND r.dehashstatus BETWEEN -6 AND 0
AND r.prehashid = 0
AND r.preid = 0
ORDER BY r.dehashstatus DESC, r.postdate ASC
LIMIT %s',
$pdo->likeString($guidChar, false, true),
@@ -100,7 +100,7 @@ if (!isset($argv[1])) {
WHERE r.guid %s
AND r.nzbstatus = 1
AND r.proc_par2 = 0
AND r.prehashid = 0
AND r.preid = 0
ORDER BY r.postdate ASC
LIMIT %s',
$pdo->likeString($guidChar, false, true),
@@ -137,7 +137,7 @@ if (!isset($argv[1])) {
WHERE r.guid %s
AND r.nzbstatus = 1 AND r.nfostatus = 1
AND r.proc_sorter = 0 AND r.isrenamed = 0
AND r.prehashid = 0
AND r.preid = 0
ORDER BY r.postdate DESC
LIMIT %s',
$pdo->likeString($guidChar, false, true),
@@ -155,8 +155,8 @@ if (!isset($argv[1])) {
case $pieces[0] === 'predbft' && isset($maxperrun) && is_numeric($maxperrun) && isset($thread) && is_numeric($thread):
$pres = $pdo->queryDirect(
sprintf('
SELECT p.id AS prehashid, p.title, p.source, p.searched
FROM prehash p
SELECT p.id AS preid, p.title, p.source, p.searched
FROM predb p
WHERE LENGTH(title) >= 15 AND title NOT REGEXP "[\"\<\> ]"
AND searched = 0
AND DATEDIFF(NOW(), predate) > 1
@@ -182,7 +182,7 @@ if (!isset($argv[1])) {
$searched = $pre['searched'] - 1;
echo ".";
}
$pdo->queryExec(sprintf("UPDATE prehash SET searched = %d WHERE id = %d", $searched, $pre['prehashid']));
$pdo->queryExec(sprintf("UPDATE predb SET searched = %d WHERE id = %d", $searched, $pre['preid']));
$namefixer->checked++;
}
}
@@ -23,7 +23,7 @@ pathname = os.path.abspath(os.path.dirname(sys.argv[0]))
if len(sys.argv) == 1:
print(bcolors.ERROR + "\nAn argument is required\n\n"
+ "python " + sys.argv[0] + " [md5, nfo, filename, par2, miscsorter] ...: To process all previously unprocessed releases, using [md5, nfo, filename, par2, miscsorter].\n"
+ "python " + sys.argv[0] + " [nfo, filename, par2] prehashid ...: To process all releases not matched to prehashid, using [nfo, filename, par2].\n"
+ "python " + sys.argv[0] + " [nfo, filename, par2] preid ...: To process all releases not matched to preid, using [nfo, filename, par2].\n"
+ "python " + sys.argv[0] + " nfo clean ...: To process all releases processed by filename, using nfo.\n"
+ "python " + sys.argv[0] + " par2 clean ...: To process all releases processed by filename and nfo, using par2.\n"
+ "python " + sys.argv[0] + " predbft clean ...: To process all releases using reverse match by PreDB title.\n"
@@ -38,12 +38,12 @@ if len(sys.argv) == 3 and sys.argv[1] == "nfo" and sys.argv[2] == "clean":
clean = " isrenamed = 0 AND proc_files = 1 "
elif len(sys.argv) == 3 and sys.argv[1] == "par2" and sys.argv[2] == "clean":
clean = " isrenamed = 0 AND proc_files = 1 AND proc_nfo = 1 "
elif len(sys.argv) == 3 and sys.argv[1] == "nfo" and sys.argv[2] == "prehashid":
clean = " prehashid = 0 "
elif len(sys.argv) == 3 and sys.argv[1] == "par2" and sys.argv[2] == "prehashid":
clean = " prehashid = 0 "
elif len(sys.argv) == 3 and sys.argv[1] == "filename" and sys.argv[2] == "prehashid":
clean = " prehashid = 0 "
elif len(sys.argv) == 3 and sys.argv[1] == "nfo" and sys.argv[2] == "preid":
clean = " preid = 0 "
elif len(sys.argv) == 3 and sys.argv[1] == "par2" and sys.argv[2] == "preid":
clean = " preid = 0 "
elif len(sys.argv) == 3 and sys.argv[1] == "filename" and sys.argv[2] == "preid":
clean = " preid = 0 "
else:
clean = " isrenamed = 0 "
@@ -69,7 +69,7 @@ elif len(sys.argv) > 1 and (sys.argv[1] == "filename"):
cur[0].execute(run, (int(perrun[0]) * int(run_threads[0])))
datas = cur[0].fetchall()
elif len(sys.argv) > 1 and (sys.argv[1] == "md5"):
run = "SELECT DISTINCT rel.id FROM releases rel LEFT OUTER JOIN release_files rf ON rel.id = rf.releaseid AND rf.ishashed = 1 WHERE nzbstatus = 1 AND rel.dehashstatus BETWEEN -6 AND 0 AND rel.ishashed = 1 AND prehashid = 0 ORDER BY dehashstatus DESC, postdate ASC LIMIT %s"
run = "SELECT DISTINCT rel.id FROM releases rel LEFT OUTER JOIN release_files rf ON rel.id = rf.releaseid AND rf.ishashed = 1 WHERE nzbstatus = 1 AND rel.dehashstatus BETWEEN -6 AND 0 AND rel.ishashed = 1 AND preid = 0 ORDER BY dehashstatus DESC, postdate ASC LIMIT %s"
cur[0].execute(run, (int(perrun[0])*int(run_threads[0])))
datas = cur[0].fetchall()
elif len(sys.argv) > 1 and (sys.argv[1] == "par2"):
@@ -79,7 +79,7 @@ elif len(sys.argv) > 1 and (sys.argv[1] == "par2"):
datas = cur[0].fetchall()
elif len(sys.argv) > 1 and (sys.argv[1] == "predbft"):
#This one does from oldest posts to newest posts since there are many other more efficient PreDB matching schemes
run = "SELECT id AS prehashid FROM prehash WHERE LENGTH(title) >= 15 AND title NOT REGEXP '[\"\<\> ]' AND searched = 0 AND DATEDIFF(NOW(), predate) > 1 ORDER BY predate ASC LIMIT %s"
run = "SELECT id AS preid FROM predb WHERE LENGTH(title) >= 15 AND title NOT REGEXP '[\"\<\> ]' AND searched = 0 AND DATEDIFF(NOW(), predate) > 1 ORDER BY predate ASC LIMIT %s"
cur[0].execute(run, (int(perrun[0]) * int(run_threads[0])))
datas = cur[0].fetchall()
@@ -40,7 +40,7 @@ datelimit = "AND DATEDIFF(NOW(), r.adddate) <= 7"
groupby = "GROUP BY guidchar"
orderby = "ORDER BY guidchar ASC"
rowlimit = "LIMIT 16"
extrawhere = "AND r.prehashid = 0 AND r.nzbstatus = 1"
extrawhere = "AND r.preid = 0 AND r.nzbstatus = 1"
select = "DISTINCT LEFT(r.guid, 1) AS guidchar, COUNT(*) AS count"
cur[0].execute("SELECT value FROM settings WHERE setting = 'fixnamethreads'")
@@ -35,7 +35,7 @@ print(bcolors.HEADER + "\n\nRequestID Threaded Started at {}".format(datetime.da
cur[0].execute("SELECT value FROM settings WHERE setting = 'request_hours'")
dbgrab = cur[0].fetchone()
request_hours = str(dbgrab[0])
cur[0].execute("SELECT DISTINCT(g.id) FROM releases r INNER JOIN groups g ON r.group_id = g.id WHERE r.nzbstatus = 1 AND r.prehashid = 0 AND r.isrequestid = 1 AND r.reqidstatus in (0, -1) OR (r.reqidstatus = -3 AND r.adddate > NOW() - INTERVAL " + request_hours + " HOUR)")
cur[0].execute("SELECT DISTINCT(g.id) FROM releases r INNER JOIN groups g ON r.group_id = g.id WHERE r.nzbstatus = 1 AND r.preid = 0 AND r.isrequestid = 1 AND r.reqidstatus in (0, -1) OR (r.reqidstatus = -3 AND r.adddate > NOW() - INTERVAL " + request_hours + " HOUR)")
datas = cur[0].fetchall()
#close connection to mysql
+4 -4
View File
@@ -257,7 +257,7 @@ class IRCScraper extends IRCClient
*/
protected function _checkForDupe()
{
$this->_oldPre = $this->_pdo->queryOneRow(sprintf('SELECT category, size FROM prehash WHERE title = %s', $this->_pdo->escapeString($this->_curPre['title'])));
$this->_oldPre = $this->_pdo->queryOneRow(sprintf('SELECT category, size FROM predb WHERE title = %s', $this->_pdo->escapeString($this->_curPre['title'])));
if ($this->_oldPre === false) {
$this->_insertNewPre();
} else {
@@ -277,7 +277,7 @@ class IRCScraper extends IRCClient
return;
}
$query = 'INSERT INTO prehash (';
$query = 'INSERT INTO predb (';
$query .= (!empty($this->_curPre['size']) ? 'size, ' : '');
$query .= (!empty($this->_curPre['category']) ? 'category, ' : '');
@@ -327,7 +327,7 @@ class IRCScraper extends IRCClient
return;
}
$query = 'UPDATE prehash SET ';
$query = 'UPDATE predb SET ';
$query .= (!empty($this->_curPre['size']) ? 'size = ' . $this->_pdo->escapeString($this->_curPre['size']) . ', ' : '');
$query .= (!empty($this->_curPre['source']) ? 'source = ' . $this->_pdo->escapeString($this->_curPre['source']) . ', ' : '');
@@ -344,7 +344,7 @@ class IRCScraper extends IRCClient
: ''
);
if ($query === 'UPDATE prehash SET '){
if ($query === 'UPDATE predb SET '){
return;
}
+1 -1
View File
@@ -423,7 +423,7 @@ class NZBImport
'categoryid' => $this->category->determineCategory($nzbDetails['group_id'], $cleanName),
'isrenamed' => $renamed,
'reqidstatus' => 0,
'prehashid' => 0,
'preid' => 0,
'nzbstatus' => NZB::NZB_ADDED
]
);
+21 -21
View File
@@ -186,7 +186,7 @@ class NameFixer
FROM releases rel
INNER JOIN releasenfo nfo ON (nfo.releaseid = rel.id)
WHERE rel.nzbstatus = %d
AND rel.prehashid = 0',
AND rel.preid = 0',
NZB::NZB_ADDED
);
$cats = 2;
@@ -278,7 +278,7 @@ class NameFixer
FROM releases rel
INNER JOIN release_files rf ON (rf.releaseid = rel.id)
WHERE rel.nzbstatus = %d
AND rel.prehashid = 0',
AND rel.preid = 0',
NZB::NZB_ADDED
);
$cats = 2;
@@ -290,7 +290,7 @@ class NameFixer
FROM releases rel
INNER JOIN release_files rf ON (rf.releaseid = rel.id)
WHERE (rel.isrenamed = %d OR rel.categoryid IN (%s))
AND rel.prehashid = 0
AND rel.preid = 0
AND rel.proc_files = %d
%s %s',
self::IS_RENAMED_NONE,
@@ -346,7 +346,7 @@ class NameFixer
SELECT rel.id AS releaseid, rel.guid, rel.groupid
FROM releases rel
WHERE nzbstatus = %d
AND prehashid = 0',
AND preid = 0',
NZB::NZB_ADDED
);
$cats = 2;
@@ -355,7 +355,7 @@ class NameFixer
SELECT rel.id AS releaseid, rel.guid, rel.groupid
FROM releases rel
WHERE (rel.isrenamed = %d OR rel.categoryid IN (%s))
AND prehashid = 0
AND preid = 0
AND proc_srr = %d',
self::IS_RENAMED_NONE,
implode(',', Category::CAT_GROUP_OTHER),
@@ -417,7 +417,7 @@ class NameFixer
SELECT rel.id AS releaseid, rel.guid, rel.groupid
FROM releases rel
WHERE rel.nzbstatus = %d
AND rel.prehashid = 0',
AND rel.preid = 0',
NZB::NZB_ADDED
);
$cats = 2;
@@ -684,7 +684,7 @@ class NameFixer
sprintf('
UPDATE releases
SET videos_id = 0, tv_episodes_id = 0, imdbid = NULL, musicinfoid = NULL,
consoleinfoid = NULL, bookinfoid = NULL, anidbid = NULL, prehashid = %d,
consoleinfoid = NULL, bookinfoid = NULL, anidbid = NULL, preid = %d,
searchname = %s, %s categoryid = %d
WHERE id = %d',
$preId,
@@ -701,7 +701,7 @@ class NameFixer
sprintf('
UPDATE releases
SET videos_id = 0, tv_episodes_id = 0, imdbid = NULL, musicinfoid = NULL,
consoleinfoid = NULL, bookinfoid = NULL, anidbid = NULL, prehashid = %d,
consoleinfoid = NULL, bookinfoid = NULL, anidbid = NULL, preid = %d,
searchname = %s, iscategorized = 1, categoryid = %d
WHERE id = %d',
$preId,
@@ -774,7 +774,7 @@ class NameFixer
FROM releases r
%1\$s
AND (r.name %2\$s OR r.searchname %2\$s)
AND r.prehashid = 0
AND r.preid = 0
LIMIT 21",
$join,
$this->pdo->likeString($pre['title'], true, true)
@@ -789,10 +789,10 @@ class NameFixer
if ($total > 0 && $total <= 15 && $res instanceof \Traversable) {
foreach ($res as $row) {
if ($pre['title'] !== $row['searchname']) {
$this->updateRelease($row, $pre['title'], $method = "Title Match source: " . $pre['source'], $echo, "PreDB FT Exact, ", $namestatus, $show, $pre['prehashid']);
$this->updateRelease($row, $pre['title'], $method = "Title Match source: " . $pre['source'], $echo, "PreDB FT Exact, ", $namestatus, $show, $pre['preid']);
$matching++;
} else {
$this->_updateSingleColumn('prehashid', $pre['prehashid'], $row['releaseid']);
$this->_updateSingleColumn('preid', $pre['preid'], $row['releaseid']);
}
}
} elseif ($total >= 16) {
@@ -854,7 +854,7 @@ class NameFixer
FROM releases r
INNER JOIN release_files rf ON r.id = rf.releaseid
AND rf.name IS NOT NULL
WHERE r.prehashid = 0
WHERE r.preid = 0
%s %s',
$orderby,
$limit
@@ -903,8 +903,8 @@ class NameFixer
if ($this->_fileName !== '') {
$pre = $this->pdo->queryOneRow(
sprintf('
SELECT id AS prehashid, title, source
FROM prehash
SELECT id AS preid, title, source
FROM predb
WHERE filename = %s
OR title = %1$s',
$this->pdo->escapeString($this->_fileName)
@@ -914,9 +914,9 @@ class NameFixer
if (isset($pre) && $pre !== false) {
if ($pre['title'] !== $release['searchname']) {
$this->updateRelease($release, $pre['title'], $method = "file matched source: " . $pre['source'], $echo, "PreDB file match, ", $namestatus, $show, $pre['prehashid']);
$this->updateRelease($release, $pre['title'], $method = "file matched source: " . $pre['source'], $echo, "PreDB file match, ", $namestatus, $show, $pre['preid']);
} else {
$this->_updateSingleColumn('prehashid', $pre['prehashid'], $release['releaseid']);
$this->_updateSingleColumn('preid', $pre['preid'], $release['releaseid']);
}
$matching++;
}
@@ -971,7 +971,7 @@ class NameFixer
}
/**
* Match a Hash from the prehash to a release.
* Match a Hash from the predb to a release.
*
* @param string $hash
* @param $release
@@ -997,8 +997,8 @@ class NameFixer
$row = $pdo->queryOneRow(
sprintf("
SELECT p.id AS prehashid, p.title, p.source
FROM prehash p INNER JOIN predbhash h ON h.pre_id = p.id
SELECT p.id AS preid, p.title, p.source
FROM predb p INNER JOIN predbhash h ON h.pre_id = p.id
WHERE h.hash = UNHEX(%s)
LIMIT 1",
$pdo->escapeString($hash)
@@ -1007,7 +1007,7 @@ class NameFixer
if ($row !== false) {
if ($row["title"] !== $release["searchname"]) {
$this->updateRelease($release, $row["title"], $method = "predb hash release name: " . $row["source"], $echo, $hashtype, $namestatus, $show, $row['prehashid']);
$this->updateRelease($release, $row["title"], $method = "predb hash release name: " . $row["source"], $echo, $hashtype, $namestatus, $show, $row['preid']);
$matching++;
}
} else {
@@ -1035,7 +1035,7 @@ class NameFixer
if (preg_match_all(self::PREDB_REGEX, $release['textstring'], $matches) && !preg_match('/Source\s\:/i', $release['textstring'])) {
foreach ($matches as $match) {
foreach ($match as $val) {
$title = $this->pdo->queryOneRow("SELECT title, id from prehash WHERE title = " . $this->pdo->escapeString(trim($val)));
$title = $this->pdo->queryOneRow("SELECT title, id from predb WHERE title = " . $this->pdo->escapeString(trim($val)));
if ($title !== false) {
$this->updateRelease($release, $title['title'], $method = "preDB: Match", $echo, $type, $namestatus, $show, $title['id']);
$preid = true;
+14 -14
View File
@@ -76,10 +76,10 @@ Class PreHash
$res = $this->pdo->queryDirect(
sprintf('
SELECT p.id AS prehashid, r.id AS releaseid
FROM prehash p
SELECT p.id AS preid, r.id AS releaseid
FROM predb p
INNER JOIN releases r ON p.title = r.searchname
WHERE r.prehashid < 1 %s',
WHERE r.preid < 1 %s',
$datesql
)
);
@@ -91,7 +91,7 @@ Class PreHash
if ($res instanceof Traversable) {
foreach ($res as $row) {
$this->pdo->queryExec(
sprintf('UPDATE releases SET prehashid = %d WHERE id = %d', $row['prehashid'], $row['releaseid'])
sprintf('UPDATE releases SET preid = %d WHERE id = %d', $row['preid'], $row['releaseid'])
);
if ($this->echooutput) {
@@ -127,25 +127,25 @@ Class PreHash
}
$titleCheck = $this->pdo->queryOneRow(
sprintf('SELECT id FROM prehash WHERE title = %s LIMIT 1', $this->pdo->escapeString($cleanerName))
sprintf('SELECT id FROM predb WHERE title = %s LIMIT 1', $this->pdo->escapeString($cleanerName))
);
if ($titleCheck !== false) {
return array(
'title' => $cleanerName,
'prehashid' => $titleCheck['id']
'preid' => $titleCheck['id']
);
}
// Check if clean name matches a PreDB filename.
$fileCheck = $this->pdo->queryOneRow(
sprintf('SELECT id, title FROM prehash WHERE filename = %s LIMIT 1', $this->pdo->escapeString($cleanerName))
sprintf('SELECT id, title FROM predb WHERE filename = %s LIMIT 1', $this->pdo->escapeString($cleanerName))
);
if ($fileCheck !== false) {
return array(
'title' => $fileCheck['title'],
'prehashid' => $fileCheck['id']
'preid' => $fileCheck['id']
);
}
@@ -191,7 +191,7 @@ Class PreHash
$query = sprintf('SELECT r.id AS releaseid, r.name, r.searchname, r.categoryid, r.groupid, '
. 'dehashstatus, rf.name AS filename FROM releases r '
. 'LEFT OUTER JOIN release_files rf ON r.id = rf.releaseid '
. 'WHERE nzbstatus = 1 AND dehashstatus BETWEEN -6 AND 0 AND prehashid = 0 %s', $regex);
. 'WHERE nzbstatus = 1 AND dehashstatus BETWEEN -6 AND 0 AND preid = 0 %s', $regex);
} else {
$query = sprintf('SELECT r.id AS releaseid, r.name, r.searchname, r.categoryid, r.groupid, '
. 'dehashstatus, rf.name AS filename FROM releases r '
@@ -248,8 +248,8 @@ Class PreHash
$sql = sprintf('
SELECT p.*, r.guid
FROM prehash p
LEFT OUTER JOIN releases r ON p.id = r.prehashid %s
FROM predb p
LEFT OUTER JOIN releases r ON p.id = r.preid %s
ORDER BY p.predate DESC
LIMIT %d
OFFSET %d',
@@ -272,7 +272,7 @@ Class PreHash
{
$count = $this->pdo->query("
SELECT COUNT(id) AS cnt
FROM prehash {$search}",
FROM predb {$search}",
true,
NN_CACHE_EXPIRY_MEDIUM
);
@@ -288,7 +288,7 @@ Class PreHash
*/
public function getForRelease($preID)
{
return $this->pdo->query(sprintf('SELECT * FROM prehash WHERE id = %d', $preID));
return $this->pdo->query(sprintf('SELECT * FROM predb WHERE id = %d', $preID));
}
/**
@@ -300,7 +300,7 @@ Class PreHash
*/
public function getOne($preID)
{
return $this->pdo->queryOneRow(sprintf('SELECT * FROM prehash WHERE id = %d', $preID));
return $this->pdo->queryOneRow(sprintf('SELECT * FROM predb WHERE id = %d', $preID));
}
}
+4 -4
View File
@@ -104,7 +104,7 @@ class ReleaseCleaning
$matches)) {
foreach ($matches as $match) {
foreach ($match as $val) {
$title = $this->pdo->queryOneRow("SELECT title, id from prehash WHERE title = " .
$title = $this->pdo->queryOneRow("SELECT title, id from predb WHERE title = " .
$this->pdo->escapeString(trim($val)));
// don't match against ab.teevee if title is for just the season
if ($this->groupName == 'alt.binaries.teevee' && preg_match('/\.S\d\d\./', $title['title'], $match)) {
@@ -130,12 +130,12 @@ class ReleaseCleaning
) {
$title = $this->pdo->queryOneRow(
sprintf(
'SELECT p.title , p.id from prehash p INNER JOIN groups g on g.id = p.groupid WHERE p.requestid = %d and g.name = %s',
'SELECT p.title , p.id from predb p INNER JOIN groups g on g.id = p.groupid WHERE p.requestid = %d and g.name = %s',
$match[1],
$this->pdo->escapeString($this->groupName)
)
);
//check for prehash title matches against other groups where it matches relative size / fromname
//check for predb title matches against other groups where it matches relative size / fromname
//known crossposted requests only atm
$reqGname = '';
switch ($this->groupName) {
@@ -160,7 +160,7 @@ class ReleaseCleaning
if ($title === false && !empty($reqGname)) {
$title = $this->pdo->queryOneRow(
sprintf(
"SELECT p.title as title, p.id as id from prehash p INNER JOIN groups g on g.id = p.groupid
"SELECT p.title as title, p.id as id from predb p INNER JOIN groups g on g.id = p.groupid
WHERE p.requestid = %d and g.name = %s",
$match[1],
$this->pdo->escapeString($reqGname)
+1 -1
View File
@@ -1057,7 +1057,7 @@ class ReleaseRemover
AND nfostatus = 1
AND haspreview = 0
AND jpgstatus = 0
AND prehashid = 0
AND preid = 0
AND videostatus = 0
AND
(
+2 -2
View File
@@ -81,7 +81,7 @@ class Releases
"INSERT INTO releases
(name, searchname, totalpart, groupid, adddate, guid, postdate, fromname,
size, passwordstatus, haspreview, categoryid, nfostatus, nzbstatus,
isrenamed, iscategorized, reqidstatus, prehashid)
isrenamed, iscategorized, reqidstatus, preid)
VALUES (%s, %s, %d, %d, NOW(), %s, %s, %s, %s, %d, -1, %d, -1, %d, %d, 1, %d, %d)",
$parameters['name'],
$parameters['searchname'],
@@ -96,7 +96,7 @@ class Releases
$parameters['nzbstatus'],
$parameters['isrenamed'],
$parameters['reqidstatus'],
$parameters['prehashid']
$parameters['preid']
)
);
$this->sphinxSearch->insertRelease($parameters);
+6 -6
View File
@@ -27,7 +27,7 @@ class RequestIDLocal extends RequestID
FROM releases r
INNER JOIN groups g ON r.groupid = g.id
WHERE r.nzbstatus = 1
AND r.prehashid = 0
AND r.preid = 0
AND r.isrequestID = 1'
);
@@ -108,7 +108,7 @@ class RequestIDLocal extends RequestID
$check = $this->pdo->queryDirect(
sprintf(
'SELECT id, title FROM prehash WHERE requestid = %d AND groupid = %d',
'SELECT id, title FROM predb WHERE requestid = %d AND groupid = %d',
$this->_requestID,
$this->_release['gid']
)
@@ -165,7 +165,7 @@ class RequestIDLocal extends RequestID
case preg_match($regex2, $this->_release['name'], $matches):
$check = $this->pdo->queryOneRow(
sprintf(
"SELECT id, title FROM prehash WHERE title = %s OR filename = %s %s",
"SELECT id, title FROM predb WHERE title = %s OR filename = %s %s",
$this->pdo->escapeString($matches['title']),
$this->pdo->escapeString($matches['title']),
(
@@ -237,7 +237,7 @@ class RequestIDLocal extends RequestID
}
$check = $this->pdo->queryOneRow(
sprintf("
SELECT id, title FROM prehash WHERE requestid = %d AND groupid = %d",
SELECT id, title FROM predb WHERE requestid = %d AND groupid = %d",
$this->_requestID,
($groupID === '' ? 0 : $groupID)
)
@@ -259,7 +259,7 @@ class RequestIDLocal extends RequestID
$this->pdo->queryExec(
sprintf('
UPDATE releases
SET prehashid = %d, reqidstatus = %d, isrenamed = 1, iscategorized = 1, searchname = %s
SET preid = %d, reqidstatus = %d, isrenamed = 1, iscategorized = 1, searchname = %s
WHERE id = %d',
$this->_newTitle['id'],
self::REQID_FOUND,
@@ -274,7 +274,7 @@ class RequestIDLocal extends RequestID
sprintf('
UPDATE releases SET
videos_id = 0, tv_episodes_id = 0, imdbid = NULL, musicinfoid = NULL, consoleinfoid = NULL,
bookinfoid = NULL, anidbid = NULL, prehashid = %d, reqidstatus = %d, isrenamed = 1,
bookinfoid = NULL, anidbid = NULL, preid = %d, reqidstatus = %d, isrenamed = 1,
iscategorized = 1, searchname = %s, categoryid = %d
WHERE id = %d',
$this->_newTitle['id'],
+7 -7
View File
@@ -46,7 +46,7 @@ class RequestIDWeb extends RequestID
FROM releases r
INNER JOIN groups g ON r.groupid = g.id
WHERE r.nzbstatus = 1
AND r.prehashid = 0
AND r.preid = 0
AND r.isrequestid = 1
AND (
r.reqidstatus = %d
@@ -246,8 +246,8 @@ class RequestIDWeb extends RequestID
{
$dupeCheck = $this->pdo->queryOneRow(
sprintf('
SELECT id AS prehashid, requestid, groupid
FROM prehash
SELECT id AS preid, requestid, groupid
FROM predb
WHERE title = %s',
$this->pdo->escapeString($this->_newTitle['title'])
)
@@ -256,7 +256,7 @@ class RequestIDWeb extends RequestID
if ($dupeCheck === false) {
$this->_preDbID = (int)$this->pdo->queryInsert(
sprintf("
INSERT INTO prehash (title, source, requestid, groupid, predate)
INSERT INTO predb (title, source, requestid, groupid, predate)
VALUES (%s, %s, %d, %d, NOW())",
$this->pdo->escapeString($this->_newTitle['title']),
$this->pdo->escapeString('requestWEB'),
@@ -265,10 +265,10 @@ class RequestIDWeb extends RequestID
)
);
} else {
$this->_preDbID = $dupeCheck['prehashid'];
$this->_preDbID = $dupeCheck['preid'];
$this->pdo->queryExec(
sprintf('
UPDATE prehash
UPDATE predb
SET requestid = %d, groupid = %d
WHERE id = %d',
$this->_requestID,
@@ -291,7 +291,7 @@ class RequestIDWeb extends RequestID
UPDATE releases
SET videos_id = 0, tv_episodes_id = 0, imdbid = NULL, musicinfoid = NULL, consoleinfoid = NULL, bookinfoid = NULL, anidbid = NULL,
reqidstatus = %d, isrenamed = 1, proc_files = 1, searchname = %s, categoryid = %d,
prehashid = %d
preid = %d
WHERE id = %d',
self::REQID_FOUND,
$newTitle,
+6 -6
View File
@@ -394,13 +394,13 @@ class Tmux
SUM(IF(nzbstatus = 1 AND categoryid BETWEEN 6000 AND 6040 AND xxxinfo_id = 0,1,0)) AS processxxx,
SUM(IF(1=1 %s,1,0)) AS processnfo,
SUM(IF(nzbstatus = 1 AND nfostatus = 1,1,0)) AS nfo,
SUM(IF(nzbstatus = 1 AND isrequestid = 1 AND prehashid = 0 AND
SUM(IF(nzbstatus = 1 AND isrequestid = 1 AND preid = 0 AND
((reqidstatus = 0) OR (reqidstatus = -1) OR (reqidstatus = -3 AND adddate > NOW() - INTERVAL %s HOUR)),1,0)) AS requestid_inprogress,
SUM(IF(prehashid > 0 AND nzbstatus = 1 AND isrequestid = 1 AND reqidstatus = 1,1,0)) AS requestid_matched,
SUM(IF(prehashid > 0 AND searchname IS NOT NULL,1,0)) AS prehash_matched,
SUM(IF(preid > 0 AND nzbstatus = 1 AND isrequestid = 1 AND reqidstatus = 1,1,0)) AS requestid_matched,
SUM(IF(preid > 0 AND searchname IS NOT NULL,1,0)) AS predb_matched,
SUM(IF(preid > 0 AND searchname IS NOT NULL,1,0)) AS predb_matched,
COUNT(DISTINCT(preid)) AS distinct_predb_matched,
COUNT(DISTINCT(prehashid)) AS distinct_prehash_matched
COUNT(DISTINCT(preid)) AS distinct_predb_matched
FROM releases r", $bookreqids, Nfo::NfoQueryString($this->pdo), $request_hours);
case 2:
return "SELECT
@@ -415,7 +415,7 @@ class Tmux
return sprintf("
SELECT
(SELECT TABLE_ROWS FROM INFORMATION_SCHEMA.TABLES WHERE table_name = 'predb' AND TABLE_SCHEMA = %1\$s) AS predb,
(SELECT TABLE_ROWS FROM INFORMATION_SCHEMA.TABLES WHERE table_name = 'prehash' AND TABLE_SCHEMA = %1\$s) AS prehash,
(SELECT TABLE_ROWS FROM INFORMATION_SCHEMA.TABLES WHERE table_name = 'predb' AND TABLE_SCHEMA = %1\$s) AS predb,
(SELECT TABLE_ROWS FROM INFORMATION_SCHEMA.TABLES WHERE table_name = 'partrepair' AND TABLE_SCHEMA = %1\$s) AS partrepair_table,
(SELECT TABLE_ROWS FROM INFORMATION_SCHEMA.TABLES WHERE table_name = 'parts' AND TABLE_SCHEMA = %1\$s) AS parts_table,
(SELECT TABLE_ROWS FROM INFORMATION_SCHEMA.TABLES WHERE table_name = 'binaries' AND TABLE_SCHEMA = %1\$s) AS binaries_table,
@@ -432,7 +432,7 @@ class Tmux
return "SELECT
(SELECT searchname FROM releases ORDER BY id DESC LIMIT 1) AS newestrelname,
(SELECT UNIX_TIMESTAMP(MIN(dateadded)) FROM collections) AS oldestcollection,
(SELECT UNIX_TIMESTAMP(MAX(predate)) FROM prehash) AS newestprehash,
(SELECT UNIX_TIMESTAMP(MAX(predate)) FROM predb) AS newestpredb,
(SELECT UNIX_TIMESTAMP(MAX(ctime)) FROM predb) AS newestpredb,
(SELECT UNIX_TIMESTAMP(adddate) FROM releases ORDER BY id DESC LIMIT 1) AS newestrelease";
default:
+8 -8
View File
@@ -166,8 +166,8 @@ class TmuxOutput extends Tmux
"Prehash Updated:",
sprintf(
"%s ago",
(isset($this->runVar['timers']['newOld']['newestprehash'])
? $this->relativeTime($this->runVar['timers']['newOld']['newestprehash'])
(isset($this->runVar['timers']['newOld']['newestpredb'])
? $this->relativeTime($this->runVar['timers']['newOld']['newestpredb'])
: 0)
)
);
@@ -235,17 +235,17 @@ class TmuxOutput extends Tmux
)
);
$buffer .= sprintf($this->tmpMasks[4],
"prehash",
"predb",
sprintf(
"%s(%s)",
number_format($this->runVar['counts']['now']['prehash'] -
$this->runVar['counts']['now']['distinct_prehash_matched']),
$this->runVar['counts']['diff']['distinct_prehash_matched']
number_format($this->runVar['counts']['now']['predb'] -
$this->runVar['counts']['now']['distinct_predb_matched']),
$this->runVar['counts']['diff']['distinct_predb_matched']
),
sprintf(
"%s(%d%%)",
number_format($this->runVar['counts']['now']['prehash_matched']),
$this->runVar['counts']['percent']['prehash_matched']
number_format($this->runVar['counts']['now']['predb_matched']),
$this->runVar['counts']['percent']['predb_matched']
)
);
$buffer .= sprintf($this->tmpMasks[4],
+17 -17
View File
@@ -43,8 +43,8 @@ class PreDb extends DB
$options += $defaults;
parent::__construct($options);
$this->tableMain = 'prehash';
$this->tableTemp = 'prehash_imports';
$this->tableMain = 'predb';
$this->tableTemp = 'predb_imports';
}
public function executeAddGroups()
@@ -224,7 +224,7 @@ SQL_EXPORT;
$sql = <<<SQL_ADD_GROUPS
INSERT IGNORE INTO groups (name, description)
SELECT groupname, 'Added by predb import script'
FROM prehash_imports AS pi LEFT JOIN groups AS g ON pi.groupname = g.name
FROM predb_imports AS pi LEFT JOIN groups AS g ON pi.groupname = g.name
WHERE pi.groupname IS NOT NULL AND g.name IS NULL
GROUP BY groupname;
SQL_ADD_GROUPS;
@@ -234,7 +234,7 @@ SQL_ADD_GROUPS;
protected function prepareSQLDeleteShort()
{
$this->prepareSQLStatement('DELETE FROM prehash_imports WHERE LENGTH(title) <= 8', 'DeleteShort');
$this->prepareSQLStatement('DELETE FROM predb_imports WHERE LENGTH(title) <= 8', 'DeleteShort');
}
protected function prepareSQLInsert()
@@ -242,16 +242,16 @@ SQL_ADD_GROUPS;
$sql = <<<SQL_INSERT
INSERT INTO {$this->tableMain} (title, nfo, size, files, filename, nuked, nukereason, category, predate, SOURCE, requestid, groupid)
SELECT pi.title, pi.nfo, pi.size, pi.files, pi.filename, pi.nuked, pi.nukereason, pi.category, pi.predate, pi.source, pi.requestid, groupid
FROM prehash_imports AS pi
ON DUPLICATE KEY UPDATE prehash.nfo = IF(prehash.nfo IS NULL, pi.nfo, prehash.nfo),
prehash.size = IF(prehash.size IS NULL, pi.size, prehash.size),
prehash.files = IF(prehash.files IS NULL, pi.files, prehash.files),
prehash.filename = IF(prehash.filename = '', pi.filename, prehash.filename),
prehash.nuked = IF(pi.nuked > 0, pi.nuked, prehash.nuked),
prehash.nukereason = IF(pi.nuked > 0, pi.nukereason, prehash.nukereason),
prehash.category = IF(prehash.category IS NULL, pi.category, prehash.category),
prehash.requestid = IF(prehash.requestid = 0, pi.requestid, prehash.requestid),
prehash.groupid = IF(prehash.groupid = 0, pi.groupid, prehash.groupid);
FROM predb_imports AS pi
ON DUPLICATE KEY UPDATE predb.nfo = IF(predb.nfo IS NULL, pi.nfo, predb.nfo),
predb.size = IF(predb.size IS NULL, pi.size, predb.size),
predb.files = IF(predb.files IS NULL, pi.files, predb.files),
predb.filename = IF(predb.filename = '', pi.filename, predb.filename),
predb.nuked = IF(pi.nuked > 0, pi.nuked, predb.nuked),
predb.nukereason = IF(pi.nuked > 0, pi.nukereason, predb.nukereason),
predb.category = IF(predb.category IS NULL, pi.category, predb.category),
predb.requestid = IF(predb.requestid = 0, pi.requestid, predb.requestid),
predb.groupid = IF(predb.groupid = 0, pi.groupid, predb.groupid);
SQL_INSERT;
$this->prepareSQLStatement($sql, 'Insert');
@@ -276,7 +276,7 @@ SQL_INSERT;
}
$sql = <<<SQL_LOAD_DATA
LOAD DATA $local INFILE :path
IGNORE INTO TABLE prehash_imports
IGNORE INTO TABLE predb_imports
FIELDS TERMINATED BY '{$options['fields']}' {$enclosedby}
LINES TERMINATED BY '{$options['lines']}'
(title, nfo, size, files, filename, nuked, nukereason, category, predate, source, requestid, groupname);
@@ -290,12 +290,12 @@ SQL_LOAD_DATA;
protected function prepareSQLTruncate()
{
$this->prepareSQLStatement('TRUNCATE TABLE prehash_imports', 'Truncate');
$this->prepareSQLStatement('TRUNCATE TABLE predb_imports', 'Truncate');
}
protected function prepareSQLUpdateGroupIDs()
{
$sql = "UPDATE prehash_imports AS pi SET groupid = (SELECT id FROM groups WHERE name = pi.groupname) WHERE groupname IS NOT NULL";
$sql = "UPDATE predb_imports AS pi SET groupid = (SELECT id FROM groups WHERE name = pi.groupname) WHERE groupname IS NOT NULL";
$this->prepareSQLStatement($sql, 'UpdateGroupID');
}
}
+2 -2
View File
@@ -494,7 +494,7 @@ class Forking extends \fork_daemon
$groupby = "GROUP BY guidchar";
$orderby = "ORDER BY guidchar ASC";
$rowLimit = "LIMIT 16";
$extrawhere = "AND r.prehashid = 0 AND r.nzbstatus = 1";
$extrawhere = "AND r.preid = 0 AND r.nzbstatus = 1";
$select = "DISTINCT LEFT(r.guid, 1) AS guidchar, COUNT(r.id) AS count";
@@ -908,7 +908,7 @@ class Forking extends \fork_daemon
INNER JOIN releases r ON r.groupid = g.id
WHERE g.active = 1
AND r.nzbstatus = %d
AND r.prehashid = 0
AND r.preid = 0
AND r.isrequestid = 1
AND r.reqidstatus = %d',
NZB::NZB_ADDED,
+1 -1
View File
@@ -480,7 +480,7 @@ class PostProcess
FROM releases r
LEFT JOIN groups g ON r.groupid = g.id
WHERE r.isrenamed = 0
AND r.prehashid = 0
AND r.preid = 0
AND r.id = %d',
$relID
)
+2 -2
View File
@@ -603,7 +603,7 @@ class ProcessReleases
$preMatch = $preDB->matchPre($cleanedName);
if ($preMatch !== false) {
$cleanedName = $preMatch['title'];
$preID = $preMatch['prehashid'];
$preID = $preMatch['preid'];
$properName = true;
}
}
@@ -621,7 +621,7 @@ class ProcessReleases
'categoryid' => $categorize->determineCategory($collection['group_id'], $cleanedName),
'isrenamed' => ($properName === true ? 1 : 0),
'reqidstatus' => ($isReqID === true ? 1 : 0),
'prehashid' => ($preID === false ? 0 : $preID),
'preid' => ($preID === false ? 0 : $preID),
'nzbstatus' => NZB::NZB_NONE
]
);
@@ -630,7 +630,7 @@ class ProcessAdditional
$this->_releases = $this->pdo->query(
sprintf(
'
SELECT r.id, r.guid, r.name, c.disablepreview, r.size, r.groupid, r.nfostatus, r.completion, r.categoryid, r.searchname, r.prehashid
SELECT r.id, r.guid, r.name, c.disablepreview, r.size, r.groupid, r.nfostatus, r.completion, r.categoryid, r.searchname, r.preid
FROM releases r
LEFT JOIN category c ON c.id = r.categoryid
WHERE r.nzbstatus = 1
@@ -1809,7 +1809,7 @@ class ProcessAdditional
if (isset($track['Album']) && isset($track['Performer'])) {
if (NN_RENAME_MUSIC_MEDIAINFO && $this->_release['prehashid'] == 0) {
if (NN_RENAME_MUSIC_MEDIAINFO && $this->_release['preid'] == 0) {
// Make the extension upper case.
$ext = strtoupper($fileExtension);
@@ -2351,7 +2351,7 @@ class ProcessAdditional
r.id AS releaseid
FROM releases r
WHERE r.isrenamed = 0
AND r.prehashid = 0
AND r.preid = 0
AND r.id = %d',
$this->_release['id']
)
@@ -2475,7 +2475,7 @@ class ProcessAdditional
'
UPDATE releases
SET videos_id = 0, tv_episodes_id = 0, imdbid = NULL, musicinfoid = NULL,
consoleinfoid = NULL, bookinfoid = NULL, anidbid = NULL, prehashid = 0,
consoleinfoid = NULL, bookinfoid = NULL, anidbid = NULL, preid = 0,
searchname = %s, isrenamed = 1, iscategorized = 1, proc_files = 1, categoryid = %d
WHERE id = %d',
$newTitle,
+20
View File
@@ -0,0 +1,20 @@
#rename the old PreDB table to predb_old
RENAME TABLE predb TO predb_old;
#rename the existing prehash table to predb
RENAME TABLE prehash TO predb;
#Redo the triggers after the table name change
DROP TRIGGER IF EXISTS delete_hashes;
DROP TRIGGER IF EXISTS insert_hashes;
DROP TRIGGER IF EXISTS update_hashes;
DELIMITER $$
CREATE TRIGGER delete_hashes AFTER DELETE ON predb FOR EACH ROW BEGIN DELETE FROM predbhash WHERE hash IN ( UNHEX(md5(OLD.title)), UNHEX(md5(md5(OLD.title))), UNHEX(sha1(OLD.title)) ) AND pre_id = OLD.id; END $$
CREATE TRIGGER insert_hashes AFTER INSERT ON predb FOR EACH ROW BEGIN INSERT INTO predbhash (hash, pre_id) VALUES (UNHEX(MD5(NEW.title)), NEW.id), (UNHEX(MD5(MD5(NEW.title))), NEW.id), ( UNHEX(SHA1(NEW.title)), NEW.id); END $$
CREATE TRIGGER update_hashes AFTER UPDATE ON predb FOR EACH ROW BEGIN IF NEW.title != OLD.title THEN DELETE FROM predbhash WHERE hash IN ( UNHEX(md5(OLD.title)), UNHEX(md5(md5(OLD.title))), UNHEX(sha1(OLD.title)) ) AND pre_id = OLD.id; INSERT INTO predbhash (hash, pre_id) VALUES ( UNHEX(MD5(NEW.title)), NEW.id ), ( UNHEX(MD5(MD5(NEW.title))), NEW.id ), ( UNHEX(SHA1(NEW.title)), NEW.id ); END IF; END $$
DELIMITER ;
@@ -0,0 +1,5 @@
#We are dropping the existing preid column
ALTER TABLE releases DROP preid;
#Now we rename the existing prehashid column to preid
ALTER TABLE releases CHANGE COLUMN prehashid preid INT(10) UNSIGNED NOT NULL DEFAULT '0';
@@ -0,0 +1,2 @@
#rename the existing prehash_imports table to predb_imports
RENAME TABLE prehash_imports TO predb_imports;
+21 -46
View File
@@ -2104,7 +2104,7 @@ INSERT INTO groups (id, name, backfill_target, first_record, first_record_postda
(161, 'alt.binaries.triballs', 0, 0, NULL, 0, NULL, NULL, NULL, NULL, 1, 0, 0, ''),
(162, 'es.binarios.hd', 0, 0, NULL, 0, NULL, NULL, NULL, NULL, 1, 0, 0, ''),
(163, 'alt.binaries.fz', 0, 0, NULL, 0, NULL, NULL, NULL, NULL, 1, 0, 0, ''),
(164, 'alt.binaries.boneless', 0, 0, NULL, 0, NULL, NULL, NULL, NULL, 1, 0, 0, 'Added by predb import script'),
(164, 'alt.binaries.boneless', 0, 0, NULL, 0, NULL, NULL, NULL, NULL, 1, 0, 0, ''),
(165, 'alt.binaries.x.upper-case', 0, 0, NULL, 0, NULL, NULL, NULL, NULL, 1, 0, 0, ''),
(166, 'alt.binaries.town.cine', 0, 0, NULL, 0, NULL, NULL, NULL, NULL, 1, 0, 0, ''),
(167, 'alt.binaries.town.long.ding.dong', 0, 0, NULL, 0, NULL, NULL, NULL, NULL, 1, 0, 0, ''),
@@ -2207,7 +2207,7 @@ INSERT INTO menu (id, href, title, newwindow, tooltip, role, ordinal, menueval)
(21, 'logout', 'Logout', 0, 'Logout', 1, 95, ''),
(22, 'login', 'Login', 0, 'Login', 0, 100, ''),
(23, 'register', 'Register', 0, 'Register', 0, 110, ''),
(24, 'prehash', 'Prehash', 0, 'Prehash', 1, 68, ''),
(24, 'predb', 'Predb', 0, 'Predb', 1, 68, ''),
(25, 'newposterwall', 'New Releases', 0, 'Newest Releases Poster Wall', 1, 11, '');
DROP TABLE IF EXISTS movieinfo;
@@ -2296,30 +2296,6 @@ CREATE TABLE IF NOT EXISTS parts (
DEFAULT CHARSET = utf8
COLLATE = utf8_unicode_ci;
DROP TABLE IF EXISTS predb;
CREATE TABLE IF NOT EXISTS predb (
id INT(12) NOT NULL AUTO_INCREMENT,
ctime INT(12) NOT NULL,
dirname VARCHAR(255) COLLATE utf8_unicode_ci NOT NULL,
category VARCHAR(20) COLLATE utf8_unicode_ci NOT NULL,
nuketype VARCHAR(20) COLLATE utf8_unicode_ci DEFAULT '',
nukereason VARCHAR(255) COLLATE utf8_unicode_ci DEFAULT '',
nuketime INT(12) DEFAULT '0',
filesize FLOAT DEFAULT '0',
filecount INT(6) DEFAULT '0',
filename VARCHAR(255) COLLATE utf8_unicode_ci DEFAULT '',
updatedate TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (id),
UNIQUE KEY dirname (dirname),
KEY ix_predb_ctime (ctime),
KEY ix_predb_updatedate (updatedate),
KEY ix_predb_filename (filename)
)
ENGINE = MyISAM
DEFAULT CHARSET = utf8
COLLATE = utf8_unicode_ci
AUTO_INCREMENT = 1;
DROP TABLE IF EXISTS predbhash;
CREATE TABLE IF NOT EXISTS predbhash (
hash varbinary(20) NOT NULL DEFAULT '',
@@ -2330,8 +2306,8 @@ CREATE TABLE IF NOT EXISTS predbhash (
DEFAULT CHARSET = utf8mb4
COLLATE = utf8mb4_unicode_ci;
DROP TABLE IF EXISTS prehash;
CREATE TABLE IF NOT EXISTS prehash (
DROP TABLE IF EXISTS predb;
CREATE TABLE IF NOT EXISTS predb (
id INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
filename VARCHAR(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
title VARCHAR(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
@@ -2347,15 +2323,15 @@ CREATE TABLE IF NOT EXISTS prehash (
files VARCHAR(50) COLLATE utf8_unicode_ci DEFAULT NULL,
searched TINYINT(1) NOT NULL DEFAULT '0',
PRIMARY KEY (id),
UNIQUE KEY ix_prehash_title (title),
KEY ix_prehash_filename (filename),
KEY ix_prehash_nfo (nfo),
KEY ix_prehash_predate (predate),
KEY ix_prehash_source (source),
KEY ix_prehash_requestid (requestid,groupid),
KEY ix_prehash_size (size),
KEY ix_prehash_category (category),
KEY ix_prehash_searched (searched)
UNIQUE KEY ix_predb_title (title),
KEY ix_predb_filename (filename),
KEY ix_predb_nfo (nfo),
KEY ix_predb_predate (predate),
KEY ix_predb_source (source),
KEY ix_predb_requestid (requestid,groupid),
KEY ix_predb_size (size),
KEY ix_predb_category (category),
KEY ix_predb_searched (searched)
)
ENGINE = MyISAM
DEFAULT CHARSET = utf8
@@ -2368,16 +2344,16 @@ DROP TRIGGER IF EXISTS update_hashes;
DELIMITER $$
CREATE TRIGGER delete_hashes AFTER DELETE ON prehash FOR EACH ROW BEGIN DELETE FROM predbhash WHERE hash IN ( UNHEX(md5(OLD.title)), UNHEX(md5(md5(OLD.title))), UNHEX(sha1(OLD.title)) ) AND pre_id = OLD.id; END $$
CREATE TRIGGER delete_hashes AFTER DELETE ON predb FOR EACH ROW BEGIN DELETE FROM predbhash WHERE hash IN ( UNHEX(md5(OLD.title)), UNHEX(md5(md5(OLD.title))), UNHEX(sha1(OLD.title)) ) AND pre_id = OLD.id; END $$
CREATE TRIGGER insert_hashes AFTER INSERT ON prehash FOR EACH ROW BEGIN INSERT INTO predbhash (hash, pre_id) VALUES (UNHEX(MD5(NEW.title)), NEW.id), (UNHEX(MD5(MD5(NEW.title))), NEW.id), ( UNHEX(SHA1(NEW.title)), NEW.id); END $$
CREATE TRIGGER insert_hashes AFTER INSERT ON predb FOR EACH ROW BEGIN INSERT INTO predbhash (hash, pre_id) VALUES (UNHEX(MD5(NEW.title)), NEW.id), (UNHEX(MD5(MD5(NEW.title))), NEW.id), ( UNHEX(SHA1(NEW.title)), NEW.id); END $$
CREATE TRIGGER update_hashes AFTER UPDATE ON prehash FOR EACH ROW BEGIN IF NEW.title != OLD.title THEN DELETE FROM predbhash WHERE hash IN ( UNHEX(md5(OLD.title)), UNHEX(md5(md5(OLD.title))), UNHEX(sha1(OLD.title)) ) AND pre_id = OLD.id; INSERT INTO predbhash (hash, pre_id) VALUES ( UNHEX(MD5(NEW.title)), NEW.id ), ( UNHEX(MD5(MD5(NEW.title))), NEW.id ), ( UNHEX(SHA1(NEW.title)), NEW.id ); END IF; END $$
CREATE TRIGGER update_hashes AFTER UPDATE ON predb FOR EACH ROW BEGIN IF NEW.title != OLD.title THEN DELETE FROM predbhash WHERE hash IN ( UNHEX(md5(OLD.title)), UNHEX(md5(md5(OLD.title))), UNHEX(sha1(OLD.title)) ) AND pre_id = OLD.id; INSERT INTO predbhash (hash, pre_id) VALUES ( UNHEX(MD5(NEW.title)), NEW.id ), ( UNHEX(MD5(MD5(NEW.title))), NEW.id ), ( UNHEX(SHA1(NEW.title)), NEW.id ); END IF; END $$
DELIMITER ;
DROP TABLE IF EXISTS prehash_imports;
CREATE TABLE IF NOT EXISTS prehash_imports (
DROP TABLE IF EXISTS predb_imports;
CREATE TABLE IF NOT EXISTS predb_imports (
title VARCHAR(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
nfo VARCHAR(255) COLLATE utf8_unicode_ci DEFAULT NULL,
size VARCHAR(50) COLLATE utf8_unicode_ci DEFAULT NULL,
@@ -2507,7 +2483,6 @@ CREATE TABLE IF NOT EXISTS releases (
musicinfoid INT(11) DEFAULT NULL,
consoleinfoid INT(11) DEFAULT NULL,
bookinfoid INT(11) DEFAULT NULL,
preid INT(12) DEFAULT NULL,
anidbid INT(11) DEFAULT NULL,
reqid VARCHAR(255) COLLATE utf8_unicode_ci DEFAULT NULL,
releasenfoid INT(11) DEFAULT NULL,
@@ -2522,7 +2497,7 @@ CREATE TABLE IF NOT EXISTS releases (
audiostatus TINYINT(1) NOT NULL DEFAULT '0',
videostatus TINYINT(1) NOT NULL DEFAULT '0',
reqidstatus TINYINT(1) NOT NULL DEFAULT '0',
prehashid INT(10) UNSIGNED NOT NULL DEFAULT '0',
preid INT(10) UNSIGNED NOT NULL DEFAULT '0',
iscategorized TINYINT(1) NOT NULL DEFAULT '0',
isrenamed TINYINT(1) NOT NULL DEFAULT '0',
ishashed TINYINT(1) NOT NULL DEFAULT '0',
@@ -2550,7 +2525,7 @@ CREATE TABLE IF NOT EXISTS releases (
KEY ix_releases_gamesinfo_id (gamesinfo_id),
KEY ix_releases_bookinfoid (bookinfoid),
KEY ix_releases_anidbid (anidbid),
KEY ix_releases_preid_searchname (prehashid,searchname),
KEY ix_releases_preid_searchname (preid,searchname),
KEY ix_releases_haspreview_passwordstatus (haspreview,passwordstatus),
KEY ix_releases_passwordstatus (passwordstatus),
KEY ix_releases_nfostatus (nfostatus,size),
@@ -4093,7 +4068,7 @@ INSERT INTO settings (setting, value, section, subsection, name, hint) VALUES
('spotnabsiteprvkey', '', '', '', 'spotnabsiteprvkey', ''),
('spotnabsitepubkey', '', '', '', 'spotnabsitepubkey', ''),
('spotnabuser', '', '', '', 'spotnabuser', ''),
('sqlpatch', '232', '', '', 'sqlpatch', ''),
('sqlpatch', '235', '', '', 'sqlpatch', ''),
('storeuserips', '0', '', '', 'storeuserips', ''),
('strapline', 'A great usenet indexer','', '', 'strapline', ''),
('style', 'Omicron', '', '', 'style', ''),
+1 -2
View File
@@ -10,7 +10,6 @@ switch ($page->page) {
case 'ajax_mediainfo':
case 'ajax_mymovies':
case 'ajax_preinfo':
case 'ajax_prehashinfo':
case 'ajax_profile':
case 'ajax_release-admin':
case 'ajax_rarfilelist':
@@ -45,7 +44,7 @@ switch ($page->page) {
case 'newposterwall':
case 'nfo':
case 'nzbgetqueuedata':
case 'prehash':
case 'predb':
case 'profile':
case 'profileedit':
case 'queue':
+2 -2
View File
@@ -129,7 +129,7 @@ if (isset($_GET["id"]))
}
$prehash = new PreHash();
$pre = $prehash->getForRelease($data["prehashid"]);
$pre = $prehash->getForRelease($data["preid"]);
$rf = new ReleaseFiles;
$releasefiles = $rf->get($data["id"]);
@@ -149,7 +149,7 @@ if (isset($_GET["id"]))
$page->smarty->assign('con',$con);
$page->smarty->assign('game', $game);
$page->smarty->assign('book',$book);
$page->smarty->assign('prehash', $pre);
$page->smarty->assign('predb', $pre);
$page->smarty->assign('comments',$comments);
$page->smarty->assign('searchname',$releases->getSimilarName($data['searchname']));
$page->smarty->assign('similars', $similars);
+1 -1
View File
@@ -213,7 +213,7 @@ div.movextra tr.mlextra {display:none;}
div.movcover { width:140px; }
div.movcover img { margin-bottom:5px;}
div.movcover .rndbtn {display:inline-block; margin-top:2px;}
.mediainfo, .seriesinfo, .preinfo, .prehashinfo {cursor:pointer;}
.mediainfo, .seriesinfo, .preinfo {cursor:pointer;}
a.external { background: url('../images/newwindow.png') center right no-repeat !important; padding-right:13px !important;}
+2 -2
View File
@@ -868,7 +868,7 @@ jQuery(function($){
// prehashinfo tooltip
$(".prehashinfo").each(function () {
var prehashid = $(this).attr('title');
var preid = $(this).attr('title');
$(this).qtip({
content: {
title: {
@@ -878,7 +878,7 @@ jQuery(function($){
ajax: {
url: SERVERROOT + 'ajax_prehashinfo', // URL to the local file
type: 'GET', // POST or GET
data: { id: prehashid }, // Data to pass along with your request
data: { id: preid }, // Data to pass along with your request
success: function (data, status) {
this.set('content.text', data);
}
+1 -1
View File
@@ -299,7 +299,7 @@ a.external { background: url('../../images/newwindow.png') center right no-repea
div.movcover { width:140px; }
div.movcover img { margin-bottom:5px;}
div.movcover .rndbtn {display:inline-block; margin-top:2px;}
.mediainfo, .seriesinfo, .preinfo, .prehashinfo {cursor:pointer;}
.mediainfo, .seriesinfo, .preinfo {cursor:pointer;}
/*
+1 -1
View File
@@ -12,4 +12,4 @@ body{
td.less {width:100px;}
.preinfo .prehashinfo {cursor:pointer;}
.preinfo {cursor:pointer;}
+2 -2
View File
@@ -155,8 +155,8 @@
{if $result.reid > 0}
<span class="mediainfo badge badge-inverse halffade" title="{$result.guid}">Media</span>
{/if}
{if $result.prehashid > 0}
<span class="prehashinfo badge badge-inverse halffade" title="{$result.prehashid}">Prehash</span>
{if $result.preid > 0}
<span class="prehashinfo badge badge-inverse halffade" title="{$result.preid}">Prehash</span>
{/if}
{if $result.failed > 0}
<span class="badge badge-inverse"><i class ="fa fa-thumbs-o-up"></i> {$result.grabs} Grab{if $result.grabs != 1}s{/if} / <i class ="fa fa-thumbs-o-down"></i> {$result.failed} Failed Download{if $result.failed != 1}s{/if}</span>
-3
View File
@@ -205,9 +205,6 @@
{if $result.nfoid > 0}
<a href="{$smarty.const.WWW_TOP}/nfo/{$result.guid}" title="View Nfo" class="modal_nfo badge halffade" rel="nfo">Nfo</a>
{/if}
{if $result.preid > 0 && $userdata.canpre == 1}
<span class="preinfo badge halffade" title="{$result.searchname}">Pre'd {if isset($result.ctime)}{$result.ctime|timeago}{else} N/A{/if} </span>
{/if}
{if $result.imdbid > 0}
<a href="{$smarty.const.WWW_TOP}/movies?imdb={$result.imdbid}" title="View movie info" class="badge badge-inverse halffade" rel="movie" >Movie</a>
{/if}
+1 -26
View File
@@ -918,31 +918,6 @@ jQuery(function($){
}
});
});
// preinfo tooltip
$(".preinfo").each(function() {
var searchname = $(this).attr('title');
$(this).qtip({
content: {
title: {
text: 'Pre Info'
},
text: 'loading...',
ajax: {
url: SERVERROOT + 'ajax_preinfo',
type: 'GET',
data: { searchname: searchname },
success: function(data, status) {
this.set('content.text', data);
}
}
},
style: {
classes: 'ui-tooltip-newznab'
}
});
});
});
@@ -1117,4 +1092,4 @@ function getHistory()
},
timeout:5000
});
}
}
+1 -26
View File
@@ -717,31 +717,6 @@ jQuery(function($){
}
});
});
// preinfo tooltip
$(".preinfo").each(function() {
var searchname = $(this).attr('title');
$(this).qtip({
content: {
title: {
text: 'Pre Info'
},
text: 'loading...',
ajax: {
url: SERVERROOT + 'ajax_preinfo',
type: 'GET',
data: { searchname: searchname },
success: function(data, status) {
this.set('content.text', data);
}
}
},
style: {
classes: 'ui-tooltip-newznab'
}
});
});
});
@@ -916,4 +891,4 @@ function getHistory()
},
timeout:5000
});
}
}
+1 -1
View File
@@ -213,7 +213,7 @@ div.movextra tr.mlextra {display:none;}
div.movcover { width:140px; }
div.movcover img { margin-bottom:5px;}
div.movcover .rndbtn {display:inline-block; margin-top:2px;}
.mediainfo, .seriesinfo, .preinfo, .prehashinfo {cursor:pointer;}
.mediainfo, .seriesinfo, .preinfo {cursor:pointer;}
a.external { background: url('../images/newwindow.png') center right no-repeat !important; padding-right:13px !important;}
+3 -27
View File
@@ -538,33 +538,9 @@ jQuery(function ($) {
});
});
// preinfo tooltip
$(".preinfo").each(function() {
var searchname = $(this).attr('title');
$(this).qtip({
content: {
title: {
text: 'Pre Info'
},
text: 'loading...',
ajax: {
url: SERVERROOT + 'ajax_preinfo',
type: 'GET',
data: { searchname: searchname },
success: function(data, status) {
this.set('content.text', data);
}
}
},
style: {
classes: 'ui-tooltip-tmux'
}
});
});
// prehashinfo tooltip
$(".prehashinfo").each(function () {
var prehashid = $(this).attr('title');
var preid = $(this).attr('title');
$(this).qtip({
content: {
title: {
@@ -574,7 +550,7 @@ jQuery(function ($) {
ajax: {
url: SERVERROOT + 'ajax_prehashinfo', // URL to the local file
type: 'GET', // POST or GET
data: { id: prehashid }, // Data to pass along with your request
data: { id: preid }, // Data to pass along with your request
success: function (data, status) {
this.set('content.text', data);
}
@@ -799,4 +775,4 @@ $(document).ready(function () {
// Utilise delegate so we don't have to rebind for every qTip!
$(document).delegate('.qtip.jgrowl', 'mouseover mouseout', timer);
});
});
+1 -1
View File
@@ -213,7 +213,7 @@ div.movextra tr.mlextra {display:none;}
div.movcover { width:140px; }
div.movcover img { margin-bottom:5px;}
div.movcover .rndbtn {display:inline-block; margin-top:2px;}
.mediainfo, .seriesinfo, .preinfo, .prehashinfo {cursor:pointer;}
.mediainfo, .seriesinfo, .preinfo {cursor:pointer;}
a.external { background: url('../images/newwindow.png') center right no-repeat !important; padding-right:13px !important;}