Merge branch 'dev' into dev-steam

This commit is contained in:
DariusIII
2017-02-14 22:32:36 +01:00
8 changed files with 59 additions and 42 deletions
@@ -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'],
];
}
+33 -25
View File
@@ -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)
{
+6 -5
View File
@@ -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();
@@ -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;
+3 -1
View File
@@ -565,7 +565,9 @@
Global Id: {$release.gid}
{/if}
<br>
{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}
<br>
{if !empty($regex->naming_regex_id)} Naming regex ID: {$regex->naming_regex_id}{/if}
</td>
</tr>
{/if}
+3 -1
View File
@@ -387,7 +387,9 @@
Global Id: {$release.gid}
{/if}
<br>
{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}
<br>
{if !empty($regex->naming_regex_id)} Naming regex ID: {$regex->naming_regex_id}{/if}
</dd>
{/if}
</dl>
+3 -1
View File
@@ -571,7 +571,9 @@
Global Id: {$release.gid}
{/if}
<br>
{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}
<br>
{if !empty($regex->naming_regex_id)} Naming regex ID: {$regex->naming_regex_id}{/if}
</td>
</tr>
{/if}
+3 -1
View File
@@ -567,7 +567,9 @@
Global Id: {$release.gid}
{/if}
<br>
{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}
<br>
{if !empty($regex->naming_regex_id)} Naming regex ID: {$regex->naming_regex_id}{/if}
</td>
</tr>
{/if}