diff --git a/app/models/ReleasesRegexes.php b/app/models/ReleaseRegexes.php similarity index 88% rename from app/models/ReleasesRegexes.php rename to app/models/ReleaseRegexes.php index 4bef0b442..988004fc2 100644 --- a/app/models/ReleasesRegexes.php +++ b/app/models/ReleaseRegexes.php @@ -19,12 +19,12 @@ namespace app\models; -class ReleasesRegexes extends \lithium\data\Model +class ReleaseRegexes extends \lithium\data\Model { public $belongsTo = ['Releases']; public $hasMany = ['Collection_regexes']; protected $_meta = [ - 'key' => ['releases_id', 'regex_id'], + 'key' => ['releases_id', 'collection_regex_id', 'naming_regex_id'], ]; } diff --git a/nntmux/ReleaseCleaning.php b/nntmux/ReleaseCleaning.php index 94cc1077c..345ef0841 100755 --- a/nntmux/ReleaseCleaning.php +++ b/nntmux/ReleaseCleaning.php @@ -112,11 +112,11 @@ class ReleaseCleaning } if ($title !== false) { return array( - "cleansubject" => $title['title'], - "properlynamed" => true, - "increment" => false, - "predb" => $title['id'], - "requestid" => false + 'cleansubject' => $title['title'], + 'properlynamed' => true, + 'increment' => false, + 'predb' => $title['id'], + 'requestid' => false ); } } @@ -160,8 +160,8 @@ class ReleaseCleaning if ($title === false && !empty($reqGname)) { $title = $this->pdo->queryOneRow( sprintf( - "SELECT p.title as title, p.id as id from predb p INNER JOIN groups g on g.id = p.groups_id - WHERE p.requestid = %d and g.name = %s", + 'SELECT p.title as title, p.id as id from predb p INNER JOIN groups g on g.id = p.groups_id + WHERE p.requestid = %d and g.name = %s', $match[1], $this->pdo->escapeString($reqGname) ) @@ -173,11 +173,11 @@ class ReleaseCleaning } if ($title !== false) { return array( - "cleansubject" => $title['title'], - "properlynamed" => true, - "increment" => false, - "predb" => $title['id'], - "requestid" => true + 'cleansubject' => $title['title'], + 'properlynamed' => true, + 'increment' => false, + 'predb' => $title['id'], + 'requestid' => true ); } } @@ -188,7 +188,10 @@ class ReleaseCleaning // Try DB regex. $potentialName = $this->_regexes->tryRegex($subject, $groupName); if ($potentialName) { - return $potentialName; + return [ + 'id' => $this->_regexes->matchedRegex, + 'name' => $potentialName + ]; } //if www.town.ag releases check against generic_town regexes @@ -206,13 +209,16 @@ class ReleaseCleaning { //[140022]-[04] - [01/40] - "140022-04.nfo" yEnc if (preg_match('/\[\d+\]-\[.+\] - \[\d+\/\d+\] - "\d+-.+" yEnc/', $this->subject)) { - return array( - "cleansubject" => $this->subject, "properlynamed" => false, "ignore" => true - ); + return [ + 'cleansubject' => $this->subject, + 'properlynamed' => false, + 'ignore' => true + ]; } - return array( - "cleansubject" => $this->releaseCleanerHelper($this->subject), "properlynamed" => false - ); + return [ + 'cleansubject' => $this->releaseCleanerHelper($this->subject), + 'properlynamed' => false + ]; } public function generic_town() { @@ -348,9 +354,10 @@ class ReleaseCleaning ) { return $match[1]; } - return array( - "cleansubject" => $this->releaseCleanerHelper($this->subject), "properlynamed" => false - ); + return [ + 'cleansubject' => $this->releaseCleanerHelper($this->subject), + 'properlynamed' => false + ]; } // Run at the end because this can be dangerous. In the future it's better to make these per group. There should not be numbers after yEnc because we remove them as well before inserting (even when importing). public function generic() @@ -362,9 +369,10 @@ class ReleaseCleaning ) { return $match['title']; } - return array( - "cleansubject" => $this->releaseCleanerHelper($this->subject), "properlynamed" => false - ); + return [ + 'cleansubject' => $this->releaseCleanerHelper($this->subject), + 'properlynamed' => false + ]; } public function releaseCleanerHelper($subject) { diff --git a/nntmux/processing/ProcessReleases.php b/nntmux/processing/ProcessReleases.php index cbd3db459..a54b85afc 100755 --- a/nntmux/processing/ProcessReleases.php +++ b/nntmux/processing/ProcessReleases.php @@ -3,7 +3,7 @@ namespace nntmux\processing; use app\models\MultigroupPosters; use app\models\ReleasesGroups; -use app\models\ReleasesRegexes; +use app\models\ReleaseRegexes; use app\models\Settings; use nntmux\Categorize; use nntmux\Category; @@ -687,11 +687,12 @@ class ProcessReleases ) ); - // Add the id of regex that matched the collection to releases_regexes table - $releasesRegexes = ReleasesRegexes::create( + // Add the id of regex that matched the collection and release name to releases_regexes table + $releasesRegexes = ReleaseRegexes::create( [ - 'releases_id' => $releaseID, - 'regex_id' => $collection['collection_regexes_id'], + 'releases_id' => $releaseID, + 'collection_regex_id' => $collection['collection_regexes_id'], + 'naming_regex_id' => $cleanedName['id'], ] ); $releasesRegexes->save(); diff --git a/resources/db/patches/mysql/0295~releases_regexes.sql b/resources/db/patches/mysql/0295~releases_regexes.sql index f72bf6fbf..458567b0f 100644 --- a/resources/db/patches/mysql/0295~releases_regexes.sql +++ b/resources/db/patches/mysql/0295~releases_regexes.sql @@ -1,12 +1,12 @@ # Create the new releases_regexes table -DROP TABLE IF EXISTS releases_regexes; +DROP TABLE IF EXISTS release_regexes; CREATE TABLE releases_regexes ( - releases_id INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, - regex_id INT(11) UNSIGNED NOT NULL DEFAULT '0', - PRIMARY KEY (releases_id, regex_id) + releases_id INT(11) UNSIGNED NOT NULL DEFAULT '0', + collection_regex_id INT(11) UNSIGNED NOT NULL DEFAULT '0', + naming_regex_id INT(11) UNSIGNED NOT NULL DEFAULT '0' + PRIMARY KEY (releases_id, collection_regex_id, naming_regex_id) ) ENGINE = MYISAM DEFAULT CHARSET = utf8 - COLLATE = utf8_unicode_ci - AUTO_INCREMENT = 1; + COLLATE = utf8_unicode_ci; diff --git a/www/themes/Charisma/templates/viewnzb.tpl b/www/themes/Charisma/templates/viewnzb.tpl index f59dfea0d..29dce4286 100755 --- a/www/themes/Charisma/templates/viewnzb.tpl +++ b/www/themes/Charisma/templates/viewnzb.tpl @@ -565,7 +565,9 @@ Global Id: {$release.gid} {/if}
- {if !empty($regex->regex_id)} Collection regex ID: {$regex->regex_id}{/if} + {if !empty($regex->collection_regex_id)} Collection regex ID: {$regex->collection_regex_id}{/if} +
+ {if !empty($regex->naming_regex_id)} Naming regex ID: {$regex->naming_regex_id}{/if} {/if} diff --git a/www/themes/Gamma/templates/viewnzb.tpl b/www/themes/Gamma/templates/viewnzb.tpl index 0e75791ec..4e80a9b98 100755 --- a/www/themes/Gamma/templates/viewnzb.tpl +++ b/www/themes/Gamma/templates/viewnzb.tpl @@ -387,7 +387,9 @@ Global Id: {$release.gid} {/if}
- {if !empty($regex->regex_id)} Collection regex ID: {$regex->regex_id}{/if} + {if !empty($regex->collection_regex_id)} Collection regex ID: {$regex->collection_regex_id}{/if} +
+ {if !empty($regex->naming_regex_id)} Naming regex ID: {$regex->naming_regex_id}{/if} {/if} diff --git a/www/themes/Gentele/templates/viewnzb.tpl b/www/themes/Gentele/templates/viewnzb.tpl index 6443791d4..453f08d21 100755 --- a/www/themes/Gentele/templates/viewnzb.tpl +++ b/www/themes/Gentele/templates/viewnzb.tpl @@ -571,7 +571,9 @@ Global Id: {$release.gid} {/if}
- {if !empty($regex->regex_id)} Collection regex ID: {$regex->regex_id}{/if} + {if !empty($regex->collection_regex_id)} Collection regex ID: {$regex->collection_regex_id}{/if} +
+ {if !empty($regex->naming_regex_id)} Naming regex ID: {$regex->naming_regex_id}{/if} {/if} diff --git a/www/themes/Omicron/templates/viewnzb.tpl b/www/themes/Omicron/templates/viewnzb.tpl index daa86d8ba..8be3b9bc9 100755 --- a/www/themes/Omicron/templates/viewnzb.tpl +++ b/www/themes/Omicron/templates/viewnzb.tpl @@ -567,7 +567,9 @@ Global Id: {$release.gid} {/if}
- {if !empty($regex->regex_id)} Collection regex ID: {$regex->regex_id}{/if} + {if !empty($regex->collection_regex_id)} Collection regex ID: {$regex->collection_regex_id}{/if} +
+ {if !empty($regex->naming_regex_id)} Naming regex ID: {$regex->naming_regex_id}{/if} {/if}