diff --git a/Changelog b/Changelog index 02190b50e..0632e56ed 100755 --- a/Changelog +++ b/Changelog @@ -1,4 +1,5 @@ 2016-05-10 DariusIII + * Chg: Rename preid to predb_id in releases table and in classes and scripts. * Chg: Move collection deletion right after NZB is created. 2016-05-09 DariusIII * Fix: Wrong class in Movie.php diff --git a/misc/testing/Releases/fixReleaseNames.php b/misc/testing/Releases/fixReleaseNames.php index 0aebbd5c9..d00d57048 100755 --- a/misc/testing/Releases/fixReleaseNames.php +++ b/misc/testing/Releases/fixReleaseNames.php @@ -24,7 +24,7 @@ if (isset($argv[1]) && isset($argv[2]) && isset($argv[3]) && isset($argv[4])) { $other = 1; if ($argv[3] === 'all') { $other = 2; - } else if ($argv[3] === 'preid') { + } else if ($argv[3] === 'predb_id') { $other = 3; } $setStatus = ($argv[4] == "yes") ? 1 : 2; @@ -81,7 +81,7 @@ if (isset($argv[1]) && isset($argv[2]) && isset($argv[3]) && isset($argv[4])) { } else { exit($pdo->log->error("\nYou must supply 4 arguments.\n" . "The 2nd argument, false, will display the results, but not change the name, type true to have the names changed.\n" - . "The 3rd argument, other, will only do against other categories, to do against all categories use all, or preid to process all not matched to predb.\n" + . "The 3rd argument, other, will only do against other categories, to do against all categories use all, or predb_id to process all not matched to predb.\n" . "The 4th argument, yes, will set the release as checked, so the next time you run it will not be processed, to not set as checked type no.\n" . "The 5th argument (optional), show, will display the release changes or only show a counter.\n\n" . "php $argv[0] 1 false other no ...: Fix release names using the usenet subject in the past 3 hours with predb information.\n" diff --git a/misc/testing/Various/renametopre.php b/misc/testing/Various/renametopre.php index 1283b03f0..5a5484c97 100644 --- a/misc/testing/Various/renametopre.php +++ b/misc/testing/Various/renametopre.php @@ -24,7 +24,7 @@ use newznab\db\Settings; */ $pdo = new Settings(); -if (!(isset($argv[1]) && ($argv[1] == "all" || $argv[1] == "full" || $argv[1] == "preid" || is_numeric($argv[1])))) { +if (!(isset($argv[1]) && ($argv[1] == "all" || $argv[1] == "full" || $argv[1] == "predb_id" || is_numeric($argv[1])))) { exit($pdo->log->error( "\nThis script will attempt to rename releases using regexes first from ReleaseCleaning.php and then from this file.\n" . "An optional last argument, show, will display the release name changes.\n\n" @@ -34,7 +34,7 @@ if (!(isset($argv[1]) && ($argv[1] == "all" || $argv[1] == "full" || $argv[1] == . "php $argv[0] full 155 ...: To process all releases in groupid 155 not previously renamed.\n" . "php $argv[0] all 155 ...: To process all releases in groupid 155.\n" . "php $argv[0] all '(155, 140)' ...: To process all releases in group_ids 155 and 140.\n" - . "php $argv[0] preid ...: To process all releases where not matched to predb.\n" + . "php $argv[0] predb_id ...: To process all releases where not matched to predb.\n" )); } preName($argv, $argc); @@ -59,14 +59,14 @@ function preName($argv, $argc) $full = true; } else if ($argv[1] === 'all') { $all = true; - } else if ($argv[1] === 'preid') { + } else if ($argv[1] === 'predb_id') { $usepre = true; } else if (is_numeric($argv[1])) { $what = ' AND adddate > NOW() - INTERVAL ' . $argv[1] . ' HOUR'; } if ($usepre === true) { $where = ''; - $why = ' WHERE preid = 0 AND nzbstatus = 1'; + $why = ' WHERE predb_id = 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 preid = 0'; + $why = ' WHERE nzbstatus = 1 and predb_id = 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, categories_id = %d, preid = " . $preid . " WHERE id = %d", $pdo->escapeString($cleanName), $determinedcat, $row['id'] + . "iscategorized = 1, isrenamed = 1, searchname = %s, categories_id = %d, predb_id = " . $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, categories_id = %d, preid = " . $preid . " WHERE id = %d", $pdo->escapeString($cleanName), $determinedcat, $row['id'] + . "iscategorized = 1, searchname = %s, categories_id = %d, predb_id = " . $preid . " WHERE id = %d", $pdo->escapeString($cleanName), $determinedcat, $row['id'] ) ); } @@ -235,8 +235,8 @@ function preName($argv, $argc) $relcount = catRelease("searchname", "WHERE categories_id = 0010 OR iscategorized = 0", true); } else if (isset($argv[1]) && $argv[1] == "all") { $relcount = catRelease("searchname", "", true); - } else if (isset($argv[1]) && $argv[1] == "preid") { - $relcount = catRelease("searchname", "WHERE preid = 0 AND nzbstatus = 1", true); + } else if (isset($argv[1]) && $argv[1] == "predb_id") { + $relcount = catRelease("searchname", "WHERE predb_id = 0 AND nzbstatus = 1", true); } else { $relcount = catRelease("searchname", "WHERE (iscategorized = 0 OR categories_id = 0010) 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, " - . "preid = 0, searchname = name, isrenamed = 0, iscategorized = 0 WHERE searchname = ''" + . "predb_id = 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, " - . "preid = 0, searchname = name, isrenamed = 0, iscategorized = 0 WHERE LENGTH(searchname) <= 8 AND LENGTH(name) > 8" + . "predb_id = 0, searchname = name, isrenamed = 0, iscategorized = 0 WHERE LENGTH(searchname) <= 8 AND LENGTH(name) > 8" ); $total = $run->rowCount(); if ($total > 0) { diff --git a/misc/update/decrypt_hashes.php b/misc/update/decrypt_hashes.php index 065d72cd4..73b5bee7f 100755 --- a/misc/update/decrypt_hashes.php +++ b/misc/update/decrypt_hashes.php @@ -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, categories_id, dehashstatus FROM releases WHERE preid = 0 AND ishashed = 1'); + $res = $pdo->queryDirect('SELECT id AS releaseid, name, searchname, groupid, categories_id, dehashstatus FROM releases WHERE predb_id = 0 AND ishashed = 1'); } else if (isset($argv[1]) && $argv[1] === "full") { $res = $pdo->queryDirect('SELECT id AS releaseid, name, searchname, groupid, categories_id, dehashstatus FROM releases WHERE categories_id = 7020 AND ishashed = 1 AND dehashstatus BETWEEN -6 AND 0'); } else if (isset($argv[1]) && is_numeric($argv[1])) { diff --git a/misc/update/nix/tmux/bin/fixreleasenames.php b/misc/update/nix/tmux/bin/fixreleasenames.php index 9289e48df..5815c135d 100644 --- a/misc/update/nix/tmux/bin/fixreleasenames.php +++ b/misc/update/nix/tmux/bin/fixreleasenames.php @@ -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 predb ' + if ($res = $db->queryOneRow(sprintf('SELECT id AS predb_id, 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 predb SET searched = %d WHERE id = %d", $searched, $res['preid'])); + $db->queryExec(sprintf("UPDATE predb SET searched = %d WHERE id = %d", $searched, $res['predb_id'])); $namefixer->checked++; } diff --git a/misc/update/nix/tmux/bin/groupfixrelnames.php b/misc/update/nix/tmux/bin/groupfixrelnames.php index 2bc096ca3..ce03b8076 100644 --- a/misc/update/nix/tmux/bin/groupfixrelnames.php +++ b/misc/update/nix/tmux/bin/groupfixrelnames.php @@ -32,7 +32,7 @@ if (!isset($argv[1])) { AND r.nzbstatus = 1 AND r.proc_nfo = 0 AND r.nfostatus = 1 - AND r.preid = 0 + AND r.predb_id = 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.preid = 0 + AND r.predb_id = 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.preid = 0 + AND r.predb_id = 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.preid = 0 + AND r.predb_id = 0 ORDER BY r.postdate DESC LIMIT %s', $pdo->likeString($guidChar, false, true), @@ -155,7 +155,7 @@ 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 preid, p.title, p.source, p.searched + SELECT p.id AS predb_id, p.title, p.source, p.searched FROM predb p WHERE LENGTH(title) >= 15 AND title NOT REGEXP "[\"\<\> ]" AND searched = 0 @@ -182,7 +182,7 @@ if (!isset($argv[1])) { $searched = $pre['searched'] - 1; echo "."; } - $pdo->queryExec(sprintf("UPDATE predb SET searched = %d WHERE id = %d", $searched, $pre['preid'])); + $pdo->queryExec(sprintf("UPDATE predb SET searched = %d WHERE id = %d", $searched, $pre['predb_id'])); $namefixer->checked++; } } diff --git a/misc/update/python/fixreleasenames_threaded.py b/misc/update/python/fixreleasenames_threaded.py index d4f1fcbd2..8edc6f21a 100644 --- a/misc/update/python/fixreleasenames_threaded.py +++ b/misc/update/python/fixreleasenames_threaded.py @@ -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] preid ...: To process all releases not matched to preid, using [nfo, filename, par2].\n" + + "python " + sys.argv[0] + " [nfo, filename, par2] predb_id ...: To process all releases not matched to predb_id, 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] == "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 " +elif len(sys.argv) == 3 and sys.argv[1] == "nfo" and sys.argv[2] == "predb_id": + clean = " predb_id = 0 " +elif len(sys.argv) == 3 and sys.argv[1] == "par2" and sys.argv[2] == "predb_id": + clean = " predb_id = 0 " +elif len(sys.argv) == 3 and sys.argv[1] == "filename" and sys.argv[2] == "predb_id": + clean = " predb_id = 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 preid = 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 predb_id = 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 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" + run = "SELECT id AS predb_id 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() diff --git a/misc/update/python/groupfixrelnames_threaded.py b/misc/update/python/groupfixrelnames_threaded.py index ab6678a74..79ee1dead 100644 --- a/misc/update/python/groupfixrelnames_threaded.py +++ b/misc/update/python/groupfixrelnames_threaded.py @@ -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.preid = 0 AND r.nzbstatus = 1" +extrawhere = "AND r.predb_id = 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'") diff --git a/misc/update/python/requestid_threaded.py b/misc/update/python/requestid_threaded.py index 89c8cc1bc..5ac0c7a81 100644 --- a/misc/update/python/requestid_threaded.py +++ b/misc/update/python/requestid_threaded.py @@ -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.preid = 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.predb_id = 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 diff --git a/newznab/MiscSorter.php b/newznab/MiscSorter.php index ff21992c6..900f893b6 100644 --- a/newznab/MiscSorter.php +++ b/newznab/MiscSorter.php @@ -74,7 +74,7 @@ class MiscSorter INNER JOIN groups g ON r.groupid = g.id WHERE rn.nfo IS NOT NULL AND r.proc_sorter = %d - AND r.preid = 0 %s", + AND r.predb_id = 0 %s", self::PROC_SORTER_NONE, ($idarr = '' ? $cat : $idarr) ) diff --git a/newznab/NZBImport.php b/newznab/NZBImport.php index dc6920900..d1943bc75 100644 --- a/newznab/NZBImport.php +++ b/newznab/NZBImport.php @@ -423,7 +423,7 @@ class NZBImport 'categories_id' => $this->category->determineCategory($nzbDetails['group_id'], $cleanName), 'isrenamed' => $renamed, 'reqidstatus' => 0, - 'preid' => 0, + 'predb_id' => 0, 'nzbstatus' => NZB::NZB_ADDED ] ); diff --git a/newznab/NameFixer.php b/newznab/NameFixer.php index d2e71a81f..25e6f369f 100755 --- a/newznab/NameFixer.php +++ b/newznab/NameFixer.php @@ -192,7 +192,7 @@ class NameFixer FROM releases rel INNER JOIN release_nfos nfo ON (nfo.releaseid = rel.id) WHERE rel.nzbstatus = %d - AND rel.preid = 0', + AND rel.predb_id = 0', NZB::NZB_ADDED ); $cats = 2; @@ -284,7 +284,7 @@ class NameFixer FROM releases rel INNER JOIN release_files rf ON (rf.releaseid = rel.id) WHERE rel.nzbstatus = %d - AND rel.preid = 0', + AND rel.predb_id = 0', NZB::NZB_ADDED ); $cats = 2; @@ -296,7 +296,7 @@ class NameFixer FROM releases rel INNER JOIN release_files rf ON (rf.releaseid = rel.id) WHERE (rel.isrenamed = %d OR rel.categories_id IN (%s)) - AND rel.preid = 0 + AND rel.predb_id = 0 AND rel.proc_files = %d %s %s', self::IS_RENAMED_NONE, @@ -352,7 +352,7 @@ class NameFixer SELECT rel.id AS releaseid, rel.guid, rel.groupid FROM releases rel WHERE nzbstatus = %d - AND preid = 0', + AND rel.predb_id = 0', NZB::NZB_ADDED ); $cats = 2; @@ -361,8 +361,8 @@ class NameFixer SELECT rel.id AS releaseid, rel.guid, rel.groupid FROM releases rel WHERE (rel.isrenamed = %d OR rel.categories_id IN (%s)) - AND preid = 0 - AND proc_srr = %d', + AND rel.predb_id = 0 + AND rel.proc_srr = %d', self::IS_RENAMED_NONE, implode(',', Category::OTHERS_GROUP), self::PROC_SRR_NONE @@ -423,7 +423,7 @@ class NameFixer SELECT rel.id AS releaseid, rel.guid, rel.groupid FROM releases rel WHERE rel.nzbstatus = %d - AND rel.preid = 0', + AND rel.predb_id = 0', NZB::NZB_ADDED ); $cats = 2; @@ -691,7 +691,7 @@ class NameFixer sprintf(' UPDATE releases SET videos_id = 0, tv_episodes_id = 0, imdbid = NULL, musicinfoid = NULL, - consoleinfoid = NULL, bookinfoid = NULL, anidbid = NULL, preid = %d, + consoleinfoid = NULL, bookinfoid = NULL, anidbid = NULL, predb_id = %d, searchname = %s, %s categories_id = %d WHERE id = %d', $preId, @@ -708,7 +708,7 @@ class NameFixer sprintf(' UPDATE releases SET videos_id = 0, tv_episodes_id = 0, imdbid = NULL, musicinfoid = NULL, - consoleinfoid = NULL, bookinfoid = NULL, anidbid = NULL, preid = %d, + consoleinfoid = NULL, bookinfoid = NULL, anidbid = NULL, predb_id = %d, searchname = %s, iscategorized = 1, categories_id = %d WHERE id = %d', $preId, @@ -781,7 +781,7 @@ class NameFixer FROM releases r %1\$s AND (r.name %2\$s OR r.searchname %2\$s) - AND r.preid = 0 + AND r.predb_id = 0 LIMIT 21", $join, $this->pdo->likeString($pre['title'], true, true) @@ -796,10 +796,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['preid']); + $this->updateRelease($row, $pre['title'], $method = "Title Match source: " . $pre['source'], $echo, "PreDB FT Exact, ", $namestatus, $show, $pre['predb_id']); $matching++; } else { - $this->_updateSingleColumn('preid', $pre['preid'], $row['releaseid']); + $this->_updateSingleColumn('predb_id', $pre['predb_id'], $row['releaseid']); } } } elseif ($total >= 16) { @@ -861,7 +861,7 @@ class NameFixer FROM releases r INNER JOIN release_files rf ON r.id = rf.releaseid AND rf.name IS NOT NULL - WHERE r.preid = 0 + WHERE r.predb_id = 0 %s %s', $orderby, $limit @@ -910,7 +910,7 @@ class NameFixer if ($this->_fileName !== '') { $pre = $this->pdo->queryOneRow( sprintf(' - SELECT id AS preid, title, source + SELECT id AS predb_id, title, source FROM predb WHERE filename = %s OR title = %1$s', @@ -921,9 +921,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['preid']); + $this->updateRelease($release, $pre['title'], $method = "file matched source: " . $pre['source'], $echo, "PreDB file match, ", $namestatus, $show, $pre['predb_id']); } else { - $this->_updateSingleColumn('preid', $pre['preid'], $release['releaseid']); + $this->_updateSingleColumn('predb_id', $pre['predb_id'], $release['releaseid']); } $matching++; } @@ -1004,7 +1004,7 @@ class NameFixer $row = $pdo->queryOneRow( sprintf(" - SELECT p.id AS preid, p.title, p.source + SELECT p.id AS predb_id, p.title, p.source FROM predb p INNER JOIN predb_hashes h ON h.pre_id = p.id WHERE h.hash = UNHEX(%s) LIMIT 1", @@ -1014,7 +1014,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['preid']); + $this->updateRelease($release, $row["title"], $method = "predb hash release name: " . $row["source"], $echo, $hashtype, $namestatus, $show, $row['predb_id']); $matching++; } } else { diff --git a/newznab/PreDb.php b/newznab/PreDb.php index 88910a273..2af5bd90c 100644 --- a/newznab/PreDb.php +++ b/newznab/PreDb.php @@ -74,12 +74,12 @@ Class PreDb $res = $this->pdo->queryDirect( sprintf(' - SELECT p.id AS preid, r.id AS releaseid + SELECT p.id AS predb_id, r.id AS releaseid FROM predb p INNER JOIN releases r FORCE INDEX (ix_releases_preid_searchname) ON p.title = r.searchname - WHERE r.preid < 1 %s', + WHERE r.predb_id < 1 %s', $datesql ) ); @@ -91,7 +91,7 @@ Class PreDb if ($res instanceof \Traversable) { foreach ($res as $row) { $this->pdo->queryExec( - sprintf('UPDATE releases SET preid = %d WHERE id = %d', $row['preid'], $row['releaseid']) + sprintf('UPDATE releases SET predb_id = %d WHERE id = %d', $row['predb_id'], $row['releaseid']) ); if ($this->echooutput) { @@ -133,7 +133,7 @@ Class PreDb if ($titleCheck !== false) { return array( 'title' => $cleanerName, - 'preid' => $titleCheck['id'] + 'predb_id' => $titleCheck['id'] ); } @@ -145,7 +145,7 @@ Class PreDb if ($fileCheck !== false) { return array( 'title' => $fileCheck['title'], - 'preid' => $fileCheck['id'] + 'predb_id' => $fileCheck['id'] ); } @@ -192,7 +192,7 @@ Class PreDb $query = sprintf('SELECT r.id AS releaseid, r.name, r.searchname, r.categories_id, 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 preid = 0 %s', $regex); + . 'WHERE nzbstatus = 1 AND dehashstatus BETWEEN -6 AND 0 AND predb_id = 0 %s', $regex); } else { $query = sprintf('SELECT r.id AS releaseid, r.name, r.searchname, r.categories_id, r.groupid, ' . 'dehashstatus, rf.name AS filename FROM releases r ' @@ -250,7 +250,7 @@ Class PreDb $sql = sprintf(' SELECT p.*, r.guid FROM predb p - LEFT OUTER JOIN releases r ON p.id = r.preid %s + LEFT OUTER JOIN releases r ON p.id = r.predb_id %s ORDER BY p.predate DESC LIMIT %d OFFSET %d', diff --git a/newznab/ReleaseRemover.php b/newznab/ReleaseRemover.php index a9bab31c1..6c3cd7f48 100644 --- a/newznab/ReleaseRemover.php +++ b/newznab/ReleaseRemover.php @@ -1057,11 +1057,11 @@ class ReleaseRemover LEFT JOIN release_files rf ON r.id = rf.releaseid WHERE {$categories} AND (r.imdbid NOT IN ('0000000', 0) OR xxxinfo_id > 0) - AND nfostatus = 1 - AND haspreview = 0 - AND jpgstatus = 0 - AND preid = 0 - AND videostatus = 0 + AND r.nfostatus = 1 + AND r.haspreview = 0 + AND r.jpgstatus = 0 + AND r.predb_id = 0 + AND r.videostatus = 0 AND ( rf.name REGEXP 'XviD-[a-z]{3}\\.(avi|mkv|wmv)$' diff --git a/newznab/Releases.php b/newznab/Releases.php index 7d09c6e3e..cc06616c9 100755 --- a/newznab/Releases.php +++ b/newznab/Releases.php @@ -79,7 +79,7 @@ class Releases "INSERT INTO releases (name, searchname, totalpart, groupid, adddate, guid, postdate, fromname, size, passwordstatus, haspreview, categories_id, nfostatus, nzbstatus, - isrenamed, iscategorized, reqidstatus, preid) + isrenamed, iscategorized, reqidstatus, predb_id) VALUES (%s, %s, %d, %d, NOW(), %s, %s, %s, %s, %d, -1, %d, -1, %d, %d, 1, %d, %d)", $parameters['name'], $parameters['searchname'], @@ -94,7 +94,7 @@ class Releases $parameters['nzbstatus'], $parameters['isrenamed'], $parameters['reqidstatus'], - $parameters['preid'] + $parameters['predb_id'] ) ); $this->sphinxSearch->insertRelease($parameters); diff --git a/newznab/RequestIDLocal.php b/newznab/RequestIDLocal.php index a852d9b72..4c761b26f 100644 --- a/newznab/RequestIDLocal.php +++ b/newznab/RequestIDLocal.php @@ -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.preid = 0 + AND r.predb_id = 0 AND r.isrequestID = 1' ); @@ -259,7 +259,7 @@ class RequestIDLocal extends RequestID $this->pdo->queryExec( sprintf(' UPDATE releases - SET preid = %d, reqidstatus = %d, isrenamed = 1, iscategorized = 1, searchname = %s + SET predb_id = %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, preid = %d, reqidstatus = %d, isrenamed = 1, + bookinfoid = NULL, anidbid = NULL, predb_id = %d, reqidstatus = %d, isrenamed = 1, iscategorized = 1, searchname = %s, categories_id = %d WHERE id = %d', $this->_newTitle['id'], diff --git a/newznab/RequestIDWeb.php b/newznab/RequestIDWeb.php index 11960e4cb..7a59d24f7 100644 --- a/newznab/RequestIDWeb.php +++ b/newznab/RequestIDWeb.php @@ -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.preid = 0 + AND r.predb_id = 0 AND r.isrequestid = 1 AND ( r.reqidstatus = %d @@ -246,7 +246,7 @@ class RequestIDWeb extends RequestID { $dupeCheck = $this->pdo->queryOneRow( sprintf(' - SELECT id AS preid, requestid, groupid + SELECT id AS predb_id, requestid, groupid FROM predb WHERE title = %s', $this->pdo->escapeString($this->_newTitle['title']) @@ -265,7 +265,7 @@ class RequestIDWeb extends RequestID ) ); } else { - $this->_preDbID = $dupeCheck['preid']; + $this->_preDbID = $dupeCheck['predb_id']; $this->pdo->queryExec( sprintf(' UPDATE predb @@ -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, categories_id = %d, - preid = %d + predb_id = %d WHERE id = %d', self::REQID_FOUND, $newTitle, diff --git a/newznab/Tmux.php b/newznab/Tmux.php index efdd1474c..4a9a6456e 100644 --- a/newznab/Tmux.php +++ b/newznab/Tmux.php @@ -397,10 +397,10 @@ class Tmux SUM(IF(nzbstatus = 1 AND categories_id BETWEEN %d AND %d 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 preid = 0 AND ((reqidstatus = 0) OR (reqidstatus = -1) OR (reqidstatus = -3 AND adddate > NOW() - INTERVAL %s HOUR)),1,0)) AS requestid_inprogress, - 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, - COUNT(DISTINCT(preid)) AS distinct_predb_matched + SUM(IF(nzbstatus = 1 AND isrequestid = 1 AND predb_id = 0 AND ((reqidstatus = 0) OR (reqidstatus = -1) OR (reqidstatus = -3 AND adddate > NOW() - INTERVAL %s HOUR)),1,0)) AS requestid_inprogress, + SUM(IF(predb_id > 0 AND nzbstatus = 1 AND isrequestid = 1 AND reqidstatus = 1,1,0)) AS requestid_matched, + SUM(IF(predb_id > 0 AND searchname IS NOT NULL,1,0)) AS predb_matched, + COUNT(DISTINCT(predb_id)) AS distinct_predb_matched FROM releases r", Category::TV_ROOT, Category::TV_OTHER, diff --git a/newznab/libraries/Forking.php b/newznab/libraries/Forking.php index 780c365d0..b8e4013a1 100644 --- a/newznab/libraries/Forking.php +++ b/newznab/libraries/Forking.php @@ -493,7 +493,7 @@ class Forking extends \fork_daemon $groupby = "GROUP BY guidchar"; $orderby = "ORDER BY guidchar ASC"; $rowLimit = "LIMIT 16"; - $extrawhere = "AND r.preid = 0 AND r.nzbstatus = 1"; + $extrawhere = "AND r.predb_id = 0 AND r.nzbstatus = 1"; $select = "DISTINCT LEFT(r.guid, 1) AS guidchar, COUNT(r.id) AS count"; @@ -907,7 +907,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.preid = 0 + AND r.predb_id = 0 AND r.isrequestid = 1 AND r.reqidstatus = %d', NZB::NZB_ADDED, diff --git a/newznab/processing/PostProcess.php b/newznab/processing/PostProcess.php index eb9f8d93e..cda1f9a8a 100755 --- a/newznab/processing/PostProcess.php +++ b/newznab/processing/PostProcess.php @@ -477,7 +477,7 @@ class PostProcess FROM releases r LEFT JOIN groups g ON r.groupid = g.id WHERE r.isrenamed = 0 - AND r.preid = 0 + AND r.predb_id = 0 AND r.id = %d', $relID ) diff --git a/newznab/processing/ProcessReleases.php b/newznab/processing/ProcessReleases.php index ed5749bef..bcf09b31e 100644 --- a/newznab/processing/ProcessReleases.php +++ b/newznab/processing/ProcessReleases.php @@ -599,7 +599,7 @@ class ProcessReleases $preMatch = $preDB->matchPre($cleanedName); if ($preMatch !== false) { $cleanedName = $preMatch['title']; - $preID = $preMatch['preid']; + $preID = $preMatch['predb_id']; $properName = true; } } @@ -617,7 +617,7 @@ class ProcessReleases 'categories_id' => $categorize->determineCategory($collection['group_id'], $cleanedName), 'isrenamed' => ($properName === true ? 1 : 0), 'reqidstatus' => ($isReqID === true ? 1 : 0), - 'preid' => ($preID === false ? 0 : $preID), + 'predb_id' => ($preID === false ? 0 : $preID), 'nzbstatus' => NZB::NZB_NONE ] ); diff --git a/newznab/processing/post/ProcessAdditional.php b/newznab/processing/post/ProcessAdditional.php index a39be9c48..aba0a4f8f 100644 --- a/newznab/processing/post/ProcessAdditional.php +++ b/newznab/processing/post/ProcessAdditional.php @@ -626,7 +626,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.categories_id, r.searchname, r.preid + SELECT r.id, r.guid, r.name, c.disablepreview, r.size, r.groupid, r.nfostatus, r.completion, r.categories_id, r.searchname, r.predb_id FROM releases r LEFT JOIN categories c ON c.id = r.categories_id WHERE r.nzbstatus = 1 @@ -1805,7 +1805,7 @@ class ProcessAdditional if (isset($track['Album']) && isset($track['Performer'])) { - if (NN_RENAME_MUSIC_MEDIAINFO && $this->_release['preid'] == 0) { + if (NN_RENAME_MUSIC_MEDIAINFO && $this->_release['predb_id'] == 0) { // Make the extension upper case. $ext = strtoupper($fileExtension); @@ -2347,7 +2347,7 @@ class ProcessAdditional r.id AS releaseid FROM releases r WHERE r.isrenamed = 0 - AND r.preid = 0 + AND r.predb_id = 0 AND r.id = %d', $this->_release['id'] ) @@ -2471,7 +2471,7 @@ class ProcessAdditional ' UPDATE releases SET videos_id = 0, tv_episodes_id = 0, imdbid = NULL, musicinfoid = NULL, - consoleinfoid = NULL, bookinfoid = NULL, anidbid = NULL, preid = 0, + consoleinfoid = NULL, bookinfoid = NULL, anidbid = NULL, predb_id = 0, searchname = %s, isrenamed = 1, iscategorized = 1, proc_files = 1, categories_id = %d WHERE id = %d', $newTitle, diff --git a/resources/db/patches/mysql/+1~releases.sql b/resources/db/patches/mysql/+1~releases.sql new file mode 100644 index 000000000..e1befada4 --- /dev/null +++ b/resources/db/patches/mysql/+1~releases.sql @@ -0,0 +1,15 @@ +ALTER TABLE releases + CHANGE COLUMN preid predb_id INT(11) UNSIGNED NOT NULL COMMENT 'id, of the predb entry, this hash belongs to', + CHANGE COLUMN musicinfoid musicinfo_id INT(11) UNSIGNED NULL COMMENT 'FK to musicinfo.id', + CHANGE COLUMN consoleinfoid consoleinfo_id INT(11) UNSIGNED NULL COMMENT 'FK to consoleinfo.id', + CHANGE COLUMN bookinfoid bookinfo_id INT(11) UNSIGNED NULL COMMENT 'FK to bookinfo.id' +PARTITION BY RANGE (categories_id) ( +PARTITION misc VALUES LESS THAN (1000), +PARTITION console VALUES LESS THAN (2000), +PARTITION movies VALUES LESS THAN (3000), +PARTITION audio VALUES LESS THAN (4000), +PARTITION pc VALUES LESS THAN (5000), +PARTITION tv VALUES LESS THAN (6000), +PARTITION xxx VALUES LESS THAN (7000), +PARTITION books VALUES LESS THAN (8000) +); diff --git a/resources/db/schema/nntmux_fi_schema.sql b/resources/db/schema/nntmux_fi_schema.sql index 802ebfa80..9059e997c 100644 --- a/resources/db/schema/nntmux_fi_schema.sql +++ b/resources/db/schema/nntmux_fi_schema.sql @@ -2459,7 +2459,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', - preid INT(10) UNSIGNED NOT NULL DEFAULT '0', + predb_id 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', @@ -2487,7 +2487,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 (preid,searchname), + KEY ix_releases_preid_searchname (predb_id,searchname), KEY ix_releases_haspreview_passwordstatus (haspreview,passwordstatus), KEY ix_releases_passwordstatus (passwordstatus), KEY ix_releases_nfostatus (nfostatus,size), diff --git a/www/pages/details.php b/www/pages/details.php index 886e0253e..47d43724d 100644 --- a/www/pages/details.php +++ b/www/pages/details.php @@ -129,7 +129,7 @@ if (isset($_GET["id"])) } $prehash = new PreDb(); - $pre = $prehash->getForRelease($data["preid"]); + $pre = $prehash->getForRelease($data["predb_id"]); $rf = new ReleaseFiles; $releasefiles = $rf->get($data["id"]); diff --git a/www/themes/Gamma/templates/browse.tpl b/www/themes/Gamma/templates/browse.tpl index d3c8e0147..b571e3781 100755 --- a/www/themes/Gamma/templates/browse.tpl +++ b/www/themes/Gamma/templates/browse.tpl @@ -154,8 +154,8 @@ {if $result.reid > 0} Media {/if} - {if $result.preid > 0} - PreDb + {if $result.predb_id > 0} + PreDb {/if} {if !empty($result.failed)} {$result.grabs} Grab{if $result.grabs != 1}s{/if} / {$result.failed} Failed Download{if $result.failed != 1}s{/if}