From 47fdefd523dc4152d0cb1bdd3d0a981fde814bd7 Mon Sep 17 00:00:00 2001 From: DariusIII Date: Sun, 9 Feb 2025 22:47:54 +0100 Subject: [PATCH] Remove predb_hash related stuff --- Blacklight/NameFixer.php | 105 ---------------------- database/schema/mariadb-schema.sql | 9 -- misc/testing/Releases/fixReleaseNames.php | 8 -- misc/update/tmux/bin/groupfixrelnames.php | 16 ---- 4 files changed, 138 deletions(-) diff --git a/Blacklight/NameFixer.php b/Blacklight/NameFixer.php index faeb2f997..d49ca7ef6 100755 --- a/Blacklight/NameFixer.php +++ b/Blacklight/NameFixer.php @@ -1201,111 +1201,6 @@ class NameFixer return false; } - /** - * Match a Hash from the predb to a release. - * - * - * @throws \Exception - */ - public function matchPredbHash(string $hash, $release, $echo, $nameStatus, $show): int - { - $matching = 0; - $this->matched = false; - - // Determine MD5 or SHA1 - if (\strlen($hash) === 40) { - $hashtype = 'SHA1, '; - } else { - $hashtype = 'MD5, '; - } - - $row = Predb::fromQuery( - sprintf( - ' - SELECT p.id AS predb_id, p.title, p.source - FROM predb p INNER JOIN predb_hashes h ON h.predb_id = p.id - WHERE h.hash = UNHEX(%s) - LIMIT 1', - escapeString($hash) - ) - ); - - foreach ($row as $item) { - if (! empty($item)) { - if ($item->title !== $release->searchname) { - $this->updateRelease($release, $item->title, 'predb hash release name: '.$item->source, $echo, $hashtype, $nameStatus, $show, $item->predb_id); - $matching++; - } - } else { - $this->_updateSingleColumn('dehashstatus', $release->dehashstatus - 1, $release->releases_id); - } - } - - return $matching; - } - - /** - * Matches the hashes within the predb table to release files and subjects (names) which are hashed. - * - * - * @throws \Exception - */ - public function parseTitles($time, $echo, $cats, $nameStatus, $show): int - { - $updated = $checked = 0; - - $tq = ''; - if ($time === 1) { - $tq = 'AND r.adddate > (NOW() - INTERVAL 3 HOUR) ORDER BY rf.releases_id, rf.size DESC'; - } - $ct = ''; - if ($cats === 1) { - $ct = sprintf('AND r.categories_id IN (%s)', $this->othercats); - } - - if ($this->echoOutput) { - $te = ''; - if ($time === 1) { - $te = ' in the past 3 hours'; - } - $this->colorCLI->climate()->info('Fixing search names'.$te.' using the predb hash.'); - } - $regex = 'AND (r.ishashed = 1 OR rf.ishashed = 1)'; - - if ($cats === 3) { - $query = sprintf('SELECT r.id AS releases_id, r.name, r.searchname, r.categories_id, r.groups_id, ' - .'dehashstatus, rf.name AS filename FROM releases r ' - .'LEFT OUTER JOIN release_files rf ON r.id = rf.releases_id ' - .'WHERE nzbstatus = 1 AND dehashstatus BETWEEN -6 AND 0 AND predb_id = 0 %s', $regex); - } else { - $query = sprintf('SELECT r.id AS releases_id, r.name, r.searchname, r.categories_id, r.groups_id, ' - .'dehashstatus, rf.name AS filename FROM releases r ' - .'LEFT OUTER JOIN release_files rf ON r.id = rf.releases_id ' - .'WHERE nzbstatus = 1 AND isrenamed = 0 AND dehashstatus BETWEEN -6 AND 0 %s %s %s', $regex, $ct, $tq); - } - - $res = Release::fromQuery($query); - $total = $res->count(); - $this->colorCLI->climate()->info(number_format($total).' releases to process.'); - foreach ($res as $row) { - if (preg_match('/[a-fA-F0-9]{32,40}/i', $row->name, $hits)) { - $updated += $this->matchPredbHash($hits[0], $row, $echo, $nameStatus, $show); - } elseif (preg_match('/[a-fA-F0-9]{32,40}/i', $row->filename, $hits)) { - $updated += $this->matchPredbHash($hits[0], $row, $echo, $nameStatus, $show); - } - if ($show === 2) { - $this->colorCLI->climate()->info('Renamed Releases: ['.number_format($updated).'] '.(new ConsoleTools)->percentString($checked++, $total)); - } - } - if ($echo === 1) { - $this->colorCLI->climate()->info(PHP_EOL.$updated.' releases have had their names changed out of: '.number_format($checked).' files.'); - } else { - $this->colorCLI->climate()->info(PHP_EOL.$updated.' releases could have their names changed. '.number_format($checked).' files were checked.'); - } - - return $updated; - } - /** * Check the array using regex for a clean name. * diff --git a/database/schema/mariadb-schema.sql b/database/schema/mariadb-schema.sql index 3827449f9..282657164 100644 --- a/database/schema/mariadb-schema.sql +++ b/database/schema/mariadb-schema.sql @@ -709,14 +709,6 @@ CREATE TABLE `predb_crcs` ( KEY `predb_crcs_osohash_index` (`osohash`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci ROW_FORMAT=DYNAMIC; -DROP TABLE IF EXISTS `predb_hashes`; - -CREATE TABLE `predb_hashes` ( - `predb_id` int(10) unsigned NOT NULL DEFAULT 0 COMMENT 'id, of the predb entry, this hash belongs to', - `hash` varbinary(40) NOT NULL DEFAULT '', - PRIMARY KEY (`hash`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; - DROP TABLE IF EXISTS `predb_imports`; CREATE TABLE `predb_imports` ( @@ -1359,7 +1351,6 @@ INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (30,'2018_01_20_195 INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (31,'2018_01_20_195915_create_par_hashes_table',1); INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (32,'2018_01_20_195925_create_parts_table',1); INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (33,'2018_01_20_195934_create_predb_table',1); -INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (34,'2018_01_20_195946_create_predb_hashes_table',1); INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (35,'2018_01_20_195954_create_predb_imports_table',1); INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (36,'2018_01_20_200005_create_release_comments_table',1); INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (37,'2018_01_20_200018_create_releases_groups_table',1); diff --git a/misc/testing/Releases/fixReleaseNames.php b/misc/testing/Releases/fixReleaseNames.php index d0b6ba1ea..58dfa6cee 100755 --- a/misc/testing/Releases/fixReleaseNames.php +++ b/misc/testing/Releases/fixReleaseNames.php @@ -39,12 +39,6 @@ if (isset($argv[1], $argv[2], $argv[3], $argv[4])) { } switch ($argv[1]) { - case 1: - $nameFixer->parseTitles(1, $update, $other, $setStatus, $show); - break; - case 2: - $nameFixer->parseTitles(2, $update, $other, $setStatus, $show); - break; case 3: $nameFixer->fixNamesWithNfo(1, $update, $other, $setStatus, $show); break; @@ -110,8 +104,6 @@ if (isset($argv[1], $argv[2], $argv[3], $argv[4])) { .'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.'.PHP_EOL .'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.'.PHP_EOL .'The 5th argument (optional), show, will display the release changes or only show a counter.'.PHP_EOL - .'php '.$argv[0].' 1 false other no ...: Fix release names using the usenet subject in the past 3 hours with predb information.'.PHP_EOL - .'php '.$argv[0].' 2 false other no ...: Fix release names using the usenet subject with predb information.'.PHP_EOL .'php '.$argv[0].' 3 false other no ...: Fix release names using NFO in the past 6 hours.'.PHP_EOL .'php '.$argv[0].' 4 false other no ...: Fix release names using NFO.'.PHP_EOL .'php '.$argv[0].' 5 false other no ...: Fix release names in misc categories using File Name in the past 6 hours.'.PHP_EOL diff --git a/misc/update/tmux/bin/groupfixrelnames.php b/misc/update/tmux/bin/groupfixrelnames.php index 14c448deb..7c42861e7 100644 --- a/misc/update/tmux/bin/groupfixrelnames.php +++ b/misc/update/tmux/bin/groupfixrelnames.php @@ -82,22 +82,6 @@ switch (true) { $colorCli->primary("[{$release->releases_id}]", true); - if ((int) $release->ishashed === 1 && (int) $release->dehashstatus >= -6 && (int) $release->dehashstatus <= 0) { - $colorCli->primaryOver('d'); - if (preg_match('/[a-fA-F0-9]{32,40}/i', $release->name, $hits)) { - $nameFixer->matchPredbHash($hits[0], $release, true, 1, true); - } - if ($nameFixer->matched === false && ! empty($release->filehash) && preg_match('/[a-fA-F0-9]{32,40}/i', $release->filehash, $hits)) { - $colorCli->primaryOver('h'); - $nameFixer->matchPredbHash($hits[0], $release, true, 1, true); - } - } - - if ($nameFixer->matched) { - continue; - } - $nameFixer->reset(); - if ((int) $release->proc_uid === NameFixer::PROC_UID_NONE && (! empty($release->uid) || ! empty($release->mediainfo))) { $colorCli->primaryOver('U'); if (! empty($release->uid)) {