|
1
|
|
|
<?php |
|
2
|
|
|
namespace App\Services\Categorization\Categorizers; |
|
3
|
|
|
use App\Models\Category; |
|
4
|
|
|
use App\Services\Categorization\CategorizationResult; |
|
5
|
|
|
use App\Services\Categorization\ReleaseContext; |
|
6
|
|
|
class GroupNameCategorizer extends AbstractCategorizer |
|
7
|
|
|
{ |
|
8
|
|
|
protected int $priority = 5; |
|
9
|
|
|
public function getName(): string { return 'GroupName'; } |
|
10
|
|
|
public function categorize(ReleaseContext $context): CategorizationResult |
|
11
|
|
|
{ |
|
12
|
|
|
$groupName = $context->groupName; |
|
13
|
|
|
if (empty($groupName)) return $this->noMatch(); |
|
14
|
|
|
if (preg_match('/alt\.binaries\..*?(tv|hdtv|tvseries)/i', $groupName)) return $this->matched(Category::TV_OTHER, 0.6, 'group_tv'); |
|
15
|
|
|
if (preg_match('/alt\.binaries\..*?(movies?|dvd|bluray|x264)/i', $groupName)) return $this->matched(Category::MOVIE_OTHER, 0.6, 'group_movie'); |
|
16
|
|
|
if (preg_match('/alt\.binaries\..*?(erotica|pictures\.erotica|xxx)/i', $groupName)) return $this->matched(Category::XXX_OTHER, 0.7, 'group_xxx'); |
|
17
|
|
|
if (preg_match('/alt\.binaries\..*?(sounds?|mp3|music|lossless)/i', $groupName)) return $this->matched(Category::MUSIC_OTHER, 0.6, 'group_music'); |
|
18
|
|
|
if (preg_match('/alt\.binaries\..*?(games?|console|psx|nintendo)/i', $groupName)) return $this->matched(Category::GAME_OTHER, 0.6, 'group_game'); |
|
19
|
|
|
if (preg_match('/alt\.binaries\..*?(warez|0day|apps?|software)/i', $groupName)) return $this->matched(Category::PC_0DAY, 0.6, 'group_pc'); |
|
20
|
|
|
if (preg_match('/alt\.binaries\..*?(e-?book|ebook|comics?)/i', $groupName)) return $this->matched(Category::BOOKS_EBOOK, 0.6, 'group_book'); |
|
21
|
|
|
return $this->noMatch(); |
|
22
|
|
|
} |
|
23
|
|
|
} |
|
24
|
|
|
|