diff --git a/Blacklight/Categorize.php b/Blacklight/Categorize.php index 7072ca713..ebabf0217 100755 --- a/Blacklight/Categorize.php +++ b/Blacklight/Categorize.php @@ -11,8 +11,19 @@ use App\Models\Settings; * * Class Categorize */ -class Categorize extends Category +class Categorize { + /** + * Temporary category while we sort through the name. + * @var int + */ + protected $tmpCat = Category::OTHER_MISC; + + /** + * Temporary tag while we sort through the name. + * @var int + */ + protected $tmpTag = [Category::OTHER_MISC]; /** * @var bool */ @@ -47,15 +58,12 @@ class Categorize extends Category public $regexes; /** - * Construct. - * - * @param array $options Class instances. + * Categorize constructor. * * @throws \Exception */ - public function __construct(array $options = []) + public function __construct() { - parent::__construct($options); $this->categorizeForeign = (bool) Settings::settingValue('indexer.categorise.categorizeforeign'); $this->catWebDL = (bool) Settings::settingValue('indexer.categorise.catwebdl'); $this->regexes = new Regexes(['Table_Name' => 'category_regexes']); @@ -64,16 +72,16 @@ class Categorize extends Category /** * Look up the site to see which language of categorizing to use. * Then work out which category is applicable for either a group or a binary. - * Returns self::OTHER_MISC if no category is appropriate. + * Returns Category::OTHER_MISC if no category is appropriate. * - * @param string $releaseName The name to parse. - * @param string $poster Name of the release poster to parse - * @param int|string $groupID The groups_id. + * @param $groupID + * @param string $releaseName + * @param string $poster * - * @return int The categories_id. + * @return array * @throws \Exception */ - public function determineCategory($groupID, $releaseName = '', $poster = ''): int + public function determineCategory($groupID, $releaseName = '', $poster = ''): array { $this->releaseName = $releaseName; $this->groupid = $groupID; @@ -92,10 +100,10 @@ class Categorize extends Category case $this->isConsole(): case $this->isBook(): case $this->isMusic(): - return $this->tmpCat; + return ['categories_id' => $this->tmpCat, 'tags' => $this->tmpTag]; } - return $this->tmpCat; + return ['categories_id' => $this->tmpCat, 'tags' => $this->tmpTag]; } /** @@ -136,15 +144,18 @@ class Categorize extends Category case $this->isPC(): break; default: - $this->tmpCat = self::PC_0DAY; + $this->tmpCat = Category::PC_0DAY; + $this->tmpTag[] = Category::PC_0DAY; break; } break; case $group === 'alt.binaries.audio.warez': - $this->tmpCat = self::PC_0DAY; + $this->tmpCat = Category::PC_0DAY; + $this->tmpTag[] = Category::PC_0DAY; break; case preg_match('/alt\.binaries\.(multimedia\.erotica\.|cartoons\.french\.|dvd\.|multimedia\.)?anime(\.highspeed|\.repost|s-fansub|\.german)?$/', $group): - $this->tmpCat = self::TV_ANIME; + $this->tmpCat = Category::TV_ANIME; + $this->tmpTag[] = Category::TV_ANIME; break; case $group === 'alt.binaries.b4e.erotica': switch (true) { @@ -153,7 +164,8 @@ class Categorize extends Category case $this->isXxx(): break; default: - $this->tmpCat = self::XXX_OTHER; + $this->tmpCat = Category::XXX_OTHER; + $this->tmpTag[] = Category::XXX_OTHER; break; } break; @@ -177,7 +189,8 @@ class Categorize extends Category case $this->isConsole(): break; default: - $this->tmpCat = self::PC_ISO; + $this->tmpCat = Category::PC_ISO; + $this->tmpTag[] = Category::PC_ISO; break; } break; @@ -195,31 +208,37 @@ class Categorize extends Category } break; case $this->categorizeForeign && $group === 'alt.binaries.cartoons.french': - $this->tmpCat = self::TV_FOREIGN; + $this->tmpCat = Category::TV_FOREIGN; + $this->tmpTag[] = Category::TV_FOREIGN; break; case $group === 'alt.binaries.cd.image.linux': - $this->tmpCat = self::PC_0DAY; + $this->tmpCat = Category::PC_0DAY; + $this->tmpTag[] = Category::PC_0DAY; break; case $group === 'alt.binaries.cd.lossless': if ($this->categorizeForeign && $this->isMusicForeign()) { break; } - $this->tmpCat = self::MUSIC_LOSSLESS; + $this->tmpCat = Category::MUSIC_LOSSLESS; + $this->tmpTag[] = Category::MUSIC_LOSSLESS; break; case $group === 'alt.binaries.classic.tv.shows': - $this->tmpCat = self::TV_SD; + $this->tmpCat = Category::TV_SD; + $this->tmpTag[] = Category::TV_SD; break; case preg_match('/alt\.binaries\.(comics\.dcp|pictures\.comics\.(complete|dcp|reposts?))$/', $group): if ($this->categorizeForeign && $this->isBookForeign()) { break; } - $this->tmpCat = self::BOOKS_COMICS; + $this->tmpCat = Category::BOOKS_COMICS; + $this->tmpTag[] = Category::BOOKS_COMICS; break; case $group === 'alt.binaries.console.ps3': if ($this->isGamePS4()) { break; } - $this->tmpCat = self::GAME_PS3; + $this->tmpCat = Category::GAME_PS3; + $this->tmpTag[] = Category::GAME_PS3; break; case $group === 'alt.binaries.cores': if ($this->isXxx()) { @@ -233,7 +252,8 @@ class Categorize extends Category case $this->isXxx(): break; default: - $this->tmpCat = self::MUSIC_MP3; + $this->tmpCat = Category::MUSIC_MP3; + $this->tmpTag[] = Category::MUSIC_MP3; break; } break; @@ -244,7 +264,8 @@ class Categorize extends Category case $this->isMovie(): break; default: - $this->tmpCat = self::OTHER_MISC; + $this->tmpCat = Category::OTHER_MISC; + $this->tmpTag[] = Category::OTHER_MISC; break; } break; @@ -252,7 +273,8 @@ class Categorize extends Category if ($this->isMovie()) { break; } - $this->tmpCat = self::OTHER_MISC; + $this->tmpCat = Category::OTHER_MISC; + $this->tmpTag[] = Category::OTHER_MISC; break; case preg_match('/alt\.binaries\.(dvdnordic\.org|nordic\.(dvdr?|xvid))|dk\.(binaer|binaries)\.film(\.divx)?$/', $group): if ($this->categorizeForeign && $this->isMovieForeign()) { @@ -261,25 +283,30 @@ class Categorize extends Category if ($this->isMovie()) { break; } - $this->tmpCat = self::MOVIE_FOREIGN; + $this->tmpCat = Category::MOVIE_FOREIGN; + $this->tmpTag[] = Category::MOVIE_FOREIGN; break; case $group === 'alt.binaries.documentaries': - $this->tmpCat = self::TV_DOCU; + $this->tmpCat = Category::TV_DOCU; + $this->tmpTag[] = Category::TV_DOCU; break; case $group === 'alt.binaries.dreamcast': - $this->tmpCat = self::GAME_OTHER; + $this->tmpCat = Category::GAME_OTHER; + $this->tmpTag[] = Category::GAME_OTHER; break; case preg_match('/alt\.binaries\.e\-?books?(([\.\-])(technical|textbooks))/', $group): if ($this->categorizeForeign && $this->isBookForeign()) { break; } - $this->tmpCat = self::BOOKS_TECHNICAL; + $this->tmpCat = Category::BOOKS_TECHNICAL; + $this->tmpTag[] = Category::BOOKS_TECHNICAL; break; case $group === 'alt.binaries.e-book.magazines': if ($this->categorizeForeign && $this->isBookForeign()) { break; } - $this->tmpCat = self::BOOKS_MAGAZINES; + $this->tmpCat = Category::BOOKS_MAGAZINES; + $this->tmpTag[] = Category::BOOKS_MAGAZINES; break; case $group === 'alt.binaries.e-book.rpg': switch (true) { @@ -289,7 +316,8 @@ class Categorize extends Category case $this->isBook(): break; default: - $this->tmpCat = self::BOOKS_UNKNOWN; + $this->tmpCat = Category::BOOKS_UNKNOWN; + $this->tmpTag[] = Category::BOOKS_UNKNOWN; break; } break; @@ -302,10 +330,12 @@ class Categorize extends Category case $this->categorizeForeign && $this->isBookForeign(): break; case preg_match('/[a-z0-9 \',]+ - \[? ?[a-z0-9 \']+ ?\]? - [a-z0-9 \']+/i', $this->releaseName): - $this->tmpCat = self::BOOKS_EBOOK; + $this->tmpCat = Category::BOOKS_EBOOK; + $this->tmpTag[] = Category::BOOKS_EBOOK; break; default: - $this->tmpCat = self::BOOKS_UNKNOWN; + $this->tmpCat = Category::BOOKS_UNKNOWN; + $this->tmpTag[] = Category::BOOKS_UNKNOWN; break; } break; @@ -313,11 +343,13 @@ class Categorize extends Category if ($this->isXxx()) { break; } - $this->tmpCat = self::XXX_OTHER; + $this->tmpCat = Category::XXX_OTHER; + $this->tmpTag[] = Category::XXX_OTHER; break; case $group === 'alt.binaries.cd.image.sega-saturn': case $group === 'alt.binaries.gamecube': - $this->tmpCat = self::GAME_OTHER; + $this->tmpCat = Category::GAME_OTHER; + $this->tmpTag[] = Category::GAME_OTHER; break; case preg_match('/alt.binaries.games/', $group): switch (true) { @@ -326,7 +358,8 @@ class Categorize extends Category case $this->isConsole(): break; default: - $this->tmpCat = self::PC_GAMES; + $this->tmpCat = Category::PC_GAMES; + $this->tmpTag[] = Category::PC_GAMES; break; } break; @@ -337,7 +370,8 @@ class Categorize extends Category case $this->isConsole(): break; default: - $this->tmpCat = self::PC_GAMES; + $this->tmpCat = Category::PC_GAMES; + $this->tmpTag[] = Category::PC_GAMES; break; } break; @@ -348,7 +382,8 @@ class Categorize extends Category case $this->isBook(): break; default: - $this->tmpCat = self::PC_GAMES; + $this->tmpCat = Category::PC_GAMES; + $this->tmpTag[] = Category::PC_GAMES; break; } break; @@ -359,7 +394,8 @@ class Categorize extends Category case $this->isTV(): break; default: - $this->tmpCat = self::PC_GAMES; + $this->tmpCat = Category::PC_GAMES; + $this->tmpTag[] = Category::PC_GAMES; break; } break; @@ -367,13 +403,15 @@ class Categorize extends Category if ($this->isGameNDS()) { break; } - $this->tmpCat = self::GAME_3DS; + $this->tmpCat = Category::GAME_3DS; + $this->tmpTag[] = Category::GAME_3DS; break; case preg_match('/alt\.binaries\.(games|emulators)?\.?nintendo[\.-]?ds/', $group): if ($this->isGame3DS()) { break; } - $this->tmpCat = self::GAME_NDS; + $this->tmpCat = Category::GAME_NDS; + $this->tmpTag[] = Category::GAME_NDS; break; case $group === 'alt.binaries.games.wii': switch (true) { @@ -381,7 +419,8 @@ class Categorize extends Category case $this->isGameWiiU(): break; default: - $this->tmpCat = self::GAME_WII; + $this->tmpCat = Category::GAME_WII; + $this->tmpTag[] = Category::GAME_WII; break; } break; @@ -392,7 +431,8 @@ class Categorize extends Category case $this->isGameXBOXONE(): break; default: - $this->tmpCat = self::GAME_XBOX; + $this->tmpCat = Category::GAME_XBOX; + $this->tmpTag[] = Category::GAME_XBOX; break; } break; @@ -402,7 +442,8 @@ class Categorize extends Category case $this->isGameXBOXONE(): break; default: - $this->tmpCat = self::GAME_XBOX360; + $this->tmpCat = Category::GAME_XBOX360; + $this->tmpTag[] = Category::GAME_XBOX360; break; } break; @@ -421,23 +462,27 @@ class Categorize extends Category break; case preg_match('/-+(19|20)\d\d-\(?(album.*?|back|cover|front)\)?-+/i', $this->releaseName): case preg_match('/(19|20)\d\d$/', $this->releaseName) && ctype_lower(preg_replace('/[^a-z]/i', '', $this->releaseName)): - $this->tmpCat = self::MUSIC_OTHER; + $this->tmpCat = Category::MUSIC_OTHER; + $this->tmpTag[] = Category::MUSIC_OTHER; break; default: return false; } break; case preg_match('/alt\.binaries\.ipod\.videos\.tvshows$/', $group): - $this->tmpCat = self::TV_OTHER; + $this->tmpCat = Category::TV_OTHER; + $this->tmpTag[] = Category::TV_OTHER; break; case $group === 'alt.binaries.mac': - $this->tmpCat = self::PC_MAC; + $this->tmpCat = Category::PC_MAC; + $this->tmpTag[] = Category::PC_MAC; break; case $group === 'alt.binaries.mma': if ($this->is0day()) { break; } - $this->tmpCat = self::TV_SPORT; + $this->tmpCat = Category::TV_SPORT; + $this->tmpTag[] = Category::TV_SPORT; break; case $group === 'alt.binaries.moovee': switch (true) { @@ -452,7 +497,8 @@ class Categorize extends Category case $this->isMovieHD(): // Check the movie isn't an HD release before blindly assigning SD break; default: - $this->tmpCat = self::MOVIE_SD; + $this->tmpCat = Category::MOVIE_SD; + $this->tmpTag[] = Category::MOVIE_SD; break; } break; @@ -460,7 +506,8 @@ class Categorize extends Category if ($this->categorizeForeign && $this->isMusicForeign()) { break; } - $this->tmpCat = self::MUSIC_VIDEO; + $this->tmpCat = Category::MUSIC_VIDEO; + $this->tmpTag[] = Category::MUSIC_VIDEO; break; case $group === 'alt.binaries.multimedia': switch (true) { @@ -475,24 +522,29 @@ class Categorize extends Category case $this->isMovieHD(): break; default: - $this->tmpCat = self::TV_HD; + $this->tmpCat = Category::TV_HD; + $this->tmpTag[] = Category::TV_HD; } break; case $group === 'alt.binaries.multimedia.documentaries': - $this->tmpCat = self::TV_DOCU; + $this->tmpCat = Category::TV_DOCU; + $this->tmpTag[] = Category::TV_DOCU; break; case preg_match('/alt\.binaries\.multimedia\.sports(\.boxing)?$/', $group): - $this->tmpCat = self::TV_SPORT; + $this->tmpCat = Category::TV_SPORT; + $this->tmpTag[] = Category::TV_SPORT; break; case $group === 'alt.binaries.music.opera': switch (true) { case $this->categorizeForeign && $this->isMusicForeign(): break; case preg_match('/720p|[-._ ]mkv/i', $this->releaseName): - $this->tmpCat = self::MUSIC_VIDEO; + $this->tmpCat = Category::MUSIC_VIDEO; + $this->tmpTag[] = Category::MUSIC_VIDEO; break; default: - $this->tmpCat = self::MUSIC_MP3; + $this->tmpCat = Category::MUSIC_MP3; + $this->tmpTag[] = Category::MUSIC_MP3; break; } break; @@ -502,7 +554,8 @@ class Categorize extends Category case $this->isMusic(): break; default: - $this->tmpCat = self::MUSIC_MP3; + $this->tmpCat = Category::MUSIC_MP3; + $this->tmpTag[] = Category::MUSIC_MP3; break; } break; @@ -510,10 +563,12 @@ class Categorize extends Category if ($this->categorizeForeign && $this->isMusicForeign()) { break; } - $this->tmpCat = self::MUSIC_AUDIOBOOK; + $this->tmpCat = Category::MUSIC_AUDIOBOOK; + $this->tmpTag[] = Category::MUSIC_AUDIOBOOK; break; case $group === 'alt.binaries.pro-wrestling': - $this->tmpCat = self::TV_SPORT; + $this->tmpCat = Category::TV_SPORT; + $this->tmpTag[] = Category::TV_SPORT; break; case preg_match('/alt\.binaries\.sounds\.(flac(\.jazz)?|jpop|lossless(\.[a-z0-9]+)?)|alt\.binaries\.(cd\.lossless|music\.flac)$/i', $group): switch (true) { @@ -521,7 +576,8 @@ class Categorize extends Category case $this->isMusic(): break; default: - $this->tmpCat = self::MUSIC_LOSSLESS; + $this->tmpCat = Category::MUSIC_LOSSLESS; + $this->tmpTag[] = Category::MUSIC_LOSSLESS; break; } break; @@ -530,7 +586,8 @@ class Categorize extends Category case $this->categorizeForeign && $this->isMusicForeign(): break; case ! preg_match('/[-._ ]scans[-._ ]/i', $this->releaseName): - $this->tmpCat = self::MUSIC_MP3; + $this->tmpCat = Category::MUSIC_MP3; + $this->tmpTag[] = Category::MUSIC_MP3; break; default: return false; @@ -540,13 +597,15 @@ class Categorize extends Category if ($this->categorizeForeign && $this->isMusicForeign()) { break; } - $this->tmpCat = self::MUSIC_OTHER; + $this->tmpCat = Category::MUSIC_OTHER; + $this->tmpTag[] = Category::MUSIC_OTHER; break; case $group === 'alt.binaries.sony.psp': if ($this->isGamePSVita()) { break; } - $this->tmpCat = self::GAME_PSP; + $this->tmpCat = Category::GAME_PSP; + $this->tmpTag[] = Category::GAME_PSP; break; case $group === 'alt.binaries.warez': switch (true) { @@ -556,21 +615,25 @@ class Categorize extends Category case $this->isConsole(): break; default: - $this->tmpCat = self::PC_0DAY; + $this->tmpCat = Category::PC_0DAY; + $this->tmpTag[] = Category::PC_0DAY; break; } break; case $group === 'alt.binaries.warez.games': - $this->tmpCat = self::PC_GAMES; + $this->tmpCat = Category::PC_GAMES; + $this->tmpTag[] = Category::PC_GAMES; break; case $group === 'alt.binaries.warez.smartphone': if ($this->isPhone()) { break; } - $this->tmpCat = self::PC_PHONE_OTHER; + $this->tmpCat = Category::PC_PHONE_OTHER; + $this->tmpTag[] = Category::PC_PHONE_OTHER; break; case $this->categorizeForeign && $group === 'dk.binaer.tv': - $this->tmpCat = self::TV_FOREIGN; + $this->tmpCat = Category::TV_FOREIGN; + $this->tmpTag[] = Category::TV_FOREIGN; break; default: return false; @@ -593,6 +656,7 @@ class Categorize extends Category $cat = $this->regexes->tryRegex($this->releaseName, $this->groupName()); if ($cat) { $this->tmpCat = $cat; + $this->tmpTag[] = $cat; return true; } @@ -625,7 +689,8 @@ class Categorize extends Category case $this->isOtherTV2(): return true; default: - $this->tmpCat = self::TV_OTHER; + $this->tmpCat = Category::TV_OTHER; + $this->tmpTag[] = Category::TV_OTHER; return true; } @@ -635,7 +700,8 @@ class Categorize extends Category if ($this->isSportTV()) { return true; } - $this->tmpCat = self::TV_OTHER; + $this->tmpCat = Category::TV_OTHER; + $this->tmpTag[] = Category::TV_OTHER; return true; } @@ -652,7 +718,8 @@ class Categorize extends Category //special case for "Have.I.Got.News.For.You" tv show && ! preg_match('/[-._ ]Got[-._ ]News[-._ ]For[-._ ]You/i', $this->releaseName) ) { - $this->tmpCat = self::TV_OTHER; + $this->tmpCat = Category::TV_OTHER; + $this->tmpTag[] = Category::TV_OTHER; return true; } @@ -673,7 +740,8 @@ class Categorize extends Category case preg_match('/[-._ ](720p|1080p|Divx|DOKU|DUB(BED)?|DLMUX|NOVARIP|RealCo|Sub(bed|s)?|Web[-._ ]?Rip|WS|Xvid).+(brazilian|chinese|croatian|danish|deutsch|dutch|estonian|flemish|finnish|french|german|greek|hebrew|icelandic|italian|ita|latin|mandarin|nordic|norwegian|polish|portuguese|japenese|japanese|russian|serbian|slovenian|spanish|spanisch|swedish|thai|turkish)[-._ ]/i', $this->releaseName): case preg_match('/(S\d\d[EX]\d\d|DOCU(MENTAIRE)?|TV)?[-._ ](FRENCH|German|Dutch)[-._ ](720p|1080p|dv([bd])r(ip)?|LD|HD\-?TV|TV[-._ ]?RIP|x264)[-._ ]/i', $this->releaseName): case preg_match('/[-._ ]FastSUB|NL|nlvlaams|patrfa|RealCO|Seizoen|slosinh|Videomann|Vostfr|xslidian[-._ ]|x264\-iZU/i', $this->releaseName): - $this->tmpCat = self::TV_FOREIGN; + $this->tmpCat = Category::TV_FOREIGN; + $this->tmpTag[] = Category::TV_FOREIGN; return true; default: @@ -694,7 +762,8 @@ class Categorize extends Category case preg_match('/[-._ ]?(AFL|Grand Prix|Indy[-._ ]Car|(iMPACT|Smoky[-._ ]Mountain|Texas)[-._ ]Wrestling|Moto[-._ ]?GP|NSCS[-._ ]ROUND|NECW|Poker|PWX|Rugby|WCW)[-._ ]/i', $this->releaseName): case preg_match('/[-._ ]?(Horse)[-._ ]Racing[-._ ]/i', $this->releaseName): case preg_match('/[-._ ](VERUM|GRiP|Ebi|OVERTAKE)/i', $this->releaseName): - $this->tmpCat = self::TV_SPORT; + $this->tmpCat = Category::TV_SPORT; + $this->tmpTag[] = Category::TV_SPORT; return true; default: @@ -708,7 +777,8 @@ class Categorize extends Category public function isDocumentaryTV(): bool { if (preg_match('/[-._ ](Docu|Documentary)[-._ ]/i', $this->releaseName)) { - $this->tmpCat = self::TV_DOCU; + $this->tmpCat = Category::TV_DOCU; + $this->tmpTag[] = Category::TV_DOCU; return true; } @@ -722,7 +792,8 @@ class Categorize extends Category public function isWEBDL(): bool { if (preg_match('/web[-._ ]dl|web-?rip/i', $this->releaseName)) { - $this->tmpCat = self::TV_WEBDL; + $this->tmpCat = Category::TV_WEBDL; + $this->tmpTag[] = [Category::TV_WEBDL, Category::TV_HD]; return true; } @@ -736,12 +807,15 @@ class Categorize extends Category public function isAnimeTV(): bool { if (preg_match('/[-._ ]Anime[-._ ]|^\[[a-zA-Z\.\-]+\].*[-_].*\d{1,3}[-_. ](([\[\(])((\d{1,4}x\d{1,4})|(h264-)?\d{3,4}([pi]))([\]\)])\s?(\[AAC\])?|\[[a-fA-F0-9]{8}\]|(8|10)BIT|hi10p)(\[[a-fA-F0-9]{8}\])?/i', $this->releaseName)) { - $this->tmpCat = self::TV_ANIME; + $this->tmpCat = Category::TV_ANIME; + $this->tmpTag[] = Category::TV_ANIME; + return true; } if (preg_match('/(ANiHLS|HaiKU|ANiURL)/i', $this->releaseName)) { - $this->tmpCat = self::TV_ANIME; + $this->tmpCat = Category::TV_ANIME; + $this->tmpTag[] = Category::TV_ANIME; return true; } @@ -755,12 +829,14 @@ class Categorize extends Category public function isHDTV(): bool { if (preg_match('/1080([ip])|720p|bluray/i', $this->releaseName)) { - $this->tmpCat = self::TV_HD; + $this->tmpCat = Category::TV_HD; + $this->tmpTag[] = Category::TV_HD; return true; } if ($this->catWebDL === false && preg_match('/web[-._ ]dl|web-?rip/i', $this->releaseName)) { - $this->tmpCat = self::TV_HD; + $this->tmpCat = Category::TV_HD; + $this->tmpTag[] = Category::TV_HD; return true; } @@ -774,7 +850,8 @@ class Categorize extends Category public function isUHDTV(): bool { if (preg_match('/(S\d+).*(2160p).*(Netflix|Amazon|NF|AMZN).*(TrollUHD|NTb|VLAD|DEFLATE|POFUDUK)/i', $this->releaseName)) { - $this->tmpCat = self::TV_UHD; + $this->tmpCat = Category::TV_UHD; + $this->tmpTag[] = [Category::TV_UHD, Category::TV_HD]; return true; } @@ -791,7 +868,8 @@ class Categorize extends Category case preg_match('/(360|480|576)p|Complete[-._ ]Season|dvdr(ip)?|dvd5|dvd9|\.pdtv|SD[-._ ]TV|TVRip|NTSC|BDRip|hdtv|xvid/i', $this->releaseName): case preg_match('/(([HP])D[-._ ]?TV|DSR|WebRip)[-._ ]x264/i', $this->releaseName): case preg_match('/s\d{1,3}[-._ ]?[ed]\d{1,3}([ex]\d{1,3}|[-.\w ])|\s\d{3,4}\s/i', $this->releaseName) && preg_match('/([HP])D[-._ ]?TV|BDRip|WEB[-._ ]x264/i', $this->releaseName): - $this->tmpCat = self::TV_SD; + $this->tmpCat = Category::TV_SD; + $this->tmpTag[] = Category::TV_SD; return true; default: @@ -805,7 +883,8 @@ class Categorize extends Category public function isOtherTV2(): bool { if (preg_match('/[-._ ]s\d{1,3}[-._ ]?(e|d(isc)?)\d{1,3}([-._ ]|$)/i', $this->releaseName)) { - $this->tmpCat = self::TV_OTHER; + $this->tmpCat = Category::TV_OTHER; + $this->tmpTag[] = Category::TV_OTHER; return true; } @@ -819,7 +898,8 @@ class Categorize extends Category public function isTVx265(): bool { if (preg_match('/(S\d+).*(x265).*(rmteam|MeGusta|HETeam|PSA|ONLY|H4S5S|TrollHD|ImE)/i', $this->releaseName)) { - $this->tmpCat = self::TV_X265; + $this->tmpCat = Category::TV_X265; + $this->tmpTag[] = [Category::TV_X265, Category::TV_HD]; return true; } @@ -866,7 +946,8 @@ class Categorize extends Category case preg_match('/(danish|flemish|Deutsch|dutch|french|german|heb|hebrew|nl[-._ ]?sub|dub(bed|s)?|\.NL|norwegian|swedish|swesub|spanish|Staffel)[-._ ]|\(german\)|Multisub/i', $this->releaseName): case stripos($this->releaseName, 'Castellano') !== false: case preg_match('/(720p|1080p|AC3|AVC|DIVX|DVD(5|9|RIP|R)|XVID)[-._ ](Dutch|French|German|ITA)|\(?(Dutch|French|German|ITA)\)?[-._ ](720P|1080p|AC3|AVC|DIVX|DVD(5|9|RIP|R)|HD[-._ ]|XVID)/i', $this->releaseName): - $this->tmpCat = self::MOVIE_FOREIGN; + $this->tmpCat = Category::MOVIE_FOREIGN; + $this->tmpTag[] = Category::MOVIE_FOREIGN; return true; default: @@ -880,7 +961,8 @@ class Categorize extends Category public function isMovieDVD(): bool { if (preg_match('/(dvd\-?r|[-._ ]dvd|dvd9|dvd5|[-._ ]r5)[-._ ]/i', $this->releaseName)) { - $this->tmpCat = self::MOVIE_DVD; + $this->tmpCat = Category::MOVIE_DVD; + $this->tmpTag[] = Category::MOVIE_DVD; return true; } @@ -894,7 +976,8 @@ class Categorize extends Category public function isMovieSD(): bool { if (preg_match('/(divx|dvdscr|extrascene|dvdrip|\.CAM|HDTS(-LINE)?|vhsrip|xvid(vd)?)[-._ ]/i', $this->releaseName)) { - $this->tmpCat = self::MOVIE_SD; + $this->tmpCat = Category::MOVIE_SD; + $this->tmpTag[] = Category::MOVIE_SD; return true; } @@ -908,7 +991,8 @@ class Categorize extends Category public function isMovie3D(): bool { if (preg_match('/[-._ ]3D\s?[\.\-_\[ ](1080p|(19|20)\d\d|AVC|BD(25|50)|Blu[-._ ]?ray|CEE|Complete|GER|MVC|MULTi|SBS|H(-)?SBS)[-._ ]/i', $this->releaseName)) { - $this->tmpCat = self::MOVIE_3D; + $this->tmpCat = Category::MOVIE_3D; + $this->tmpTag[] = Category::MOVIE_3D; return true; } @@ -923,7 +1007,8 @@ class Categorize extends Category { if (preg_match('/bluray\-|[-._ ]bd?[-._ ]?(25|50)|blu-ray|Bluray\s\-\sUntouched|[-._ ]untouched[-._ ]/i', $this->releaseName) && ! preg_match('/SecretUsenet\.com/i', $this->releaseName)) { - $this->tmpCat = self::MOVIE_BLURAY; + $this->tmpCat = Category::MOVIE_BLURAY; + $this->tmpTag[] = Category::MOVIE_BLURAY; return true; } @@ -937,12 +1022,14 @@ class Categorize extends Category public function isMovieHD(): bool { if (preg_match('/720p|1080p|AVC|VC1|VC\-1|web\-dl|wmvhd|x264|XvidHD|bdrip/i', $this->releaseName)) { - $this->tmpCat = self::MOVIE_HD; + $this->tmpCat = Category::MOVIE_HD; + $this->tmpTag[] = Category::MOVIE_HD; return true; } if ($this->catWebDL === false && preg_match('/web[-._ ]dl|web-?rip/i', $this->releaseName)) { - $this->tmpCat = self::MOVIE_HD; + $this->tmpCat = Category::MOVIE_HD; + $this->tmpTag[] = Category::MOVIE_HD; return true; } @@ -956,7 +1043,8 @@ class Categorize extends Category public function isMovieUHD(): bool { if (! preg_match('/(S\d+).*(2160p).*(Netflix|Amazon).*(TrollUHD|NTb|VLAD)/i', $this->releaseName) && false !== stripos($this->releaseName, '2160p')) { - $this->tmpCat = self::MOVIE_UHD; + $this->tmpCat = Category::MOVIE_UHD; + $this->tmpTag[] = [Category::MOVIE_UHD, Category::MOVIE_HD]; return true; } @@ -970,7 +1058,8 @@ class Categorize extends Category public function isMovieOther(): bool { if (preg_match('/[-._ ]cam[-._ ]/i', $this->releaseName)) { - $this->tmpCat = self::MOVIE_OTHER; + $this->tmpCat = Category::MOVIE_OTHER; + $this->tmpTag[] = Category::MOVIE_OTHER; return true; } @@ -984,7 +1073,8 @@ class Categorize extends Category public function isMovieWEBDL(): bool { if (preg_match('/web[-._ ]dl|web-?rip/i', $this->releaseName)) { - $this->tmpCat = self::MOVIE_WEBDL; + $this->tmpCat = Category::MOVIE_WEBDL; + $this->tmpTag[] = [Category::MOVIE_WEBDL, Category::MOVIE_HD]; return true; } @@ -998,7 +1088,8 @@ class Categorize extends Category public function isMovieX265(): bool { if (preg_match('/(\w+[\.-_\s]+).*(x265).*(Tigole|SESKAPiLE|CHD|IAMABLE|THREESOME|OohLaLa|DEFLATE|NCmt)/i', $this->releaseName)) { - $this->tmpCat = self::MOVIE_X265; + $this->tmpCat = Category::MOVIE_X265; + $this->tmpTag[] = [Category::MOVIE_X265, Category::MOVIE_HD]; return true; } @@ -1034,13 +1125,16 @@ class Categorize extends Category { switch (true) { case preg_match('/[^a-z0-9](IPHONE|ITOUCH|IPAD)[-._ ]/i', $this->releaseName): - $this->tmpCat = self::PC_PHONE_IOS; + $this->tmpCat = Category::PC_PHONE_IOS; + $this->tmpTag[] = Category::PC_PHONE_IOS; break; case preg_match('/[-._ ]?(ANDROID)[-._ ]/i', $this->releaseName): - $this->tmpCat = self::PC_PHONE_ANDROID; + $this->tmpCat = Category::PC_PHONE_ANDROID; + $this->tmpTag[] = Category::PC_PHONE_ANDROID; break; case preg_match('/[^a-z0-9](symbian|xscale|wm5|wm6)[-._ ]/i', $this->releaseName): - $this->tmpCat = self::PC_PHONE_OTHER; + $this->tmpCat = Category::PC_PHONE_OTHER; + $this->tmpTag[] = Category::PC_PHONE_OTHER; break; default: return false; @@ -1057,7 +1151,8 @@ class Categorize extends Category switch (true) { case preg_match('/[-._ ]([a-zA-Z]{2,10})?iso[ _.-]|[-. ]([a-z]{2,10})?iso$/i', $this->releaseName): case preg_match('/[-._ ](DYNAMiCS|INFINITESKILLS|UDEMY|kEISO|PLURALSIGHT|DIGITALTUTORS|TUTSPLUS|OSTraining|PRODEV|CBT\.Nuggets|COMPRISED)/i', $this->releaseName): - $this->tmpCat = self::PC_ISO; + $this->tmpCat = Category::PC_ISO; + $this->tmpTag[] = Category::PC_ISO; return true; default: @@ -1074,7 +1169,8 @@ class Categorize extends Category case preg_match('/[-._ ]exe$|[-._ ](utorrent|Virtualbox)[-._ ]|\b0DAY\b|incl.+crack| DRM$|>DRMreleaseName): case preg_match('/[-._ ]((32|64)bit|converter|i\d86|key(gen|maker)|freebsd|GAMEGUiDE|hpux|irix|linux|multilingual|Patch|Pro v\d{1,3}|portable|regged|software|solaris|template|unix|win2kxp2k3|win64|win(2k|32|64|all|dows|nt(2k)?(xp)?|xp)|win9x(me|nt)?|x(32|64|86))[-._ ]/i', $this->releaseName): case preg_match('/\b(Adobe|auto(cad|desk)|-BEAN|Cracked|Cucusoft|CYGNUS|Divx[-._ ]Plus|\.(deb|exe)|DIGERATI|FOSI|-FONT|Key(filemaker|gen|maker)|Lynda\.com|lz0|MULTiLANGUAGE|Microsoft\s*(Office|Windows|Server)|MultiOS|-(iNViSiBLE|SPYRAL|SUNiSO|UNION|TE)|v\d{1,3}.*?Pro|[-._ ]v\d{1,3}[-._ ]|\(x(64|86)\)|Xilisoft)\b/i', $this->releaseName): - $this->tmpCat = self::PC_0DAY; + $this->tmpCat = Category::PC_0DAY; + $this->tmpTag[] = Category::PC_0DAY; return true; default: @@ -1088,7 +1184,8 @@ class Categorize extends Category public function isMac(): bool { if (preg_match('/(\b|[-._ ])mac([\.\s])?osx(\b|[-_. ])/i', $this->releaseName)) { - $this->tmpCat = self::PC_MAC; + $this->tmpCat = Category::PC_MAC; + $this->tmpTag[] = Category::PC_MAC; return true; } @@ -1102,7 +1199,8 @@ class Categorize extends Category public function isPCGame(): bool { if (preg_match('/[^a-z0-9](0x0007|ALiAS|BACKLASH|BAT|CLONECD|CPY|FAS(DOX|iSO)|FLT([-._ ]|COGENT)|FLT(DOX)?|PC GAMES?|\(?(Game([sz])|GAME([SZ]))\)? ?(\(([Cc])\))|GENESIS|-GOG|-HATRED|HI2U|INLAWS|JAGUAR|MAZE|MONEY|OUTLAWS|PPTCLASSiCS|PC Game|PROPHET|RAiN|Razor1911|RELOADED|DEViANCE|PLAZA|RiTUELYPOGEiOS|[rR][iI][pP]-[uU][nN][lL][eE][aA][sS][hH][eE][dD]|Steam(\b)?Rip|SKIDROW|TiNYiSO|CODEX)[^a-z0-9]?/', $this->releaseName)) { - $this->tmpCat = self::PC_GAMES; + $this->tmpCat = Category::PC_GAMES; + $this->tmpTag[] = Category::PC_GAMES; return true; } @@ -1135,7 +1233,8 @@ class Categorize extends Category return true; default: - $this->tmpCat = self::XXX_OTHER; + $this->tmpCat = Category::XXX_OTHER; + $this->tmpTag[] = Category::XXX_OTHER; return true; } @@ -1147,12 +1246,14 @@ class Categorize extends Category public function isXxx264(): bool { if (preg_match('/720p|1080(hd|[ip])|[xh][^a-z0-9]?264/i', $this->releaseName) && ! preg_match('/\bwmv\b/i', $this->releaseName) && stripos($this->releaseName, 'SDX264XXX') === false) { - $this->tmpCat = self::XXX_X264; + $this->tmpCat = Category::XXX_X264; + $this->tmpTag[] = Category::XXX_X264; return true; } if ($this->catWebDL === false && preg_match('/web[-._ ]dl|web-?rip/i', $this->releaseName)) { - $this->tmpCat = self::XXX_X264; + $this->tmpCat = Category::XXX_X264; + $this->tmpTag[] = Category::XXX_X264; return true; } @@ -1166,7 +1267,8 @@ class Categorize extends Category public function isXxxUHD(): bool { if (preg_match('/^[\w\-.]+(\d{2}\.\d{2}\.\d{2}).+(2160p)+[\w\-.]+(M[PO][V4]-(KTR|GUSH|FaiLED|SEXORS|hUSHhUSH|YAPG))/i', $this->releaseName)) { - $this->tmpCat = self::XXX_UHD; + $this->tmpCat = Category::XXX_UHD; + $this->tmpTag[] = Category::XXX_UHD; return true; } @@ -1180,7 +1282,8 @@ class Categorize extends Category public function isXxxClipHD(): bool { if (preg_match('/^[\w\-.]+(\d{2}\.\d{2}\.\d{2}).+(720|1080)+[\w\-.]+(M[PO][V4]-(KTR|GUSH|FaiLED|SEXORS|hUSHhUSH|YAPG))/i', $this->releaseName)) { - $this->tmpCat = self::XXX_CLIPHD; + $this->tmpCat = Category::XXX_CLIPHD; + $this->tmpTag[] = Category::XXX_CLIPHD; return true; } @@ -1194,7 +1297,8 @@ class Categorize extends Category public function isXxxWMV(): bool { if (preg_match('/(\d{2}\.\d{2}\.\d{2})|([ex]\d{2,})|[^a-z0-9](f4v|flv|isom|(issue\.\d{2,})|mov|mp(4|eg)|multiformat|pack-|realmedia|uhq|wmv)[^a-z0-9]/i', $this->releaseName) && stripos($this->releaseName, 'SDX264XXX') === false) { - $this->tmpCat = self::XXX_WMV; + $this->tmpCat = Category::XXX_WMV; + $this->tmpTag[] = Category::XXX_WMV; return true; } @@ -1208,7 +1312,8 @@ class Categorize extends Category public function isXxxXvid(): bool { if (preg_match('/(b[dr]|dvd)rip|detoxication|divx|nympho|pornolation|swe6|tesoro|xvid/i', $this->releaseName)) { - $this->tmpCat = self::XXX_XVID; + $this->tmpCat = Category::XXX_XVID; + $this->tmpTag[] = Category::XXX_XVID; return true; } @@ -1222,7 +1327,8 @@ class Categorize extends Category public function isXxxDVD(): bool { if (preg_match('/dvdr[^i]|dvd[59]/i', $this->releaseName)) { - $this->tmpCat = self::XXX_DVD; + $this->tmpCat = Category::XXX_DVD; + $this->tmpTag[] = Category::XXX_DVD; return true; } @@ -1236,7 +1342,8 @@ class Categorize extends Category public function isXxxImageset(): bool { if (preg_match('/IMAGESET|PICTURESET|ABPEA/i', $this->releaseName)) { - $this->tmpCat = self::XXX_IMAGESET; + $this->tmpCat = Category::XXX_IMAGESET; + $this->tmpTag[] = Category::XXX_IMAGESET; return true; } @@ -1250,7 +1357,8 @@ class Categorize extends Category public function isXxxPack(): bool { if (preg_match('/[ .]PACK[ .]/i', $this->releaseName)) { - $this->tmpCat = self::XXX_PACK; + $this->tmpCat = Category::XXX_PACK; + $this->tmpTag[] = Category::XXX_PACK; return true; } @@ -1265,7 +1373,8 @@ class Categorize extends Category { // If nothing else matches, then try these words. if (preg_match('/[-._ ]Brazzers|Creampie|[-._ ]JAV[-._ ]|North\.Pole|^Nubiles|She[-._ ]?Male|Transsexual|OLDER ANGELS/i', $this->releaseName)) { - $this->tmpCat = self::XXX_OTHER; + $this->tmpCat = Category::XXX_OTHER; + $this->tmpTag[] = Category::XXX_OTHER; return true; } @@ -1279,14 +1388,15 @@ class Categorize extends Category public function isXxxClipSD(): bool { switch (true) { - case $this->checkPoster('/oz@lot[.]com/i', $this->poster, self::XXX_CLIPSD): + case $this->checkPoster('/oz@lot[.]com/i', $this->poster, Category::XXX_CLIPSD): return true; - case $this->checkPoster('/anon@y[.]com/i', $this->poster, self::XXX_CLIPSD): + case $this->checkPoster('/anon@y[.]com/i', $this->poster, Category::XXX_CLIPSD): return true; - case $this->checkPoster('/@md-hobbys[.]com/i', $this->poster, self::XXX_CLIPSD): + case $this->checkPoster('/@md-hobbys[.]com/i', $this->poster, Category::XXX_CLIPSD): return true; case stripos($this->releaseName, 'SDPORN') !== false: - $this->tmpCat = self::XXX_CLIPSD; + $this->tmpCat = Category::XXX_CLIPSD; + $this->tmpTag[] = Category::XXX_CLIPSD; return true; default: @@ -1300,7 +1410,8 @@ class Categorize extends Category public function isXxxSD(): bool { if (preg_match('/SDX264XXX|XXX\.HR\./i', $this->releaseName)) { - $this->tmpCat = self::XXX_SD; + $this->tmpCat = Category::XXX_SD; + $this->tmpTag[] = Category::XXX_SD; return true; } @@ -1314,7 +1425,8 @@ class Categorize extends Category public function isXxxWEBDL(): bool { if (preg_match('/web[-._ ]dl|web-?rip/i', $this->releaseName)) { - $this->tmpCat = self::XXX_WEBDL; + $this->tmpCat = Category::XXX_WEBDL; + $this->tmpTag[] = Category::XXX_WEBDL; return true; } @@ -1358,12 +1470,14 @@ class Categorize extends Category { if (preg_match('/^NDS|[^a-zA-Z0-9]NDS|[\._-](nds|NDS)|nintendo.+[^3]n?dsi?/', $this->releaseName)) { if (preg_match('/\((DE|DSi(\sEnhanched)?|_NDS-|EUR?|FR|GAME|HOL|JP|JPN|NL|NTSC|PAL|KS|USA?)\)/i', $this->releaseName)) { - $this->tmpCat = self::GAME_NDS; + $this->tmpCat = Category::GAME_NDS; + $this->tmpTag[] = Category::GAME_NDS; return true; } if (preg_match('/EUR|FR|GAME|HOL|JP|JPN|NL|NTSC|PAL|KS|USA|\bROMS?(et)?\b/i', $this->releaseName)) { - $this->tmpCat = self::GAME_NDS; + $this->tmpCat = Category::GAME_NDS; + $this->tmpTag[] = Category::GAME_NDS; return true; } @@ -1378,7 +1492,8 @@ class Categorize extends Category public function isGame3DS(): bool { if (preg_match('/\b3DS\b[^max]|[\._-]3ds|nintendo.+3ds|[_\.]3DS-/i', $this->releaseName) && ! preg_match('/3ds max/i', $this->releaseName) && preg_match('/(EUR|FR|GAME|HOL|JP|JPN|NL|NTSC|PAL|KS|USA|ASIA)/i', $this->releaseName)) { - $this->tmpCat = self::GAME_3DS; + $this->tmpCat = Category::GAME_3DS; + $this->tmpTag[] = Category::GAME_3DS; return true; } @@ -1393,12 +1508,14 @@ class Categorize extends Category { if (preg_match('/[\._-]N?G(AME)?C(UBE)?-/i', $this->releaseName)) { if (preg_match('/_(EUR?|FR|GAME|HOL|JP|JPN|NL|NTSC|PAL|KS|USA?)_/i', $this->releaseName)) { - $this->tmpCat = self::GAME_OTHER; + $this->tmpCat = Category::GAME_OTHER; + $this->tmpTag[] = Category::GAME_OTHER; return true; } if (preg_match('/-(((STAR|DEATH|STINKY|MOON|HOLY|G)?CUBE(SOFT)?)|(DARKFORCE|DNL|GP|ICP|iNSOMNIA|JAY|LaKiTu|METHS|NOMIS|QUBiSM|PANDORA|REACT0R|SUNSHiNE|SAVEPOiNT|SYNDiCATE|WAR3X|WRG))/i', $this->releaseName)) { - $this->tmpCat = self::GAME_OTHER; + $this->tmpCat = Category::GAME_OTHER; + $this->tmpTag[] = Category::GAME_OTHER; return true; } @@ -1414,12 +1531,14 @@ class Categorize extends Category { if (preg_match('/[^e]PS3/i', $this->releaseName)) { if (preg_match('/ANTiDOTE|DLC|DUPLEX|EUR?|Googlecus|GOTY|\-HR|iNSOMNi|JAP|JPN|KONDIOS|\[PS3\]|PSN/i', $this->releaseName)) { - $this->tmpCat = self::GAME_PS3; + $this->tmpCat = Category::GAME_PS3; + $this->tmpTag[] = Category::GAME_PS3; return true; } if (preg_match('/AGENCY|APATHY|Caravan|MULTi|NRP|NTSC|PAL|SPLiT|STRiKE|USA?|ZRY/i', $this->releaseName)) { - $this->tmpCat = self::GAME_PS3; + $this->tmpCat = Category::GAME_PS3; + $this->tmpTag[] = Category::GAME_PS3; return true; } @@ -1435,12 +1554,14 @@ class Categorize extends Category { if (preg_match('/[ \(_.-]PS4[ \)_.-]/i', $this->releaseName)) { if (preg_match('/ANTiDOTE|DLC|DUPLEX|EUR?|Googlecus|GOTY|\-HR|iNSOMNi|JAP|JPN|KONDIOS|\[PS4\]/i', $this->releaseName)) { - $this->tmpCat = self::GAME_PS4; + $this->tmpCat = Category::GAME_PS4; + $this->tmpTag[] = Category::GAME_PS4; return true; } if (preg_match('/AGENCY|APATHY|Caravan|MULTi|NRP|NTSC|PAL|SPLiT|STRiKE|USA?|WaYsTeD|ZRY/i', $this->releaseName)) { - $this->tmpCat = self::GAME_PS4; + $this->tmpCat = Category::GAME_PS4; + $this->tmpTag[] = Category::GAME_PS4; return true; } @@ -1456,12 +1577,14 @@ class Categorize extends Category { if (stripos($this->releaseName, 'PSP') !== false) { if (preg_match('/[-._ ](BAHAMUT|Caravan|EBOOT|EMiNENT|EUR?|EvoX|GAME|GHS|Googlecus|HandHeld|\-HR|JAP|JPN|KLOTEKLAPPERS|KOR|NTSC|PAL)/i', $this->releaseName)) { - $this->tmpCat = self::GAME_PSP; + $this->tmpCat = Category::GAME_PSP; + $this->tmpTag[] = Category::GAME_PSP; return true; } if (preg_match('/[-._ ](Dynarox|HAZARD|ITALIAN|KLB|KuDoS|LIGHTFORCE|MiRiBS|POPSTATiON|(PLAY)?ASiA|PSN|PSX2?PSP|SPANiSH|SUXXORS|UMD(RIP)?|USA?|YARR)/i', $this->releaseName)) { - $this->tmpCat = self::GAME_PSP; + $this->tmpCat = Category::GAME_PSP; + $this->tmpTag[] = Category::GAME_PSP; return true; } @@ -1476,7 +1599,8 @@ class Categorize extends Category public function isGamePSVita(): bool { if (preg_match('/PS ?Vita/i', $this->releaseName)) { - $this->tmpCat = self::GAME_PSVITA; + $this->tmpCat = Category::GAME_PSVITA; + $this->tmpTag[] = Category::GAME_PSVITA; return true; } @@ -1490,7 +1614,8 @@ class Categorize extends Category public function isGameWiiWare(): bool { if (preg_match('/(Console|DLC|VC).+[-._ ]WII|(Console|DLC|VC)[-._ ]WII|WII[-._ ].+(Console|DLC|VC)|WII[-._ ](Console|DLC|VC)|WIIWARE/i', $this->releaseName)) { - $this->tmpCat = self::GAME_WIIWARE; + $this->tmpCat = Category::GAME_WIIWARE; + $this->tmpTag[] = Category::GAME_WIIWARE; return true; } @@ -1509,7 +1634,8 @@ class Categorize extends Category case preg_match('/[-._ ](Allstars|BiOSHOCK|dumpTruck|DNi|iCON|JAP|NTSC|PAL|ProCiSiON|PROPER|RANT|REV0|SUNSHiNE|SUSHi|TMD|USA?)/i', $this->releaseName): case preg_match('/[-._ ](APATHY|BAHAMUT|DMZ|ERD|GAME|JPN|LoCAL|MULTi|NAGGERS|OneUp|PLAYME|PONS|Scrubbed|VORTEX|ZARD|ZER0)/i', $this->releaseName): case preg_match('/[-._ ](ALMoST|AMBITION|Caravan|CLiiCHE|DRYB|HaZMaT|KOR|LOADER|MARVEL|PROMiNENT|LaKiTu|LOCAL|QwiiF|RANT)/i', $this->releaseName): - $this->tmpCat = self::GAME_WIIU; + $this->tmpCat = Category::GAME_WIIU; + $this->tmpTag[] = Category::GAME_WIIU; return true; default: @@ -1528,7 +1654,8 @@ class Categorize extends Category case preg_match('/[-._ ](Allstars|BiOSHOCK|dumpTruck|DNi|iCON|JAP|NTSC|PAL|ProCiSiON|PROPER|RANT|REV0|SUNSHiNE|SUSHi|TMD|USA?)/i', $this->releaseName): case preg_match('/[-._ ](APATHY|BAHAMUT|DMZ|ERD|GAME|JPN|LoCAL|MULTi|NAGGERS|OneUp|PLAYME|PONS|Scrubbed|VORTEX|ZARD|ZER0)/i', $this->releaseName): case preg_match('/[-._ ](ALMoST|AMBITION|Caravan|CLiiCHE|DRYB|HaZMaT|KOR|LOADER|MARVEL|PROMiNENT|LaKiTu|LOCAL|QwiiF|RANT)/i', $this->releaseName): - $this->tmpCat = self::GAME_WII; + $this->tmpCat = Category::GAME_WII; + $this->tmpTag[] = Category::GAME_WII; return true; default: @@ -1542,7 +1669,8 @@ class Categorize extends Category public function isGameXBOX360DLC(): bool { if (preg_match('/DLC.+xbox360|xbox360.+DLC|XBLA.+xbox360|xbox360.+XBLA/i', $this->releaseName)) { - $this->tmpCat = self::GAME_XBOX360DLC; + $this->tmpCat = Category::GAME_XBOX360DLC; + $this->tmpTag[] = Category::GAME_XBOX360DLC; return true; } @@ -1556,18 +1684,21 @@ class Categorize extends Category public function isGameXBOX360(): bool { if (stripos($this->releaseName, '/XBOX360/i') !== false) { - $this->tmpCat = self::GAME_XBOX360; + $this->tmpCat = Category::GAME_XBOX360; + $this->tmpTag[] = Category::GAME_XBOX360; return true; } if (stripos($this->releaseName, 'x360') !== false) { if (preg_match('/Allstars|ASiA|CCCLX|COMPLEX|DAGGER|GLoBAL|iMARS|JAP|JPN|MULTi|NTSC|PAL|REPACK|RRoD|RF|SWAG|USA?/i', $this->releaseName)) { - $this->tmpCat = self::GAME_XBOX360; + $this->tmpCat = Category::GAME_XBOX360; + $this->tmpTag[] = Category::GAME_XBOX360; return true; } if (preg_match('/DAMNATION|GERMAN|GOTY|iNT|iTA|JTAG|KINECT|MARVEL|MUX360|RANT|SPARE|SPANISH|VATOS|XGD/i', $this->releaseName)) { - $this->tmpCat = self::GAME_XBOX360; + $this->tmpCat = Category::GAME_XBOX360; + $this->tmpTag[] = Category::GAME_XBOX360; return true; } @@ -1582,7 +1713,8 @@ class Categorize extends Category public function isGameXBOXONE(): bool { if (preg_match('/XBOXONE|XBOX\.ONE/i', $this->releaseName)) { - $this->tmpCat = self::GAME_XBOXONE; + $this->tmpCat = Category::GAME_XBOXONE; + $this->tmpTag[] = Category::GAME_XBOXONE; return true; } @@ -1596,7 +1728,8 @@ class Categorize extends Category public function isGameXBOX(): bool { if (stripos($this->releaseName, 'XBOX') !== false) { - $this->tmpCat = self::GAME_XBOX; + $this->tmpCat = Category::GAME_XBOX; + $this->tmpTag[] = Category::GAME_XBOX; return true; } @@ -1610,7 +1743,8 @@ class Categorize extends Category public function isGameOther(): bool { if (preg_match('/\b(PS(1)X|PS2|SNES|NES|SEGA\s(GENESIS|CD)|GB([AC])|Dreamcast|SEGA\sSaturn|Atari\s(Jaguar)?|3DO)\b/i', $this->releaseName) && preg_match('/EUR|FR|GAME|HOL|\bISO\b|JP|JPN|NL|NTSC|PAL|KS|USA|ROMS?(et)?/i', $this->releaseName)) { - $this->tmpCat = self::GAME_OTHER; + $this->tmpCat = Category::GAME_OTHER; + $this->tmpTag[] = Category::GAME_OTHER; return true; } @@ -1646,7 +1780,8 @@ class Categorize extends Category public function isMusicForeign(): bool { if ($this->categorizeForeign && preg_match('/[ \-\._](brazilian|chinese|croatian|danish|deutsch|dutch|estonian|flemish|finnish|french|german|greek|hebrew|icelandic|italian|ita|latin|mandarin|nordic|norwegian|polish|portuguese|japenese|japanese|russian|serbian|slovenian|spanish|spanisch|swedish|thai|turkish|bl|cz|de|es|fr|ger|heb|hu|hun|it(a| 19|20\d\d)|jap|ko|kor|nl|pl|se)[ \-\._]/i', $this->releaseName)) { - $this->tmpCat = self::MUSIC_FOREIGN; + $this->tmpCat = Category::MUSIC_FOREIGN; + $this->tmpTag[] = Category::MUSIC_FOREIGN; return true; } @@ -1660,7 +1795,8 @@ class Categorize extends Category public function isAudiobook(): bool { if ($this->categorizeForeign && stripos($this->releaseName, 'Audiobook') !== false) { - $this->tmpCat = self::MUSIC_FOREIGN; + $this->tmpCat = Category::MUSIC_FOREIGN; + $this->tmpTag[] = Category::MUSIC_FOREIGN; return true; } @@ -1677,7 +1813,8 @@ class Categorize extends Category if ($this->isMusicForeign()) { return true; } - $this->tmpCat = self::MUSIC_VIDEO; + $this->tmpCat = Category::MUSIC_VIDEO; + $this->tmpTag[] = Category::MUSIC_VIDEO; return true; } @@ -1685,7 +1822,8 @@ class Categorize extends Category if ($this->isMusicForeign()) { return true; } - $this->tmpCat = self::MUSIC_VIDEO; + $this->tmpCat = Category::MUSIC_VIDEO; + $this->tmpTag[] = Category::MUSIC_VIDEO; return true; } @@ -1702,7 +1840,8 @@ class Categorize extends Category if ($this->isMusicForeign()) { return true; } - $this->tmpCat = self::MUSIC_LOSSLESS; + $this->tmpCat = Category::MUSIC_LOSSLESS; + $this->tmpTag[] = Category::MUSIC_LOSSLESS; return true; } @@ -1719,7 +1858,8 @@ class Categorize extends Category if ($this->isMusicForeign()) { return true; } - $this->tmpCat = self::MUSIC_MP3; + $this->tmpCat = Category::MUSIC_MP3; + $this->tmpTag[] = Category::MUSIC_MP3; return true; } @@ -1727,7 +1867,8 @@ class Categorize extends Category if ($this->isMusicForeign()) { return true; } - $this->tmpCat = self::MUSIC_MP3; + $this->tmpCat = Category::MUSIC_MP3; + $this->tmpTag[] = Category::MUSIC_MP3; return true; } @@ -1742,13 +1883,15 @@ class Categorize extends Category { if (preg_match('/(19|20)\d\d\-(C4)$|[-._ ]\d?CD[-._ ](19|20)\d\d|\(\d\-?CD\)|\-\dcd\-|\d[-._ ]Albums|Albums.+(EP)|Bonus.+Tracks|Box.+?CD.+SET|Discography|D\.O\.M|Greatest\sSongs|Live.+(Bootleg|Remastered)|Music.+Vol|([\(\[\s])NMR([\)\]\s])|Promo.+CD|Reggaeton|Tiesto.+Club|Vinyl\s2496|\WV\.A\.|^\(VA\s|^VA[-._ ]/i', $this->releaseName)) { if (true !== $this->isMusicForeign()) { - $this->tmpCat = self::MUSIC_OTHER; + $this->tmpCat = Category::MUSIC_OTHER; + $this->tmpTag[] = Category::MUSIC_OTHER; } return true; } if (preg_match('/\(pure_fm\)|-+\(?(2lp|cd[ms]([-_ .][a-z]{2})?|cover|ep|ltd_ed|mix|original|ost|.*?(edit(ion)?|remix(es)?|vinyl)|web)\)?-+((19|20)\d\d|you$)/i', $this->releaseName)) { - $this->tmpCat = self::MUSIC_OTHER; + $this->tmpCat = Category::MUSIC_OTHER; + $this->tmpTag[] = Category::MUSIC_OTHER; return true; } @@ -1786,7 +1929,8 @@ class Categorize extends Category case $this->categorizeForeign === false: return false; case preg_match('/[ \-\._](brazilian|chinese|croatian|danish|deutsch|dutch|estonian|flemish|finnish|french|german|greek|hebrew|icelandic|italian|ita|latin|mandarin|nordic|norwegian|polish|portuguese|japenese|japanese|russian|serbian|slovenian|spanish|spanisch|swedish|thai|turkish)[-._ ]/i', $this->releaseName): - $this->tmpCat = self::BOOKS_FOREIGN; + $this->tmpCat = Category::BOOKS_FOREIGN; + $this->tmpTag[] = Category::BOOKS_FOREIGN; return true; default: @@ -1805,7 +1949,8 @@ class Categorize extends Category case $this->isBookForeign(): break; default: - $this->tmpCat = self::BOOKS_COMICS; + $this->tmpCat = Category::BOOKS_COMICS; + $this->tmpTag[] = Category::BOOKS_COMICS; break; } @@ -1823,7 +1968,8 @@ class Categorize extends Category case $this->isBookForeign(): break; default: - $this->tmpCat = self::BOOKS_TECHNICAL; + $this->tmpCat = Category::BOOKS_TECHNICAL; + $this->tmpTag[] = Category::BOOKS_TECHNICAL; break; } @@ -1841,7 +1987,8 @@ class Categorize extends Category case $this->isBookForeign(): break; default: - $this->tmpCat = self::BOOKS_MAGAZINES; + $this->tmpCat = Category::BOOKS_MAGAZINES; + $this->tmpTag[] = Category::BOOKS_MAGAZINES; break; } @@ -1854,7 +2001,8 @@ class Categorize extends Category public function isBookOther(): bool { if (preg_match('/"\d\d-\d\d-20\d\d\./i', $this->releaseName)) { - $this->tmpCat = self::BOOKS_UNKNOWN; + $this->tmpCat = Category::BOOKS_UNKNOWN; + $this->tmpTag[] = Category::BOOKS_UNKNOWN; return true; } @@ -1873,7 +2021,8 @@ class Categorize extends Category case $this->isBookForeign(): break; default: - $this->tmpCat = self::BOOKS_EBOOK; + $this->tmpCat = Category::BOOKS_EBOOK; + $this->tmpTag[] = Category::BOOKS_EBOOK; break; } @@ -1891,11 +2040,13 @@ class Categorize extends Category case preg_match('/[^a-z0-9]((480|720|1080)[ip]|s\d{1,3}[-._ ]?[ed]\d{1,3}([ex]\d{1,3}|[-.\w ]))[^a-z0-9]/i', $this->releaseName): return false; case preg_match('/[a-f0-9]{32,64}/i', $this->releaseName): - $this->tmpCat = self::OTHER_HASHED; + $this->tmpCat = Category::OTHER_HASHED; + $this->tmpTag[] = Category::OTHER_HASHED; break; case preg_match('/[a-z0-9]{20,}/i', $this->releaseName): case preg_match('/^[A-Z0-9]{1,}$/i', $this->releaseName): - $this->tmpCat = self::OTHER_MISC; + $this->tmpCat = Category::OTHER_MISC; + $this->tmpTag[] = Category::OTHER_MISC; break; default: return false; @@ -1915,6 +2066,7 @@ class Categorize extends Category { if (preg_match($regex, $fromName)) { $this->tmpCat = $category; + $this->tmpTag[] = [$category]; return true; } diff --git a/Blacklight/NZBImport.php b/Blacklight/NZBImport.php index b5819730f..0f78f8135 100755 --- a/Blacklight/NZBImport.php +++ b/Blacklight/NZBImport.php @@ -396,6 +396,7 @@ class NZBImport if ($dupeCheck === null) { $escapedSearchName = $cleanName; + $determinedCategory = $this->category->determineCategory($nzbDetails['groups_id'], $cleanName, $escapedFromName); // Insert the release into the DB. $relID = Release::insertRelease( [ @@ -407,13 +408,16 @@ class NZBImport 'postdate' => $nzbDetails['postDate'], 'fromname' => $escapedFromName, 'size' => $nzbDetails['totalSize'], - 'categories_id' => $this->category->determineCategory($nzbDetails['groups_id'], $cleanName, $escapedFromName), + 'categories_id' => $determinedCategory['categories_id'], 'isrenamed' => $renamed, 'reqidstatus' => 0, 'predb_id' => 0, 'nzbstatus' => NZB::NZB_ADDED, ] ); + $release = Release::find($relID); + $release->tag($determinedCategory['tags']); + } else { $this->echoOut('This release is already in our DB so skipping: '.$subject); diff --git a/Blacklight/NameFixer.php b/Blacklight/NameFixer.php index 2468d738c..a8a7cf5d9 100755 --- a/Blacklight/NameFixer.php +++ b/Blacklight/NameFixer.php @@ -871,7 +871,7 @@ class NameFixer if ($this->echooutput === true && $show === true) { $groupName = Group::getNameByID($release->groups_id); $oldCatName = Category::getNameByID($release->categories_id); - $newCatName = Category::getNameByID($determinedCategory); + $newCatName = Category::getNameByID($determinedCategory['categories_id']); if ($type === 'PAR2, ') { echo PHP_EOL; @@ -953,7 +953,7 @@ class NameFixer 'anidbid' => null, 'predb_id' => $preId, 'searchname' => $newTitle, - 'categories_id' => $determinedCategory, + 'categories_id' => $determinedCategory['categories_id'], ]; if ($status !== '') { @@ -963,6 +963,7 @@ class NameFixer } $release->update($updateColumns); + $release->tag($determinedCategory['tags']); $this->sphinx->updateRelease($release->releases_id); } else { $newTitle = substr($newName, 0, 299); @@ -978,10 +979,11 @@ class NameFixer 'anidbid' => null, 'predb_id' => $preId, 'searchname' => $newTitle, - 'categories_id' => $determinedCategory, + 'categories_id' => $determinedCategory['categories_id'], 'iscategorized' => 1, ] ); + $release->tag($determinedCategory['tags']); $this->sphinx->updateRelease($release->releases_id); } } diff --git a/Blacklight/processing/ProcessReleases.php b/Blacklight/processing/ProcessReleases.php index 9d7cf052d..156f2eec4 100755 --- a/Blacklight/processing/ProcessReleases.php +++ b/Blacklight/processing/ProcessReleases.php @@ -266,7 +266,8 @@ class ProcessReleases $total = \count($releases); foreach ($releases as $release) { $catId = $cat->determineCategory($release->groups_id, $release->{$type}, $release->fromname); - Release::query()->where('id', $release->id)->update(['categories_id' => $catId, 'iscategorized' => 1]); + Release::query()->where('id', $release->id)->update(['categories_id' => $catId['categories_id'], 'iscategorized' => 1]); + $release->retag($catId['tags']); $categorized++; if ($this->echoCLI) { $this->consoleTools->overWritePrimary( @@ -596,6 +597,8 @@ class ProcessReleases } } + $determinedCategory = $categorize->determineCategory($collection->groups_id, $cleanedName); + $releaseID = Release::insertRelease( [ 'name' => $cleanRelName, @@ -606,12 +609,14 @@ class ProcessReleases 'postdate' => $collection->date, 'fromname' => $fromName, 'size' => $collection->filesize, - 'categories_id' => $categorize->determineCategory($collection->groups_id, $cleanedName), + 'categories_id' => $determinedCategory['categories_id'], 'isrenamed' => $properName === true ? 1 : 0, 'predb_id' => $preID === false ? 0 : $preID, 'nzbstatus' => NZB::NZB_NONE, ] ); + $release = Release::find($releaseID); + $release->retag($determinedCategory['tags']); if ($releaseID !== null) { // Update collections table to say we inserted the release. diff --git a/Blacklight/processing/post/ProcessAdditional.php b/Blacklight/processing/post/ProcessAdditional.php index 9a37b735a..9ddf5514e 100755 --- a/Blacklight/processing/post/ProcessAdditional.php +++ b/Blacklight/processing/post/ProcessAdditional.php @@ -1750,10 +1750,12 @@ class ProcessAdditional SET searchname = %s, categories_id = %d, iscategorized = 1, isrenamed = 1, proc_pp = 1 WHERE id = %d', $newTitle, - $newCat, + $newCat['categories_id'], $this->_release->id ) ); + $release = Release::find($this->_release->id); + $release->retag($newCat['tags']); $this->sphinx->updateRelease($this->_release->id); // Echo the changed name. diff --git a/Changelog b/Changelog index a2f9db825..5b075580e 100755 --- a/Changelog +++ b/Changelog @@ -1,3 +1,5 @@ +2018-11-01 DariusIII + * Chg: Add first wave of Release tagging capabilities 2018-10-31 DariusIII * Chg: Update NameFixer updateRelease function to use already provided release to update and skip doing unnecessary queries * Chg: Update symfony components to their latest versions diff --git a/app/Models/Category.php b/app/Models/Category.php index 124018049..ac735cd92 100644 --- a/app/Models/Category.php +++ b/app/Models/Category.php @@ -160,12 +160,10 @@ class Category extends Model ]; /** - * Temporary category while we sort through the name. - * @var int + * @var string */ - protected $tmpCat = self::OTHER_MISC; - protected $table = 'categories'; + /** * @var bool */ diff --git a/app/Models/Release.php b/app/Models/Release.php index c727004c2..837a29c81 100644 --- a/app/Models/Release.php +++ b/app/Models/Release.php @@ -4,6 +4,7 @@ namespace App\Models; use Blacklight\NZB; use Blacklight\SphinxSearch; +use Conner\Tagging\Taggable; use Illuminate\Support\Facades\DB; use Watson\Rememberable\Rememberable; use Illuminate\Database\Eloquent\Model; @@ -128,7 +129,7 @@ use Illuminate\Database\Eloquent\Model; */ class Release extends Model { - use Rememberable; + use Rememberable, Taggable; /** * @var bool diff --git a/build/nntmux.xml b/build/nntmux.xml index 4a21633b3..815566417 100755 --- a/build/nntmux.xml +++ b/build/nntmux.xml @@ -16,8 +16,8 @@ - 357 - 357 + 358 + 358 diff --git a/composer.json b/composer.json index 1b2f2d74f..af9ad88aa 100755 --- a/composer.json +++ b/composer.json @@ -157,6 +157,7 @@ "predis/predis": "^1.1", "propaganistas/laravel-disposable-email": "^2.0", "ramsey/uuid": "^3.7", + "rtconner/laravel-tagging": "^3.0", "smarty/smarty": "^3.1", "spatie/laravel-fractal": "^5.3", "spatie/laravel-permission": "^2.12", diff --git a/composer.lock b/composer.lock index 92744f7ce..e2e7d03fd 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "b3a47d0324cda1a0b9b10734d9f34c27", + "content-hash": "8799a7c6a870c9a9e1361e31def1aa02", "packages": [ { "name": "aharen/omdbapi", @@ -321,7 +321,8 @@ "Gemfile.lock", "*.md" ] - } + }, + "time": "2016-06-06T17:37:52+00:00" }, { "name": "bower-asset/autosize", @@ -350,7 +351,8 @@ "form", "textarea", "ui" - ] + ], + "time": "2017-05-19T15:36:30+00:00" }, { "name": "bower-asset/bootstrap", @@ -399,7 +401,8 @@ "mobile-first", "responsive", "web" - ] + ], + "time": "2016-07-25T15:51:55+00:00" }, { "name": "bower-asset/bootstrap-datepicker", @@ -428,7 +431,8 @@ }, "license": [ "Apache-2.0" - ] + ], + "time": "2016-08-05T09:50:13+00:00" }, { "name": "bower-asset/bootstrap-hover-dropdown", @@ -458,7 +462,8 @@ "dropdowns", "hover", "twitter" - ] + ], + "time": "2015-12-01T23:35:57+00:00" }, { "name": "bower-asset/bootstrap-progressbar", @@ -492,7 +497,8 @@ }, "license": [ "MIT" - ] + ], + "time": "2015-05-15T18:56:17+00:00" }, { "name": "bower-asset/colorbox", @@ -533,7 +539,8 @@ "modal", "popup", "ui" - ] + ], + "time": "2016-05-10T22:21:33+00:00" }, { "name": "bower-asset/datatables", @@ -648,7 +655,8 @@ "tests", "examples" ] - } + }, + "time": "2015-01-26T21:19:01+00:00" }, { "name": "bower-asset/flexboxgrid", @@ -684,7 +692,8 @@ "css", "flexbox", "grid" - ] + ], + "time": "2016-08-14T16:43:18+00:00" }, { "name": "bower-asset/font-awesome", @@ -750,7 +759,8 @@ "replacement", "skins", "ui" - ] + ], + "time": "2014-03-03T17:36:28+00:00" }, { "name": "bower-asset/jquery", @@ -817,7 +827,8 @@ "scroll", "scrolltop", "scrolltotop" - ] + ], + "time": "2017-08-31T15:51:29+00:00" }, { "name": "bower-asset/jquery-migrate", @@ -867,7 +878,8 @@ "demo", "package.json" ] - } + }, + "time": "2016-03-01T20:38:24+00:00" }, { "name": "bower-asset/multifile", @@ -983,7 +995,8 @@ "progress", "progress", "spinner" - ] + ], + "time": "2014-11-06T16:31:34+00:00" }, { "name": "bower-asset/pnotify", @@ -1035,7 +1048,8 @@ "license": [ "Apache-2.0" ], - "description": "JavaScript notification plugin." + "description": "JavaScript notification plugin.", + "time": "2017-07-31T21:50:29+00:00" }, { "name": "bower-asset/slimscroll", @@ -1076,7 +1090,8 @@ "scrolling", "slimscroll", "ui" - ] + ], + "time": "2016-06-11T09:19:14+00:00" }, { "name": "bower-asset/tinymce-dist", @@ -5438,6 +5453,68 @@ ], "time": "2018-07-19T23:38:55+00:00" }, + { + "name": "rtconner/laravel-tagging", + "version": "3.0.0", + "source": { + "type": "git", + "url": "https://github.com/rtconner/laravel-tagging.git", + "reference": "6f58920a2146d520de34d858ad93fe9af2012256" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/rtconner/laravel-tagging/zipball/6f58920a2146d520de34d858ad93fe9af2012256", + "reference": "6f58920a2146d520de34d858ad93fe9af2012256", + "shasum": "" + }, + "require": { + "illuminate/database": ">= 5.0", + "illuminate/support": ">= 5.0", + "php": ">=5.5.0" + }, + "require-dev": { + "mockery/mockery": "~0.9", + "orchestra/testbench": "~3.0", + "phpunit/phpunit": "~4.0", + "vlucas/phpdotenv": "~2.0" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "Conner\\Tagging\\Providers\\TaggingServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "Conner\\Tagging\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Robert Conner", + "email": "rtconner@smarter.bz" + } + ], + "description": "Use PHP traits to extend Laravel Eloquent Models to allow Tags. Models can be marked as Taggable.", + "homepage": "https://smartersoftware.net/packages/laravel-tagging-taggable", + "keywords": [ + "Taggable", + "eloquent", + "laravel", + "laravel5", + "tag", + "tagged", + "tagging", + "tags" + ], + "time": "2018-08-13T16:25:54+00:00" + }, { "name": "rtheunissen/guzzle-log-middleware", "version": "v0.4.1", diff --git a/config/tagging.php b/config/tagging.php new file mode 100644 index 000000000..bd0699923 --- /dev/null +++ b/config/tagging.php @@ -0,0 +1,31 @@ + 'integer', // 'string' or 'integer' + + // Value of are passed through this before save of tags + 'normalizer' => '\Conner\Tagging\Util::slug', + + // Display value of tags are passed through (for front end display) + 'displayer' => '\Illuminate\Support\Str::title', + + // Database connection for Conner\Taggable\Tag model to use +// 'connection' => 'mysql', + + // When deleting a model, remove all the tags first + 'untag_on_delete' => true, + + // Auto-delete unused tags from the 'tags' database table (when they are used zero times) + 'delete_unused_tags'=>true, + + // Model to use to store the tags in the database + 'tag_model'=>'\Conner\Tagging\Model\Tag', + + // Delimiter used within tags + 'delimiter' => '-', + + // Model to use for the relation between tags and tagged records + 'tagged_model' => '\Conner\Tagging\Model\Tagged', +]; diff --git a/database/migrations/2014_01_07_073615_create_tagged_table.php b/database/migrations/2014_01_07_073615_create_tagged_table.php new file mode 100644 index 000000000..ce36b565a --- /dev/null +++ b/database/migrations/2014_01_07_073615_create_tagged_table.php @@ -0,0 +1,25 @@ +increments('id'); + if(config('tagging.primary_keys_type') == 'string') { + $table->string('taggable_id', 36)->index(); + } else { + $table->integer('taggable_id')->unsigned()->index(); + } + $table->string('taggable_type', 125)->index(); + $table->string('tag_name', 125); + $table->string('tag_slug', 125)->index(); + }); + } + + public function down() { + Schema::drop('tagging_tagged'); + } +} diff --git a/database/migrations/2014_01_07_073615_create_tags_table.php b/database/migrations/2014_01_07_073615_create_tags_table.php new file mode 100644 index 000000000..986b42d64 --- /dev/null +++ b/database/migrations/2014_01_07_073615_create_tags_table.php @@ -0,0 +1,23 @@ +increments('id'); + $table->string('slug', 125)->index(); + $table->string('name', 125); + $table->boolean('suggest')->default(false); + $table->integer('count')->unsigned()->default(0); // count of how many times this tag was used + }); + } + + public function down() + { + Schema::drop('tagging_tags'); + } +} diff --git a/database/migrations/2016_06_29_073615_create_tag_groups_table.php b/database/migrations/2016_06_29_073615_create_tag_groups_table.php new file mode 100644 index 000000000..558e85f3e --- /dev/null +++ b/database/migrations/2016_06_29_073615_create_tag_groups_table.php @@ -0,0 +1,21 @@ +increments('id'); + $table->string('slug', 125)->index(); + $table->string('name', 125); + }); + } + + public function down() + { + Schema::drop('tagging_tag_groups'); + } +} diff --git a/database/migrations/2016_06_29_073615_update_tags_table.php b/database/migrations/2016_06_29_073615_update_tags_table.php new file mode 100644 index 000000000..10f5b71a2 --- /dev/null +++ b/database/migrations/2016_06_29_073615_update_tags_table.php @@ -0,0 +1,26 @@ +integer('tag_group_id')->unsigned()->nullable()->after('id'); + $table->foreign('tag_group_id')->references('id')->on('tagging_tag_groups'); + }); + + } + + + public function down() + { + Schema::table('tagging_tags', function ($table) { + $table->dropForeign('tagging_tags_tag_group_id_foreign'); + $table->dropColumn('tag_group_id'); + }); + } +} diff --git a/misc/testing/Releases/recategorize.php b/misc/testing/Releases/recategorize.php index 5ecee2409..4e4d4e707 100644 --- a/misc/testing/Releases/recategorize.php +++ b/misc/testing/Releases/recategorize.php @@ -3,6 +3,7 @@ require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap/autoload.php'; use App\Models\Category; +use App\Models\Release; use Blacklight\ColorCLI; use Blacklight\Categorize; use Blacklight\ConsoleTools; @@ -97,10 +98,12 @@ function categorizeRelease($where, $update = true, $echooutput = false) xxxinfo_id = 0, categories_id = %d WHERE id = %d', - $catId, + $catId['categories_id'], $rowrel->id ) ); + $release = Release::find($rowrel->id); + $release->retag($catId['tags']); } $chgcount++; } diff --git a/resources/db/patches/0358~tags.sql b/resources/db/patches/0358~tags.sql new file mode 100644 index 000000000..f3aaec039 --- /dev/null +++ b/resources/db/patches/0358~tags.sql @@ -0,0 +1,58 @@ +# Add tables related to tagging releases + +SET FOREIGN_KEY_CHECKS = 0; + +DROP TABLE IF EXISTS tagging_tag_groups; +create table tagging_tag_groups +( + id int unsigned auto_increment primary key, + slug varchar(125) not null, + name varchar(125) not null +) +ENGINE=InnoDB +DEFAULT CHARSET=utf8 +COLLATE=utf8_unicode_ci +ROW_FORMAT=DYNAMIC; + +create index tagging_tag_groups_slug_index on tagging_tag_groups (slug); + +DROP TABLE IF EXISTS tagging_tagged; +create table tagging_tagged +( + id int unsigned auto_increment primary key, + taggable_id int unsigned not null, + taggable_type varchar(125) not null, + tag_name varchar(125) not null, + tag_slug varchar(125) not null +) +ENGINE=InnoDB +DEFAULT CHARSET=utf8 +COLLATE=utf8_unicode_ci +ROW_FORMAT=DYNAMIC; + +create index tagging_tagged_tag_slug_index on tagging_tagged (tag_slug); + +create index tagging_tagged_taggable_id_index on tagging_tagged (taggable_id); + +create index tagging_tagged_taggable_type_index on tagging_tagged (taggable_type); + +DROP TABLE IF EXISTS tagging_tags; +create table tagging_tags +( + id int unsigned auto_increment + primary key, + tag_group_id int unsigned null, + slug varchar(125) not null, + name varchar(125) not null, + suggest tinyint(1) default 0 not null, + count int unsigned default 0 not null, + constraint tagging_tags_tag_group_id_foreign foreign key (tag_group_id) references tagging_tag_groups (id) +) +ENGINE=InnoDB +DEFAULT CHARSET=utf8 +COLLATE=utf8_unicode_ci +ROW_FORMAT=DYNAMIC; + +create index tagging_tags_slug_index on tagging_tags (slug); + +SET FOREIGN_KEY_CHECKS = 1;