Total Complexity | 477 |
Total Lines | 1881 |
Duplicated Lines | 0 % |
Changes | 0 |
Complex classes like Categorize often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Categorize, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
14 | class Categorize extends Category |
||
15 | { |
||
16 | /** |
||
17 | * @var bool |
||
18 | */ |
||
19 | protected $categorizeForeign; |
||
20 | |||
21 | /** |
||
22 | * @var bool |
||
23 | */ |
||
24 | protected $catWebDL; |
||
25 | |||
26 | /** |
||
27 | * Release name to sort through. |
||
28 | * @var string |
||
29 | */ |
||
30 | public $releaseName; |
||
31 | |||
32 | /** |
||
33 | * Release poster to sort through. |
||
34 | * @var string |
||
35 | */ |
||
36 | public $poster; |
||
37 | |||
38 | /** |
||
39 | * Group id of the releasename we are sorting through. |
||
40 | * @var int|string |
||
41 | */ |
||
42 | public $groupid; |
||
43 | |||
44 | /** |
||
45 | * @var \Blacklight\Regexes |
||
46 | */ |
||
47 | public $regexes; |
||
48 | |||
49 | /** |
||
50 | * Construct. |
||
51 | * |
||
52 | * @param array $options Class instances. |
||
53 | * |
||
54 | * @throws \Exception |
||
55 | */ |
||
56 | public function __construct(array $options = []) |
||
57 | { |
||
58 | parent::__construct($options); |
||
59 | $this->categorizeForeign = (int) Settings::settingValue('indexer.categorise.categorizeforeign'); |
||
60 | $this->catWebDL = (int) Settings::settingValue('indexer.categorise.catwebdl'); |
||
61 | $this->regexes = new Regexes(['Table_Name' => 'category_regexes']); |
||
62 | } |
||
63 | |||
64 | /** |
||
65 | * Look up the site to see which language of categorizing to use. |
||
66 | * Then work out which category is applicable for either a group or a binary. |
||
67 | * Returns Category::OTHER_MISC if no category is appropriate. |
||
68 | * |
||
69 | * @param string $releaseName The name to parse. |
||
70 | * @param string $poster Name of the release poster to parse |
||
71 | * @param int|string $groupID The groups_id. |
||
72 | * |
||
73 | * @return int The categories_id. |
||
74 | * @throws \Exception |
||
75 | */ |
||
76 | public function determineCategory($groupID, $releaseName = '', $poster = ''): int |
||
77 | { |
||
78 | $this->releaseName = $releaseName; |
||
79 | $this->groupid = $groupID; |
||
80 | $this->poster = $poster; |
||
81 | |||
82 | switch (true) { |
||
83 | case $this->isMisc(): |
||
84 | // Note that in byGroup() some overrides occur... |
||
85 | case $this->databaseRegex(): |
||
86 | case $this->byGroup(): // Note that in byGroup() some overrides occur... |
||
87 | //Try against all functions, if still nothing, return Cat Misc. |
||
88 | case $this->isPC(): |
||
89 | case $this->isXxx(): |
||
90 | case $this->isTV(): |
||
91 | case $this->isMovie(): |
||
92 | case $this->isConsole(): |
||
93 | case $this->isBook(): |
||
94 | case $this->isMusic(): |
||
95 | return $this->tmpCat; |
||
96 | } |
||
97 | |||
98 | return $this->tmpCat; |
||
99 | } |
||
100 | |||
101 | /** |
||
102 | * Cache of group names for group id's. |
||
103 | * @var array |
||
104 | */ |
||
105 | private $groups = []; |
||
106 | |||
107 | /** |
||
108 | * Sets/Gets a group name for the current group id in the buffer. |
||
109 | * |
||
110 | * @return string Group Name. |
||
111 | */ |
||
112 | private function groupName(): string |
||
113 | { |
||
114 | if (! isset($this->groups[$this->groupid])) { |
||
115 | $group = Group::query()->where('id', $this->groupid)->first(['name']); |
||
116 | $this->groups[$this->groupid] = ($group === null ? false : $group['name']); |
||
117 | } |
||
118 | |||
119 | return $this->groups[$this->groupid]; |
||
120 | } |
||
121 | |||
122 | /** |
||
123 | * Determine category by group name. |
||
124 | * |
||
125 | * @return bool |
||
126 | */ |
||
127 | public function byGroup(): bool |
||
128 | { |
||
129 | $group = $this->groupName(); |
||
130 | if ($group !== false) { |
||
131 | switch (true) { |
||
132 | case $group === 'alt.binaries.0day.stuffz': |
||
133 | switch (true) { |
||
134 | case $this->isBook(): |
||
135 | case $this->isConsole(): |
||
136 | case $this->isPC(): |
||
137 | break; |
||
138 | default: |
||
139 | $this->tmpCat = Category::PC_0DAY; |
||
140 | break; |
||
141 | } |
||
142 | break; |
||
143 | case $group === 'alt.binaries.audio.warez': |
||
144 | $this->tmpCat = Category::PC_0DAY; |
||
145 | break; |
||
146 | case preg_match('/alt\.binaries\.(multimedia\.erotica\.|cartoons\.french\.|dvd\.|multimedia\.)?anime(\.highspeed|\.repost|s-fansub|\.german)?/', $group): |
||
147 | $this->tmpCat = Category::TV_ANIME; |
||
148 | break; |
||
149 | case $group === 'alt.binaries.b4e.erotica': |
||
150 | switch (true) { |
||
151 | case $this->isTV(): |
||
152 | case $this->isMovie(): |
||
153 | case $this->isXxx(): |
||
154 | break; |
||
155 | default: |
||
156 | $this->tmpCat = Category::XXX_OTHER; |
||
157 | break; |
||
158 | } |
||
159 | break; |
||
160 | case $group === 'alt.binaries.british.drama': |
||
161 | switch (true) { |
||
162 | case $this->isUHDTV(): |
||
163 | case $this->isHDTV(): |
||
164 | case $this->isSDTV(): |
||
165 | case $this->isPC(): |
||
166 | case $this->isSportTV(): |
||
167 | break; |
||
168 | default: |
||
169 | return false; |
||
170 | } |
||
171 | break; |
||
172 | case $group === 'alt.binaries.cd.image': |
||
173 | switch (true) { |
||
174 | case $this->isISO(): |
||
175 | case $this->isPCGame(): |
||
176 | case $this->is0day(): |
||
177 | case $this->isConsole(): |
||
178 | break; |
||
179 | default: |
||
180 | $this->tmpCat = Category::PC_ISO; |
||
181 | break; |
||
182 | } |
||
183 | break; |
||
184 | case $group === 'alt.binaries.b4e': |
||
185 | switch (true) { |
||
186 | case $this->isUHDTV(): |
||
187 | case $this->isHDTV(): |
||
188 | case $this->isSDTV(): |
||
189 | case $this->isPC(): |
||
190 | case $this->isMovie(): |
||
191 | case $this->isXxx(): |
||
192 | break; |
||
193 | default: |
||
194 | return false; |
||
195 | } |
||
196 | break; |
||
197 | case $this->categorizeForeign && $group === 'alt.binaries.cartoons.french': |
||
198 | $this->tmpCat = Category::TV_FOREIGN; |
||
199 | break; |
||
200 | case $group === 'alt.binaries.cd.image.linux': |
||
201 | $this->tmpCat = Category::PC_0DAY; |
||
202 | break; |
||
203 | case $group === 'alt.binaries.cd.lossless': |
||
204 | if ($this->categorizeForeign && $this->isMusicForeign()) { |
||
205 | break; |
||
206 | } |
||
207 | $this->tmpCat = Category::MUSIC_LOSSLESS; |
||
208 | break; |
||
209 | case $group === 'alt.binaries.classic.tv.shows': |
||
210 | $this->tmpCat = Category::TV_SD; |
||
211 | break; |
||
212 | case preg_match('/alt\.binaries\.(comics\.dcp|pictures\.comics\.(complete|dcp|reposts?))/', $group): |
||
213 | if ($this->categorizeForeign && $this->isBookForeign()) { |
||
214 | break; |
||
215 | } |
||
216 | $this->tmpCat = Category::BOOKS_COMICS; |
||
217 | break; |
||
218 | case $group === 'alt.binaries.console.ps3': |
||
219 | if ($this->isGamePS4()) { |
||
220 | break; |
||
221 | } |
||
222 | $this->tmpCat = Category::GAME_PS3; |
||
223 | break; |
||
224 | case $group === 'alt.binaries.cores': |
||
225 | if ($this->isXxx()) { |
||
226 | break; |
||
227 | } |
||
228 | |||
229 | return false; |
||
230 | case preg_match('/alt\.binaries(\.(19\d0s|country|sounds?(\.country|\.19\d0s)?))?\.mp3(\.[a-z]+)?/i', $group): |
||
231 | switch (true) { |
||
232 | case $this->isMusic(): |
||
233 | case $this->isXxx(): |
||
234 | break; |
||
235 | default: |
||
236 | $this->tmpCat = Category::MUSIC_MP3; |
||
237 | break; |
||
238 | } |
||
239 | break; |
||
240 | case $group === 'alt.binaries.triballs': |
||
241 | switch (true) { |
||
242 | case $this->isMusic(): |
||
243 | case $this->isPC(): |
||
244 | case $this->isMovie(): |
||
245 | break; |
||
246 | default: |
||
247 | $this->tmpCat = Category::OTHER_MISC; |
||
248 | break; |
||
249 | } |
||
250 | break; |
||
251 | case preg_match('/alt\.binaries\.dvd(\-?r)?(\.(movies|))?$/i', $group): |
||
252 | if ($this->isMovie()) { |
||
253 | break; |
||
254 | } |
||
255 | $this->tmpCat = Category::OTHER_MISC; |
||
256 | break; |
||
257 | case preg_match('/alt\.binaries\.(dvdnordic\.org|nordic\.(dvdr?|xvid))|dk\.(binaer|binaries)\.film(\.divx)?/', $group): |
||
258 | if ($this->categorizeForeign && $this->isMovieForeign()) { |
||
259 | break; |
||
260 | } |
||
261 | if ($this->isMovie()) { |
||
262 | break; |
||
263 | } |
||
264 | $this->tmpCat = Category::MOVIE_FOREIGN; |
||
265 | break; |
||
266 | case $group === 'alt.binaries.documentaries': |
||
267 | $this->tmpCat = Category::TV_DOCU; |
||
268 | break; |
||
269 | case $group === 'alt.binaries.dreamcast': |
||
270 | $this->tmpCat = Category::GAME_OTHER; |
||
271 | break; |
||
272 | case preg_match('/alt\.binaries\.e\-?books?((\.|\-)(technical|textbooks))/', $group): |
||
273 | if ($this->categorizeForeign && $this->isBookForeign()) { |
||
274 | break; |
||
275 | } |
||
276 | $this->tmpCat = Category::BOOKS_TECHNICAL; |
||
277 | break; |
||
278 | case $group === 'alt.binaries.e-book.magazines': |
||
279 | if ($this->categorizeForeign && $this->isBookForeign()) { |
||
280 | break; |
||
281 | } |
||
282 | $this->tmpCat = Category::BOOKS_MAGAZINES; |
||
283 | break; |
||
284 | case $group === 'alt.binaries.e-book.rpg': |
||
285 | switch (true) { |
||
286 | case $this->is0day(): |
||
287 | case $this->isPCGame(): |
||
288 | case $this->isConsole(): |
||
289 | case $this->isBook(): |
||
290 | break; |
||
291 | default: |
||
292 | $this->tmpCat = Category::BOOKS_UNKNOWN; |
||
293 | break; |
||
294 | } |
||
295 | break; |
||
296 | case preg_match('/alt\.binaries\.e\-?book(\.[a-z]+)?/', $group): |
||
297 | switch (true) { |
||
298 | case $this->is0day(): |
||
299 | case $this->isPCGame(): |
||
300 | case $this->isConsole(): |
||
301 | case $this->isBook(): |
||
302 | case $this->categorizeForeign && $this->isBookForeign(): |
||
303 | break; |
||
304 | case preg_match('/[a-z0-9 \',]+ - \[? ?[a-z0-9 \']+ ?\]? - [a-z0-9 \']+/i', $this->releaseName): |
||
305 | $this->tmpCat = Category::BOOKS_EBOOK; |
||
306 | break; |
||
307 | default: |
||
308 | $this->tmpCat = Category::BOOKS_UNKNOWN; |
||
309 | break; |
||
310 | } |
||
311 | break; |
||
312 | case preg_match('/alt\.binaries\..*(erotica|ijsklontje|xxx)/', $group): |
||
313 | if ($this->isXxx()) { |
||
314 | break; |
||
315 | } |
||
316 | $this->tmpCat = Category::XXX_OTHER; |
||
317 | break; |
||
318 | case $group === 'alt.binaries.cd.image.sega-saturn': |
||
319 | case $group === 'alt.binaries.gamecube': |
||
320 | $this->tmpCat = Category::GAME_OTHER; |
||
321 | break; |
||
322 | case preg_match('/alt.binaries.games/', $group): |
||
323 | switch (true) { |
||
324 | case $this->isPCGame(): |
||
325 | case $this->is0day(): |
||
326 | case $this->isConsole(): |
||
327 | break; |
||
328 | default: |
||
329 | $this->tmpCat = Category::PC_GAMES; |
||
330 | break; |
||
331 | } |
||
332 | break; |
||
333 | case preg_match('/alt.binaries.games.(dox|adventures)/', $group): |
||
334 | switch (true) { |
||
335 | case $this->isPCGame(): |
||
336 | case $this->is0day(): |
||
337 | case $this->isConsole(): |
||
338 | break; |
||
339 | default: |
||
340 | $this->tmpCat = Category::PC_GAMES; |
||
341 | break; |
||
342 | } |
||
343 | break; |
||
344 | case preg_match('/alt.binaries.cd.images?.games/', $group): |
||
345 | switch (true) { |
||
346 | case $this->is0day(): |
||
347 | case $this->isConsole(): |
||
348 | case $this->isBook(): |
||
349 | break; |
||
350 | default: |
||
351 | $this->tmpCat = Category::PC_GAMES; |
||
352 | break; |
||
353 | } |
||
354 | break; |
||
355 | case $group === 'alt.binaries.pcgame': |
||
356 | switch (true) { |
||
357 | case $this->is0day(): |
||
358 | case $this->isConsole(): |
||
359 | case $this->isTV(): |
||
360 | break; |
||
361 | default: |
||
362 | $this->tmpCat = Category::PC_GAMES; |
||
363 | break; |
||
364 | } |
||
365 | break; |
||
366 | case $group === 'alt.binaries.games.nintendo3ds': |
||
367 | if ($this->isGameNDS()) { |
||
368 | break; |
||
369 | } |
||
370 | $this->tmpCat = Category::GAME_3DS; |
||
371 | break; |
||
372 | case preg_match('/alt\.binaries\.(games|emulators)?\.?nintendo[\.-]?ds/', $group): |
||
373 | if ($this->isGame3DS()) { |
||
374 | break; |
||
375 | } |
||
376 | $this->tmpCat = Category::GAME_NDS; |
||
377 | break; |
||
378 | case $group === 'alt.binaries.games.wii': |
||
379 | switch (true) { |
||
380 | case $this->isGameWiiWare(): |
||
381 | case $this->isGameWiiU(): |
||
382 | break; |
||
383 | default: |
||
384 | $this->tmpCat = Category::GAME_WII; |
||
385 | break; |
||
386 | } |
||
387 | break; |
||
388 | case $group === 'alt.binaries.games.xbox': |
||
389 | switch (true) { |
||
390 | case $this->isGameXBOX360DLC(): |
||
391 | case $this->isGameXBOX360(): |
||
392 | case $this->isGameXBOXONE(): |
||
393 | break; |
||
394 | default: |
||
395 | $this->tmpCat = Category::GAME_XBOX; |
||
396 | break; |
||
397 | } |
||
398 | break; |
||
399 | case $group === 'alt.binaries.games.xbox360': |
||
400 | switch (true) { |
||
401 | case $this->isGameXBOX360DLC(): |
||
402 | case $this->isGameXBOXONE(): |
||
403 | break; |
||
404 | default: |
||
405 | $this->tmpCat = Category::GAME_XBOX360; |
||
406 | break; |
||
407 | } |
||
408 | break; |
||
409 | case $group === 'alt.binaries.hdtv': |
||
410 | switch (true) { |
||
411 | case $this->isTV(): |
||
412 | case $this->isMovie(): |
||
413 | break; |
||
414 | default: |
||
415 | return false; |
||
416 | } |
||
417 | break; |
||
418 | case $group === 'alt.binaries.inner-sanctum': |
||
419 | switch (true) { |
||
420 | case $this->isMusic(): |
||
421 | break; |
||
422 | case preg_match('/-+(19|20)\d\d-\(?(album.*?|back|cover|front)\)?-+/i', $this->releaseName): |
||
423 | case preg_match('/(19|20)\d\d$/', $this->releaseName) && ctype_lower(preg_replace('/[^a-z]/i', '', $this->releaseName)): |
||
424 | $this->tmpCat = Category::MUSIC_OTHER; |
||
425 | break; |
||
426 | default: |
||
427 | return false; |
||
428 | } |
||
429 | break; |
||
430 | case preg_match('/alt\.binaries\.ipod\.videos\.tvshows/', $group): |
||
431 | $this->tmpCat = Category::TV_OTHER; |
||
432 | break; |
||
433 | case $group === 'alt.binaries.mac': |
||
434 | $this->tmpCat = Category::PC_MAC; |
||
435 | break; |
||
436 | case $group === 'alt.binaries.mma': |
||
437 | if ($this->is0day()) { |
||
438 | break; |
||
439 | } |
||
440 | $this->tmpCat = Category::TV_SPORT; |
||
441 | break; |
||
442 | case $group === 'alt.binaries.moovee': |
||
443 | switch (true) { |
||
444 | case $this->isTV(): // Check if it's TV first as some tv posted in moovee |
||
445 | break; |
||
446 | case $this->isMovieSD(): // Need to check this BEFORE the HD check |
||
447 | break; |
||
448 | case $this->isMovieUHD(): // Check the movie isn't an UHD release before blindly assigning SD |
||
449 | break; |
||
450 | case $this->isMovieHD(): // Check the movie isn't an HD release before blindly assigning SD |
||
451 | break; |
||
452 | default: |
||
453 | $this->tmpCat = Category::MOVIE_SD; |
||
454 | break; |
||
455 | } |
||
456 | break; |
||
457 | case $group === 'alt.binaries.mpeg.video.music': |
||
458 | if ($this->categorizeForeign && $this->isMusicForeign()) { |
||
459 | break; |
||
460 | } |
||
461 | $this->tmpCat = Category::MUSIC_VIDEO; |
||
462 | break; |
||
463 | case $group === 'alt.binaries.multimedia.documentaries': |
||
464 | $this->tmpCat = Category::TV_DOCU; |
||
465 | break; |
||
466 | case preg_match('/alt\.binaries\.multimedia\.sports(\.boxing)?/', $group): |
||
467 | $this->tmpCat = Category::TV_SPORT; |
||
468 | break; |
||
469 | case $group === 'alt.binaries.music.opera': |
||
470 | switch (true) { |
||
471 | case $this->categorizeForeign && $this->isMusicForeign(): |
||
472 | break; |
||
473 | case preg_match('/720p|[-._ ]mkv/i', $this->releaseName): |
||
474 | $this->tmpCat = Category::MUSIC_VIDEO; |
||
475 | break; |
||
476 | default: |
||
477 | $this->tmpCat = Category::MUSIC_MP3; |
||
478 | break; |
||
479 | } |
||
480 | break; |
||
481 | case preg_match('/alt\.binaries\.music/', $group): |
||
482 | switch (true) { |
||
483 | case $this->categorizeForeign && $this->isMusicForeign(): |
||
484 | case $this->isMusic(): |
||
485 | break; |
||
486 | default: |
||
487 | $this->tmpCat = Category::MUSIC_MP3; |
||
488 | break; |
||
489 | } |
||
490 | break; |
||
491 | case strpos($group, 'audiobook') !== false: |
||
492 | if ($this->categorizeForeign && $this->isMusicForeign()) { |
||
493 | break; |
||
494 | } |
||
495 | $this->tmpCat = Category::MUSIC_AUDIOBOOK; |
||
496 | break; |
||
497 | case $group === 'alt.binaries.pro-wrestling': |
||
498 | $this->tmpCat = Category::TV_SPORT; |
||
499 | break; |
||
500 | case preg_match('/alt\.binaries\.sounds\.(flac(\.jazz)?|jpop|lossless(\.[a-z0-9]+)?)|alt\.binaries\.(cd\.lossless|music\.flac)/i', $group): |
||
501 | switch (true) { |
||
502 | case $this->categorizeForeign && $this->isMusicForeign(): |
||
503 | case $this->isMusic(): |
||
504 | break; |
||
505 | default: |
||
506 | $this->tmpCat = Category::MUSIC_LOSSLESS; |
||
507 | break; |
||
508 | } |
||
509 | break; |
||
510 | case $group === 'alt.binaries.sounds.whitburn.pop': |
||
511 | switch (true) { |
||
512 | case $this->categorizeForeign && $this->isMusicForeign(): |
||
513 | break; |
||
514 | case ! preg_match('/[-._ ]scans[-._ ]/i', $this->releaseName): |
||
515 | $this->tmpCat = Category::MUSIC_MP3; |
||
516 | break; |
||
517 | default: |
||
518 | return false; |
||
519 | } |
||
520 | break; |
||
521 | case $group === 'alt.binaries.sounds.ogg': |
||
522 | if ($this->categorizeForeign && $this->isMusicForeign()) { |
||
523 | break; |
||
524 | } |
||
525 | $this->tmpCat = Category::MUSIC_OTHER; |
||
526 | break; |
||
527 | case $group === 'alt.binaries.sony.psp': |
||
528 | if ($this->isGamePSVita()) { |
||
529 | break; |
||
530 | } |
||
531 | $this->tmpCat = Category::GAME_PSP; |
||
532 | break; |
||
533 | case $group === 'alt.binaries.warez': |
||
534 | switch (true) { |
||
535 | case $this->isTV(): |
||
536 | case $this->isMovie(): |
||
537 | case $this->isPC(): |
||
538 | case $this->isConsole(): |
||
539 | break; |
||
540 | default: |
||
541 | $this->tmpCat = Category::PC_0DAY; |
||
542 | break; |
||
543 | } |
||
544 | break; |
||
545 | case $group === 'alt.binaries.warez.games': |
||
546 | $this->tmpCat = Category::PC_GAMES; |
||
547 | break; |
||
548 | case $group === 'alt.binaries.warez.smartphone': |
||
549 | if ($this->isPhone()) { |
||
550 | break; |
||
551 | } |
||
552 | $this->tmpCat = Category::PC_PHONE_OTHER; |
||
553 | break; |
||
554 | case $this->categorizeForeign && $group === 'dk.binaer.tv': |
||
555 | $this->tmpCat = Category::TV_FOREIGN; |
||
556 | break; |
||
557 | default: |
||
558 | return false; |
||
559 | } |
||
560 | |||
561 | return true; |
||
562 | } |
||
563 | |||
564 | return false; |
||
565 | } |
||
566 | |||
567 | /** |
||
568 | * Try database regexes against a group / release name. |
||
569 | * |
||
570 | * @return bool |
||
571 | * @throws \Exception |
||
572 | */ |
||
573 | public function databaseRegex(): bool |
||
574 | { |
||
575 | $cat = $this->regexes->tryRegex($this->releaseName, $this->groupName()); |
||
576 | if ($cat) { |
||
577 | $this->tmpCat = $cat; |
||
578 | |||
579 | return true; |
||
580 | } |
||
581 | |||
582 | return false; |
||
583 | } |
||
584 | |||
585 | // |
||
586 | // Beginning of functions to determine category by release name. |
||
587 | // |
||
588 | |||
589 | /** |
||
590 | * @return bool |
||
591 | */ |
||
592 | public function isTV(): bool |
||
593 | { |
||
594 | // if (/*!preg_match('/s\d{1,3}[-._ ]?[ed]\d{1,3}|season|episode/i', $this->releaseName) &&*/ preg_match('/part[-._ ]?\d/i', $this->releaseName)) { |
||
595 | // return false; |
||
596 | // } |
||
597 | |||
598 | if (preg_match('/Daily[-_\.]Show|Nightly News|^\[[a-zA-Z\.\-]+\].*[-_].*\d{1,3}[-_. ]((\[|\()(h264-)?\d{3,4}(p|i)(\]|\))\s?(\[AAC\])?|\[[a-fA-F0-9]{8}\]|(8|10)BIT|hi10p)(\[[a-fA-F0-9]{8}\])?|(\d\d-){2}[12]\d{3}|[12]\d{3}(\.\d\d){2}|\d+x\d+|\.e\d{1,3}\.|s\d{1,3}[-._ ]?[ed]\d{1,3}([ex]\d{1,3}|[-.\w ])|[-._ ](\dx\d\d|C4TV|Complete[-._ ]Season|DSR|(D|H|P|S)DTV|EP[-._ ]?\d{1,3}|S\d{1,3}.+Extras|SUBPACK|Season[-._ ]\d{1,2})([-._ ]|$)|TVRIP|TV[-._ ](19|20)\d\d|Troll(HD|UHD)/i', $this->releaseName) |
||
599 | && ! preg_match('/[-._ ](flac|imageset|mp3|xxx)[-._ ]|[ .]exe$/i', $this->releaseName)) { |
||
600 | switch (true) { |
||
601 | case $this->isOtherTV(): |
||
602 | case $this->categorizeForeign && $this->isForeignTV(): |
||
603 | case $this->isSportTV(): |
||
604 | case $this->isDocumentaryTV(): |
||
605 | case $this->isUHDTV(): |
||
606 | case $this->catWebDL && $this->isWEBDL(): |
||
607 | case $this->isAnimeTV(): |
||
608 | case $this->isHDTV(): |
||
609 | case $this->isSDTV(): |
||
610 | case $this->isOtherTV2(): |
||
611 | return true; |
||
612 | default: |
||
613 | $this->tmpCat = Category::TV_OTHER; |
||
614 | |||
615 | return true; |
||
616 | } |
||
617 | } |
||
618 | |||
619 | if (preg_match('/[-._ ]((19|20)\d\d[-._ ]\d{1,2}[-._ ]\d{1,2}[-._ ]VHSRip|Indy[-._ ]?Car|(iMPACT|Smoky[-._ ]Mountain|Texas)[-._ ]Wrestling|Moto[-._ ]?GP|NSCS[-._ ]ROUND|NECW[-._ ]TV|(Per|Post)\-Show|PPV|WrestleMania|WCW|WEB[-._ ]HD|WWE[-._ ](Monday|NXT|RAW|Smackdown|Superstars|WrestleMania))[-._ ]/i', $this->releaseName)) { |
||
620 | if ($this->isSportTV()) { |
||
621 | return true; |
||
622 | } |
||
623 | $this->tmpCat = Category::TV_OTHER; |
||
624 | |||
625 | return true; |
||
626 | } |
||
627 | |||
628 | return false; |
||
629 | } |
||
630 | |||
631 | /** |
||
632 | * @return bool |
||
633 | */ |
||
634 | public function isOtherTV(): bool |
||
635 | { |
||
636 | if (preg_match('/[-._ ]S\d{1,3}.+(EP\d{1,3}|Extras|SUBPACK)[-._ ]|News/i', $this->releaseName) |
||
637 | //special case for "Have.I.Got.News.For.You" tv show |
||
638 | && ! preg_match('/[-._ ]Got[-._ ]News[-._ ]For[-._ ]You/i', $this->releaseName) |
||
639 | ) { |
||
640 | $this->tmpCat = Category::TV_OTHER; |
||
641 | |||
642 | return true; |
||
643 | } |
||
644 | |||
645 | return false; |
||
646 | } |
||
647 | |||
648 | /** |
||
649 | * @return bool|null |
||
650 | */ |
||
651 | public function isForeignTV(): ?bool |
||
652 | { |
||
653 | switch (true) { |
||
654 | case preg_match('/[-._ ](NHL|stanley.+cup)[-._ ]/', $this->releaseName): |
||
655 | return false; |
||
656 | case preg_match('/[-._ ](chinese|dk|fin|french|ger?|heb|ita|jap|kor|nor|nordic|nl|pl|swe)[-._ ]?(sub|dub)(ed|bed|s)?|<German>/i', $this->releaseName): |
||
657 | 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).+(720p|1080p|Divx|DOKU|DUB(BED)?|DLMUX|NOVARIP|RealCo|Sub(bed|s)?|Web[-._ ]?Rip|WS|Xvid|x264)[-._ ]/i', $this->releaseName): |
||
658 | 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): |
||
659 | case preg_match('/(S\d\d[EX]\d\d|DOCU(MENTAIRE)?|TV)?[-._ ](FRENCH|German|Dutch)[-._ ](720p|1080p|dv(b|d)r(ip)?|LD|HD\-?TV|TV[-._ ]?RIP|x264)[-._ ]/i', $this->releaseName): |
||
660 | case preg_match('/[-._ ]FastSUB|NL|nlvlaams|patrfa|RealCO|Seizoen|slosinh|Videomann|Vostfr|xslidian[-._ ]|x264\-iZU/i', $this->releaseName): |
||
661 | $this->tmpCat = Category::TV_FOREIGN; |
||
662 | |||
663 | return true; |
||
664 | default: |
||
665 | return false; |
||
666 | } |
||
667 | } |
||
668 | |||
669 | /** |
||
670 | * @return bool|null |
||
671 | */ |
||
672 | public function isSportTV(): ?bool |
||
673 | { |
||
674 | switch (true) { |
||
675 | case preg_match('/s\d{1,3}[-._ ]?[ed]\d{1,3}([ex]\d{1,3}|[-.\w ])/i', $this->releaseName): |
||
676 | return false; |
||
677 | case preg_match('/[-._ ]?(Bellator|bundesliga|EPL|ESPN|FIA|la[-._ ]liga|MMA|motogp|NFL|MLB|NCAA|PGA|FIM|NJPW|red[-._ ]bull|.+race|Sengoku|Strikeforce|supercup|uefa|UFC|wtcc|WWE)[-._ ]/i', $this->releaseName): |
||
678 | case preg_match('/[-._ ]?(DTM|FIFA|formula[-._ ]1|indycar|Rugby|NASCAR|NBA|NHL|NRL|netball[-._ ]anz|ROH|SBK|Superleague|The[-._ ]Ultimate[-._ ]Fighter|TNA|V8[-._ ]Supercars|WBA|WrestleMania)[-._ ]/i', $this->releaseName): |
||
679 | 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): |
||
680 | case preg_match('/[-._ ]?(Horse)[-._ ]Racing[-._ ]/i', $this->releaseName): |
||
681 | case preg_match('/[-._ ](VERUM|GRiP|Ebi|OVERTAKE)/i', $this->releaseName): |
||
682 | $this->tmpCat = Category::TV_SPORT; |
||
683 | |||
684 | return true; |
||
685 | default: |
||
686 | return false; |
||
687 | } |
||
688 | } |
||
689 | |||
690 | /** |
||
691 | * @return bool |
||
692 | */ |
||
693 | public function isDocumentaryTV(): bool |
||
694 | { |
||
695 | if (preg_match('/[-._ ](Docu|Documentary)[-._ ]/i', $this->releaseName)) { |
||
696 | $this->tmpCat = Category::TV_DOCU; |
||
697 | |||
698 | return true; |
||
699 | } |
||
700 | |||
701 | return false; |
||
702 | } |
||
703 | |||
704 | /** |
||
705 | * @return bool |
||
706 | */ |
||
707 | public function isWEBDL(): bool |
||
708 | { |
||
709 | if (preg_match('/web[-._ ]dl|web-?rip/i', $this->releaseName)) { |
||
710 | $this->tmpCat = Category::TV_WEBDL; |
||
711 | |||
712 | return true; |
||
713 | } |
||
714 | |||
715 | return false; |
||
716 | } |
||
717 | |||
718 | /** |
||
719 | * @return bool |
||
720 | */ |
||
721 | public function isAnimeTV(): bool |
||
722 | { |
||
723 | if (preg_match('/[-._ ]Anime[-._ ]|^\[[a-zA-Z\.\-]+\].*[-_].*\d{1,3}[-_. ]((\[|\()((\d{1,4}x\d{1,4})|(h264-)?\d{3,4}(p|i))(\]|\))\s?(\[AAC\])?|\[[a-fA-F0-9]{8}\]|(8|10)BIT|hi10p)(\[[a-fA-F0-9]{8}\])?/i', $this->releaseName)) { |
||
724 | $this->tmpCat = Category::TV_ANIME; |
||
725 | |||
726 | return true; |
||
727 | } |
||
728 | if (preg_match('/(ANiHLS|HaiKU|ANiURL)/i', $this->releaseName)) { |
||
729 | $this->tmpCat = Category::TV_ANIME; |
||
730 | |||
731 | return true; |
||
732 | } |
||
733 | |||
734 | return false; |
||
735 | } |
||
736 | |||
737 | /** |
||
738 | * @return bool |
||
739 | */ |
||
740 | public function isHDTV(): bool |
||
756 | } |
||
757 | |||
758 | /** |
||
759 | * @return bool |
||
760 | */ |
||
761 | public function isUHDTV(): bool |
||
762 | { |
||
763 | if (preg_match('/(S\d+).*(2160p).*(Netflix|Amazon).*(TrollUHD|NTb|VLAD)/i', $this->releaseName)) { |
||
764 | $this->tmpCat = Category::TV_UHD; |
||
765 | |||
766 | return true; |
||
767 | } |
||
768 | |||
769 | return false; |
||
770 | } |
||
771 | |||
772 | /** |
||
773 | * @return bool|null |
||
774 | */ |
||
775 | public function isSDTV(): ?bool |
||
776 | { |
||
777 | switch (true) { |
||
778 | case preg_match('/(360|480|576)p|Complete[-._ ]Season|dvdr(ip)?|dvd5|dvd9|\.pdtv|SD[-._ ]TV|TVRip|NTSC|BDRip|hdtv|xvid/i', $this->releaseName): |
||
779 | case preg_match('/((H|P)D[-._ ]?TV|DSR|WebRip)[-._ ]x264/i', $this->releaseName): |
||
780 | 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('/(H|P)D[-._ ]?TV|BDRip|WEB[-._ ]x264/i', $this->releaseName): |
||
781 | $this->tmpCat = Category::TV_SD; |
||
782 | |||
783 | return true; |
||
784 | default: |
||
785 | return false; |
||
786 | } |
||
787 | } |
||
788 | |||
789 | /** |
||
790 | * @return bool |
||
791 | */ |
||
792 | public function isOtherTV2(): bool |
||
793 | { |
||
794 | if (preg_match('/[-._ ]s\d{1,3}[-._ ]?(e|d(isc)?)\d{1,3}([-._ ]|$)/i', $this->releaseName)) { |
||
795 | $this->tmpCat = Category::TV_OTHER; |
||
796 | |||
797 | return true; |
||
798 | } |
||
799 | |||
800 | return false; |
||
801 | } |
||
802 | |||
803 | // Movies. |
||
804 | |||
805 | /** |
||
806 | * @return bool |
||
807 | */ |
||
808 | public function isMovie(): bool |
||
809 | { |
||
810 | if (preg_match('/[-._ ]AVC|[-._ ]|[BH][DR]RIP|Bluray|BD[-._ ]?(25|50)?|\bBR\b|Camrip|[-._ ]\d{4}[-._ ].+(720p|1080p|Cam|HDTS)|DIVX|[-._ ]DVD[-._ ]|DVD-?(5|9|R|Rip)|Untouched|VHSRip|XVID|[-._ ](DTS|TVrip)[-._ ]/i', $this->releaseName) && ! preg_match('/auto(cad|desk)|divx[-._ ]plus|[-._ ]exe$|[-._ ](jav|XXX)[-._ ]|SWE6RUS|\wXXX(1080p|720p|DVD)|Xilisoft/i', $this->releaseName)) { |
||
811 | switch (true) { |
||
812 | case $this->categorizeForeign && $this->isMovieForeign(): |
||
813 | case $this->isMovieDVD(): |
||
814 | case $this->isMovieUHD(): |
||
815 | case $this->catWebDL && $this->isMovieWEBDL(): |
||
816 | case $this->isMovieSD(): |
||
817 | case $this->isMovie3D(): |
||
818 | case $this->isMovieBluRay(): |
||
819 | case $this->isMovieHD(): |
||
820 | case $this->isMovieOther(): |
||
821 | return true; |
||
822 | default: |
||
823 | return false; |
||
824 | } |
||
825 | } |
||
826 | |||
827 | return false; |
||
828 | } |
||
829 | |||
830 | /** |
||
831 | * @return bool|null |
||
832 | */ |
||
833 | public function isMovieForeign(): ?bool |
||
834 | { |
||
835 | switch (true) { |
||
836 | case $this->isConsole(): |
||
837 | return true; |
||
838 | 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): |
||
839 | case stripos($this->releaseName, 'Castellano') !== false: |
||
840 | 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): |
||
841 | $this->tmpCat = Category::MOVIE_FOREIGN; |
||
842 | |||
843 | return true; |
||
844 | default: |
||
845 | return false; |
||
846 | } |
||
847 | } |
||
848 | |||
849 | /** |
||
850 | * @return bool |
||
851 | */ |
||
852 | public function isMovieDVD(): bool |
||
853 | { |
||
854 | if (preg_match('/(dvd\-?r|[-._ ]dvd|dvd9|dvd5|[-._ ]r5)[-._ ]/i', $this->releaseName)) { |
||
855 | $this->tmpCat = Category::MOVIE_DVD; |
||
856 | |||
857 | return true; |
||
858 | } |
||
859 | |||
860 | return false; |
||
861 | } |
||
862 | |||
863 | /** |
||
864 | * @return bool |
||
865 | */ |
||
866 | public function isMovieSD(): bool |
||
867 | { |
||
868 | if (preg_match('/(divx|dvdscr|extrascene|dvdrip|\.CAM|HDTS(-LINE)?|vhsrip|xvid(vd)?)[-._ ]/i', $this->releaseName)) { |
||
869 | $this->tmpCat = Category::MOVIE_SD; |
||
870 | |||
871 | return true; |
||
872 | } |
||
873 | |||
874 | return false; |
||
875 | } |
||
876 | |||
877 | /** |
||
878 | * @return bool |
||
879 | */ |
||
880 | public function isMovie3D(): bool |
||
881 | { |
||
882 | 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)) { |
||
883 | $this->tmpCat = Category::MOVIE_3D; |
||
884 | |||
885 | return true; |
||
886 | } |
||
887 | |||
888 | return false; |
||
889 | } |
||
890 | |||
891 | /** |
||
892 | * @return bool |
||
893 | */ |
||
894 | public function isMovieBluRay(): bool |
||
895 | { |
||
896 | if (preg_match('/bluray\-|[-._ ]bd?[-._ ]?(25|50)|blu-ray|Bluray\s\-\sUntouched|[-._ ]untouched[-._ ]/i', $this->releaseName) |
||
897 | && ! preg_match('/SecretUsenet\.com/i', $this->releaseName)) { |
||
898 | $this->tmpCat = Category::MOVIE_BLURAY; |
||
899 | |||
900 | return true; |
||
901 | } |
||
902 | |||
903 | return false; |
||
904 | } |
||
905 | |||
906 | /** |
||
907 | * @return bool |
||
908 | */ |
||
909 | public function isMovieHD(): bool |
||
910 | { |
||
911 | if (preg_match('/720p|1080p|AVC|VC1|VC\-1|web\-dl|wmvhd|x264|XvidHD|bdrip/i', $this->releaseName)) { |
||
912 | $this->tmpCat = Category::MOVIE_HD; |
||
913 | |||
914 | return true; |
||
915 | } |
||
916 | if ($this->catWebDL === false) { |
||
917 | if (preg_match('/web[-._ ]dl|web-?rip/i', $this->releaseName)) { |
||
918 | $this->tmpCat = Category::MOVIE_HD; |
||
919 | |||
920 | return true; |
||
921 | } |
||
922 | } |
||
923 | |||
924 | return false; |
||
925 | } |
||
926 | |||
927 | /** |
||
928 | * @return bool |
||
929 | */ |
||
930 | public function isMovieUHD(): bool |
||
931 | { |
||
932 | if (! preg_match('/(S\d+).*(2160p).*(Netflix|Amazon).*(TrollUHD|NTb|VLAD)/i', $this->releaseName) && preg_match('/2160p/i', $this->releaseName)) { |
||
933 | $this->tmpCat = Category::MOVIE_UHD; |
||
934 | |||
935 | return true; |
||
936 | } |
||
937 | |||
938 | return false; |
||
939 | } |
||
940 | |||
941 | /** |
||
942 | * @return bool |
||
943 | */ |
||
944 | public function isMovieOther(): bool |
||
945 | { |
||
946 | if (preg_match('/[-._ ]cam[-._ ]/i', $this->releaseName)) { |
||
947 | $this->tmpCat = Category::MOVIE_OTHER; |
||
948 | |||
949 | return true; |
||
950 | } |
||
951 | |||
952 | return false; |
||
953 | } |
||
954 | |||
955 | /** |
||
956 | * @return bool |
||
957 | */ |
||
958 | public function isMovieWEBDL(): bool |
||
959 | { |
||
960 | if (preg_match('/web[-._ ]dl|web-?rip/i', $this->releaseName)) { |
||
961 | $this->tmpCat = Category::MOVIE_WEBDL; |
||
962 | |||
963 | return true; |
||
964 | } |
||
965 | |||
966 | return false; |
||
967 | } |
||
968 | |||
969 | // PC. |
||
970 | |||
971 | /** |
||
972 | * @return bool|null |
||
973 | */ |
||
974 | public function isPC(): ?bool |
||
975 | { |
||
976 | switch (true) { |
||
977 | case preg_match('/s\d{1,3}[-._ ]?[ed]\d{1,3}([ex]\d{1,3}|[-.\w ])|[^a-z0-9](FLAC|Imageset|PICTURESET|MP3|Nintendo|PDTV|PS[23P]|SWE6RUS|UMD(RIP)?|WII|x264|XBOX(360|DVD|ONE)?|XXX)[^a-z0-9]/i', $this->releaseName): |
||
978 | return false; |
||
979 | case $this->isPhone(): |
||
980 | case $this->isMac(): |
||
981 | case $this->isISO(): |
||
982 | case $this->isPCGame(): |
||
983 | case $this->is0day(): |
||
984 | return true; |
||
985 | default: |
||
986 | return false; |
||
987 | } |
||
988 | } |
||
989 | |||
990 | /** |
||
991 | * @return bool |
||
992 | */ |
||
993 | public function isPhone(): bool |
||
994 | { |
||
995 | switch (true) { |
||
996 | case preg_match('/[^a-z0-9](IPHONE|ITOUCH|IPAD)[-._ ]/i', $this->releaseName): |
||
997 | $this->tmpCat = Category::PC_PHONE_IOS; |
||
998 | break; |
||
999 | case preg_match('/[-._ ]?(ANDROID)[-._ ]/i', $this->releaseName): |
||
1000 | $this->tmpCat = Category::PC_PHONE_ANDROID; |
||
1001 | break; |
||
1002 | case preg_match('/[^a-z0-9](symbian|xscale|wm5|wm6)[-._ ]/i', $this->releaseName): |
||
1003 | $this->tmpCat = Category::PC_PHONE_OTHER; |
||
1004 | break; |
||
1005 | default: |
||
1006 | return false; |
||
1007 | } |
||
1008 | |||
1009 | return true; |
||
1010 | } |
||
1011 | |||
1012 | /** |
||
1013 | * @return bool|null |
||
1014 | */ |
||
1015 | public function isISO(): ?bool |
||
1016 | { |
||
1017 | switch (true) { |
||
1018 | case preg_match('/[-._ ]([a-zA-Z]{2,10})?iso[ _.-]|[-. ]([a-z]{2,10})?iso$/i', $this->releaseName): |
||
1019 | case preg_match('/[-._ ](DYNAMiCS|INFINITESKILLS|UDEMY|kEISO|PLURALSIGHT|DIGITALTUTORS|TUTSPLUS|OSTraining|PRODEV|CBT\.Nuggets|COMPRISED)/i', $this->releaseName): |
||
1020 | $this->tmpCat = Category::PC_ISO; |
||
1021 | |||
1022 | return true; |
||
1023 | default: |
||
1024 | return false; |
||
1025 | } |
||
1026 | } |
||
1027 | |||
1028 | /** |
||
1029 | * @return bool|null |
||
1030 | */ |
||
1031 | public function is0day(): ?bool |
||
1032 | { |
||
1033 | switch (true) { |
||
1034 | case preg_match('/[-._ ]exe$|[-._ ](utorrent|Virtualbox)[-._ ]|\b0DAY\b|incl.+crack| DRM$|>DRM</i', $this->releaseName): |
||
1035 | 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): |
||
1036 | 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): |
||
1037 | $this->tmpCat = Category::PC_0DAY; |
||
1038 | |||
1039 | return true; |
||
1040 | default: |
||
1041 | return false; |
||
1042 | } |
||
1043 | } |
||
1044 | |||
1045 | /** |
||
1046 | * @return bool |
||
1047 | */ |
||
1048 | public function isMac(): bool |
||
1049 | { |
||
1050 | if (preg_match('/(\b|[-._ ])mac(\.|\s)?osx(\b|[-_. ])/i', $this->releaseName)) { |
||
1051 | $this->tmpCat = Category::PC_MAC; |
||
1052 | |||
1053 | return true; |
||
1054 | } |
||
1055 | |||
1056 | return false; |
||
1057 | } |
||
1058 | |||
1059 | /** |
||
1060 | * @return bool |
||
1061 | */ |
||
1062 | public function isPCGame(): bool |
||
1063 | { |
||
1064 | if (preg_match('/[^a-z0-9](0x0007|ALiAS|BACKLASH|BAT|CLONECD|CPY|FAS(DOX|iSO)|FLT([-._ ]|COGENT)|FLT(DOX)?|PC GAMES?|\(?(Game(s|z)|GAME(S|Z))\)? ?(\((C|c)\))|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)) { |
||
1065 | $this->tmpCat = Category::PC_GAMES; |
||
1066 | |||
1067 | return true; |
||
1068 | } |
||
1069 | |||
1070 | return false; |
||
1071 | } |
||
1072 | |||
1073 | // XXX. |
||
1074 | |||
1075 | /** |
||
1076 | * @return bool|null |
||
1077 | */ |
||
1078 | public function isXxx(): ?bool |
||
1079 | { |
||
1080 | switch (true) { |
||
1081 | case ! preg_match('/\bXXX\b|(a\.b\.erotica|ClubSeventeen|Cum(ming|shot)|Err?oticax?|Porn(o|lation)?|Imageset|PICTURESET|JAV Uncensored|lesb(ians?|os?)|mastur(bation|e?bate)|My_Stepfather_Made_Me|nympho?|OLDER ANGELS|pictures\.erotica\.anime|sexontv|slut|Squirt|SWE6RUS|Transsexual|whore)/i', $this->releaseName): |
||
1082 | return false; |
||
1083 | case $this->isXxxPack(): |
||
1084 | case $this->isXxxClipSD(): |
||
1085 | case $this->isXxxSD(): |
||
1086 | case $this->isXxxUHD(): |
||
1087 | case $this->isXxxClipHD(): |
||
1088 | case $this->catWebDL && $this->isXxxWEBDL(): |
||
1089 | case $this->isXxx264(): |
||
1090 | case $this->isXxxXvid(): |
||
1091 | case $this->isXxxImageset(): |
||
1092 | case $this->isXxxWMV(): |
||
1093 | case $this->isXxxDVD(): |
||
1094 | case $this->isXxxOther(): |
||
1095 | |||
1096 | return true; |
||
1097 | default: |
||
1098 | $this->tmpCat = Category::XXX_OTHER; |
||
1099 | |||
1100 | return true; |
||
1101 | } |
||
1102 | } |
||
1103 | |||
1104 | /** |
||
1105 | * @return bool |
||
1106 | */ |
||
1107 | public function isXxx264(): bool |
||
1108 | { |
||
1109 | 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) { |
||
1110 | $this->tmpCat = Category::XXX_X264; |
||
1111 | |||
1112 | return true; |
||
1113 | } |
||
1114 | if ($this->catWebDL === false) { |
||
1115 | if (preg_match('/web[-._ ]dl|web-?rip/i', $this->releaseName)) { |
||
1116 | $this->tmpCat = Category::XXX_X264; |
||
1117 | |||
1118 | return true; |
||
1119 | } |
||
1120 | } |
||
1121 | |||
1122 | return false; |
||
1123 | } |
||
1124 | |||
1125 | /** |
||
1126 | * @return bool |
||
1127 | */ |
||
1128 | public function isXxxUHD(): bool |
||
1129 | { |
||
1130 | if (preg_match('/^[\w-.]+(\d{2}\.\d{2}\.\d{2}).+(2160p)+[\w-.]+(M[PO][V4]-(KTR|GUSH|FaiLED|SEXORS|hUSHhUSH|YAPG))/i', $this->releaseName)) { |
||
1131 | $this->tmpCat = Category::XXX_UHD; |
||
1132 | |||
1133 | return true; |
||
1134 | } |
||
1135 | |||
1136 | return false; |
||
1137 | } |
||
1138 | |||
1139 | /** |
||
1140 | * @return bool |
||
1141 | */ |
||
1142 | public function isXxxClipHD(): bool |
||
1143 | { |
||
1144 | 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)) { |
||
1145 | $this->tmpCat = Category::XXX_CLIPHD; |
||
1146 | |||
1147 | return true; |
||
1148 | } |
||
1149 | |||
1150 | return false; |
||
1151 | } |
||
1152 | |||
1153 | /** |
||
1154 | * @return bool |
||
1155 | */ |
||
1156 | public function isXxxWMV(): bool |
||
1157 | { |
||
1158 | 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) { |
||
1159 | $this->tmpCat = Category::XXX_WMV; |
||
1160 | |||
1161 | return true; |
||
1162 | } |
||
1163 | |||
1164 | return false; |
||
1165 | } |
||
1166 | |||
1167 | /** |
||
1168 | * @return bool |
||
1169 | */ |
||
1170 | public function isXxxXvid(): bool |
||
1171 | { |
||
1172 | if (preg_match('/(b[dr]|dvd)rip|detoxication|divx|nympho|pornolation|swe6|tesoro|xvid/i', $this->releaseName)) { |
||
1173 | $this->tmpCat = Category::XXX_XVID; |
||
1174 | |||
1175 | return true; |
||
1176 | } |
||
1177 | |||
1178 | return false; |
||
1179 | } |
||
1180 | |||
1181 | /** |
||
1182 | * @return bool |
||
1183 | */ |
||
1184 | public function isXxxDVD(): bool |
||
1185 | { |
||
1186 | if (preg_match('/dvdr[^i]|dvd[59]/i', $this->releaseName)) { |
||
1187 | $this->tmpCat = Category::XXX_DVD; |
||
1188 | |||
1189 | return true; |
||
1190 | } |
||
1191 | |||
1192 | return false; |
||
1193 | } |
||
1194 | |||
1195 | /** |
||
1196 | * @return bool |
||
1197 | */ |
||
1198 | public function isXxxImageset(): bool |
||
1199 | { |
||
1200 | if (preg_match('/IMAGESET|PICTURESET|ABPEA/i', $this->releaseName)) { |
||
1201 | $this->tmpCat = Category::XXX_IMAGESET; |
||
1202 | |||
1203 | return true; |
||
1204 | } |
||
1205 | |||
1206 | return false; |
||
1207 | } |
||
1208 | |||
1209 | /** |
||
1210 | * @return bool |
||
1211 | */ |
||
1212 | public function isXxxPack(): bool |
||
1213 | { |
||
1214 | if (preg_match('/[ .]PACK[ .]/i', $this->releaseName)) { |
||
1215 | $this->tmpCat = Category::XXX_PACK; |
||
1216 | |||
1217 | return true; |
||
1218 | } |
||
1219 | |||
1220 | return false; |
||
1221 | } |
||
1222 | |||
1223 | /** |
||
1224 | * @return bool |
||
1225 | */ |
||
1226 | public function isXxxOther(): bool |
||
1227 | { |
||
1228 | // If nothing else matches, then try these words. |
||
1229 | if (preg_match('/[-._ ]Brazzers|Creampie|[-._ ]JAV[-._ ]|North\.Pole|^Nubiles|She[-._ ]?Male|Transsexual|OLDER ANGELS/i', $this->releaseName)) { |
||
1230 | $this->tmpCat = Category::XXX_OTHER; |
||
1231 | |||
1232 | return true; |
||
1233 | } |
||
1234 | |||
1235 | return false; |
||
1236 | } |
||
1237 | |||
1238 | /** |
||
1239 | * @return bool|null |
||
1240 | */ |
||
1241 | public function isXxxClipSD(): ?bool |
||
1242 | { |
||
1243 | switch (true) { |
||
1244 | case $this->checkPoster('/oz@lot[.]com/i', $this->poster, Category::XXX_CLIPSD): |
||
1245 | return true; |
||
1246 | case $this->checkPoster('/anon@y[.]com/i', $this->poster, Category::XXX_CLIPSD): |
||
1247 | return true; |
||
1248 | case $this->checkPoster('/@md-hobbys[.]com/i', $this->poster, Category::XXX_CLIPSD): |
||
1249 | return true; |
||
1250 | case stripos($this->releaseName, 'SDPORN') !== false: |
||
1251 | $this->tmpCat = Category::XXX_CLIPSD; |
||
1252 | |||
1253 | return true; |
||
1254 | default: |
||
1255 | return false; |
||
1256 | } |
||
1257 | } |
||
1258 | |||
1259 | /** |
||
1260 | * @return bool |
||
1261 | */ |
||
1262 | public function isXxxSD(): bool |
||
1263 | { |
||
1264 | if (preg_match('/SDX264XXX|XXX\.HR\./i', $this->releaseName)) { |
||
1265 | $this->tmpCat = Category::XXX_SD; |
||
1266 | |||
1267 | return true; |
||
1268 | } |
||
1269 | |||
1270 | return false; |
||
1271 | } |
||
1272 | |||
1273 | /** |
||
1274 | * @return bool |
||
1275 | */ |
||
1276 | public function isXxxWEBDL(): bool |
||
1277 | { |
||
1278 | if (preg_match('/web[-._ ]dl|web-?rip/i', $this->releaseName)) { |
||
1279 | $this->tmpCat = Category::XXX_WEBDL; |
||
1280 | |||
1281 | return true; |
||
1282 | } |
||
1283 | |||
1284 | return false; |
||
1285 | } |
||
1286 | |||
1287 | // Console. |
||
1288 | |||
1289 | /** |
||
1290 | * @return bool|null |
||
1291 | */ |
||
1292 | public function isConsole(): ?bool |
||
1293 | { |
||
1294 | switch (true) { |
||
1295 | case $this->isGameNDS(): |
||
1296 | case $this->isGame3DS(): |
||
1297 | case $this->isGamePS3(): |
||
1298 | case $this->isGamePS4(): |
||
1299 | case $this->isGamePSP(): |
||
1300 | case $this->isGamePSVita(): |
||
1301 | case $this->isGameWiiWare(): |
||
1302 | case $this->isGameWiiU(): |
||
1303 | case $this->isGameWii(): |
||
1304 | case $this->isGameNGC(): |
||
1305 | case $this->isGameXBOX360DLC(): |
||
1306 | case $this->isGameXBOX360(): |
||
1307 | case $this->isGameXBOXONE(): |
||
1308 | case $this->isGameXBOX(): |
||
1309 | case $this->isGameOther(): |
||
1310 | return true; |
||
1311 | default: |
||
1312 | return false; |
||
1313 | } |
||
1314 | } |
||
1315 | |||
1316 | /** |
||
1317 | * @return bool |
||
1318 | */ |
||
1319 | public function isGameNDS(): bool |
||
1320 | { |
||
1321 | if (preg_match('/^NDS|[^a-zA-Z0-9]NDS|[\._-](nds|NDS)|nintendo.+[^3]n?dsi?/', $this->releaseName)) { |
||
1322 | if (preg_match('/\((DE|DSi(\sEnhanched)?|_NDS-|EUR?|FR|GAME|HOL|JP|JPN|NL|NTSC|PAL|KS|USA?)\)/i', $this->releaseName)) { |
||
1323 | $this->tmpCat = Category::GAME_NDS; |
||
1324 | |||
1325 | return true; |
||
1326 | } |
||
1327 | if (preg_match('/EUR|FR|GAME|HOL|JP|JPN|NL|NTSC|PAL|KS|USA|\bROMS?(et)?\b/i', $this->releaseName)) { |
||
1328 | $this->tmpCat = Category::GAME_NDS; |
||
1329 | |||
1330 | return true; |
||
1331 | } |
||
1332 | } |
||
1333 | |||
1334 | return false; |
||
1335 | } |
||
1336 | |||
1337 | /** |
||
1338 | * @return bool |
||
1339 | */ |
||
1340 | public function isGame3DS(): bool |
||
1341 | { |
||
1342 | if (preg_match('/\b3DS\b[^max]|[\._-]3ds|nintendo.+3ds|[_\.]3DS-/i', $this->releaseName) && ! preg_match('/3ds max/i', $this->releaseName)) { |
||
1343 | if (preg_match('/(EUR|FR|GAME|HOL|JP|JPN|NL|NTSC|PAL|KS|USA|ASIA)/i', $this->releaseName)) { |
||
1344 | $this->tmpCat = Category::GAME_3DS; |
||
1345 | |||
1346 | return true; |
||
1347 | } |
||
1348 | } |
||
1349 | |||
1350 | return false; |
||
1351 | } |
||
1352 | |||
1353 | /** |
||
1354 | * @return bool |
||
1355 | */ |
||
1356 | public function isGameNGC(): bool |
||
1357 | { |
||
1358 | if (preg_match('/[\._-]N?G(AME)?C(UBE)?-/i', $this->releaseName)) { |
||
1359 | if (preg_match('/_(EUR?|FR|GAME|HOL|JP|JPN|NL|NTSC|PAL|KS|USA?)_/i', $this->releaseName)) { |
||
1360 | $this->tmpCat = Category::GAME_OTHER; |
||
1361 | |||
1362 | return true; |
||
1363 | } |
||
1364 | 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)) { |
||
1365 | $this->tmpCat = Category::GAME_OTHER; |
||
1366 | |||
1367 | return true; |
||
1368 | } |
||
1369 | } |
||
1370 | |||
1371 | return false; |
||
1372 | } |
||
1373 | |||
1374 | /** |
||
1375 | * @return bool |
||
1376 | */ |
||
1377 | public function isGamePS3(): bool |
||
1378 | { |
||
1379 | if (preg_match('/[^e]PS3/i', $this->releaseName)) { |
||
1380 | if (preg_match('/ANTiDOTE|DLC|DUPLEX|EUR?|Googlecus|GOTY|\-HR|iNSOMNi|JAP|JPN|KONDIOS|\[PS3\]|PSN/i', $this->releaseName)) { |
||
1381 | $this->tmpCat = Category::GAME_PS3; |
||
1382 | |||
1383 | return true; |
||
1384 | } |
||
1385 | if (preg_match('/AGENCY|APATHY|Caravan|MULTi|NRP|NTSC|PAL|SPLiT|STRiKE|USA?|ZRY/i', $this->releaseName)) { |
||
1386 | $this->tmpCat = Category::GAME_PS3; |
||
1387 | |||
1388 | return true; |
||
1389 | } |
||
1390 | } |
||
1391 | |||
1392 | return false; |
||
1393 | } |
||
1394 | |||
1395 | /** |
||
1396 | * @return bool |
||
1397 | */ |
||
1398 | public function isGamePS4(): bool |
||
1414 | } |
||
1415 | |||
1416 | /** |
||
1417 | * @return bool |
||
1418 | */ |
||
1419 | public function isGamePSP(): bool |
||
1420 | { |
||
1421 | if (stripos($this->releaseName, 'PSP') !== false) { |
||
1422 | if (preg_match('/[-._ ](BAHAMUT|Caravan|EBOOT|EMiNENT|EUR?|EvoX|GAME|GHS|Googlecus|HandHeld|\-HR|JAP|JPN|KLOTEKLAPPERS|KOR|NTSC|PAL)/i', $this->releaseName)) { |
||
1423 | $this->tmpCat = Category::GAME_PSP; |
||
1424 | |||
1425 | return true; |
||
1426 | } |
||
1427 | 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)) { |
||
1428 | $this->tmpCat = Category::GAME_PSP; |
||
1429 | |||
1430 | return true; |
||
1431 | } |
||
1432 | } |
||
1433 | |||
1434 | return false; |
||
1435 | } |
||
1436 | |||
1437 | /** |
||
1438 | * @return bool |
||
1439 | */ |
||
1440 | public function isGamePSVita(): bool |
||
1441 | { |
||
1442 | if (preg_match('/PS ?Vita/i', $this->releaseName)) { |
||
1443 | $this->tmpCat = Category::GAME_PSVITA; |
||
1444 | |||
1445 | return true; |
||
1446 | } |
||
1447 | |||
1448 | return false; |
||
1449 | } |
||
1450 | |||
1451 | /** |
||
1452 | * @return bool |
||
1453 | */ |
||
1454 | public function isGameWiiWare(): bool |
||
1455 | { |
||
1456 | if (preg_match('/(Console|DLC|VC).+[-._ ]WII|(Console|DLC|VC)[-._ ]WII|WII[-._ ].+(Console|DLC|VC)|WII[-._ ](Console|DLC|VC)|WIIWARE/i', $this->releaseName)) { |
||
1457 | $this->tmpCat = Category::GAME_WIIWARE; |
||
1458 | |||
1459 | return true; |
||
1460 | } |
||
1461 | |||
1462 | return false; |
||
1463 | } |
||
1464 | |||
1465 | /** |
||
1466 | * @return bool|null |
||
1467 | */ |
||
1468 | public function isGameWiiU(): ?bool |
||
1469 | { |
||
1470 | switch (true) { |
||
1471 | case ! preg_match('/WII-?U/i', $this->releaseName): |
||
1472 | return false; |
||
1473 | case preg_match('/[-._ ](Allstars|BiOSHOCK|dumpTruck|DNi|iCON|JAP|NTSC|PAL|ProCiSiON|PROPER|RANT|REV0|SUNSHiNE|SUSHi|TMD|USA?)/i', $this->releaseName): |
||
1474 | case preg_match('/[-._ ](APATHY|BAHAMUT|DMZ|ERD|GAME|JPN|LoCAL|MULTi|NAGGERS|OneUp|PLAYME|PONS|Scrubbed|VORTEX|ZARD|ZER0)/i', $this->releaseName): |
||
1475 | case preg_match('/[-._ ](ALMoST|AMBITION|Caravan|CLiiCHE|DRYB|HaZMaT|KOR|LOADER|MARVEL|PROMiNENT|LaKiTu|LOCAL|QwiiF|RANT)/i', $this->releaseName): |
||
1476 | $this->tmpCat = Category::GAME_WIIU; |
||
1477 | |||
1478 | return true; |
||
1479 | default: |
||
1480 | return false; |
||
1481 | } |
||
1482 | } |
||
1483 | |||
1484 | /** |
||
1485 | * @return bool|null |
||
1486 | */ |
||
1487 | public function isGameWii(): ?bool |
||
1488 | { |
||
1489 | switch (true) { |
||
1490 | case stripos($this->releaseName, 'WII') === false: |
||
1491 | return false; |
||
1492 | case preg_match('/[-._ ](Allstars|BiOSHOCK|dumpTruck|DNi|iCON|JAP|NTSC|PAL|ProCiSiON|PROPER|RANT|REV0|SUNSHiNE|SUSHi|TMD|USA?)/i', $this->releaseName): |
||
1493 | case preg_match('/[-._ ](APATHY|BAHAMUT|DMZ|ERD|GAME|JPN|LoCAL|MULTi|NAGGERS|OneUp|PLAYME|PONS|Scrubbed|VORTEX|ZARD|ZER0)/i', $this->releaseName): |
||
1494 | case preg_match('/[-._ ](ALMoST|AMBITION|Caravan|CLiiCHE|DRYB|HaZMaT|KOR|LOADER|MARVEL|PROMiNENT|LaKiTu|LOCAL|QwiiF|RANT)/i', $this->releaseName): |
||
1495 | $this->tmpCat = Category::GAME_WII; |
||
1496 | |||
1497 | return true; |
||
1498 | default: |
||
1499 | return false; |
||
1500 | } |
||
1501 | } |
||
1502 | |||
1503 | /** |
||
1504 | * @return bool |
||
1505 | */ |
||
1506 | public function isGameXBOX360DLC(): bool |
||
1507 | { |
||
1508 | if (preg_match('/DLC.+xbox360|xbox360.+DLC|XBLA.+xbox360|xbox360.+XBLA/i', $this->releaseName)) { |
||
1509 | $this->tmpCat = Category::GAME_XBOX360DLC; |
||
1510 | |||
1511 | return true; |
||
1512 | } |
||
1513 | |||
1514 | return false; |
||
1515 | } |
||
1516 | |||
1517 | /** |
||
1518 | * @return bool |
||
1519 | */ |
||
1520 | public function isGameXBOX360(): bool |
||
1521 | { |
||
1522 | if (stripos($this->releaseName, '/XBOX360/i') !== false) { |
||
1523 | $this->tmpCat = Category::GAME_XBOX360; |
||
1524 | |||
1525 | return true; |
||
1526 | } |
||
1527 | if (stripos($this->releaseName, 'x360') !== false) { |
||
1528 | if (preg_match('/Allstars|ASiA|CCCLX|COMPLEX|DAGGER|GLoBAL|iMARS|JAP|JPN|MULTi|NTSC|PAL|REPACK|RRoD|RF|SWAG|USA?/i', $this->releaseName)) { |
||
1529 | $this->tmpCat = Category::GAME_XBOX360; |
||
1530 | |||
1531 | return true; |
||
1532 | } |
||
1533 | if (preg_match('/DAMNATION|GERMAN|GOTY|iNT|iTA|JTAG|KINECT|MARVEL|MUX360|RANT|SPARE|SPANISH|VATOS|XGD/i', $this->releaseName)) { |
||
1534 | $this->tmpCat = Category::GAME_XBOX360; |
||
1535 | |||
1536 | return true; |
||
1537 | } |
||
1538 | } |
||
1539 | |||
1540 | return false; |
||
1541 | } |
||
1542 | |||
1543 | /** |
||
1544 | * @return bool |
||
1545 | */ |
||
1546 | public function isGameXBOXONE(): bool |
||
1547 | { |
||
1548 | if (preg_match('/XBOXONE|XBOX\.ONE/i', $this->releaseName)) { |
||
1549 | $this->tmpCat = Category::GAME_XBOXONE; |
||
1550 | |||
1551 | return true; |
||
1552 | } |
||
1553 | |||
1554 | return false; |
||
1555 | } |
||
1556 | |||
1557 | /** |
||
1558 | * @return bool |
||
1559 | */ |
||
1560 | public function isGameXBOX(): bool |
||
1561 | { |
||
1562 | if (stripos($this->releaseName, 'XBOX') !== false) { |
||
1563 | $this->tmpCat = Category::GAME_XBOX; |
||
1564 | |||
1565 | return true; |
||
1566 | } |
||
1567 | |||
1568 | return false; |
||
1569 | } |
||
1570 | |||
1571 | /** |
||
1572 | * @return bool |
||
1573 | */ |
||
1574 | public function isGameOther(): bool |
||
1575 | { |
||
1576 | if (preg_match('/\b(PS(1)X|PS2|SNES|NES|SEGA\s(GENESIS|CD)|GB(A|C)|Dreamcast|SEGA\sSaturn|Atari\s(Jaguar)?|3DO)\b/i', $this->releaseName)) { |
||
1577 | if (preg_match('/EUR|FR|GAME|HOL|\bISO\b|JP|JPN|NL|NTSC|PAL|KS|USA|ROMS?(et)?/i', $this->releaseName)) { |
||
1578 | $this->tmpCat = Category::GAME_OTHER; |
||
1579 | |||
1580 | return true; |
||
1581 | } |
||
1582 | } |
||
1583 | |||
1584 | return false; |
||
1585 | } |
||
1586 | |||
1587 | // Music. |
||
1588 | |||
1589 | /** |
||
1590 | * @return bool|null |
||
1591 | */ |
||
1592 | public function isMusic(): ?bool |
||
1593 | { |
||
1594 | switch (true) { |
||
1595 | //They Knew What They Wanted (1940).480p.DVDRIP.MP3-NoGroup -- prevents movies matches with MP3 audio codec in the title |
||
1596 | case preg_match('/\d{3,4}(p|i)\.DVD(RIP)?\.MP3[-\.].*|WEB(-DL|-?RIP)/i', $this->releaseName): |
||
1597 | return false; |
||
1598 | case $this->isMusicVideo(): |
||
1599 | case $this->isAudiobook(): |
||
1600 | case $this->isMusicLossless(): |
||
1601 | case $this->isMusicMP3(): |
||
1602 | case $this->isMusicOther(): |
||
1603 | return true; |
||
1604 | default: |
||
1605 | return false; |
||
1606 | } |
||
1607 | } |
||
1608 | |||
1609 | /** |
||
1610 | * @return bool |
||
1611 | */ |
||
1612 | public function isMusicForeign(): bool |
||
1613 | { |
||
1614 | 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)) { |
||
1615 | $this->tmpCat = Category::MUSIC_FOREIGN; |
||
1616 | |||
1617 | return true; |
||
1618 | } |
||
1619 | |||
1620 | return false; |
||
1621 | } |
||
1622 | |||
1623 | /** |
||
1624 | * @return bool |
||
1625 | */ |
||
1626 | public function isAudiobook(): bool |
||
1627 | { |
||
1628 | if ($this->categorizeForeign) { |
||
1629 | if (stripos($this->releaseName, 'Audiobook') !== false) { |
||
1630 | $this->tmpCat = Category::MUSIC_FOREIGN; |
||
1631 | |||
1632 | return true; |
||
1633 | } |
||
1634 | } |
||
1635 | |||
1636 | return false; |
||
1637 | } |
||
1638 | |||
1639 | /** |
||
1640 | * @return bool |
||
1641 | */ |
||
1642 | public function isMusicVideo(): bool |
||
1643 | { |
||
1644 | if (preg_match('/(720P|x264)\-(19|20)\d\d\-[a-z0-9]{1,12}/i', $this->releaseName)) { |
||
1645 | if ($this->isMusicForeign()) { |
||
1646 | return true; |
||
1647 | } |
||
1648 | $this->tmpCat = Category::MUSIC_VIDEO; |
||
1649 | |||
1650 | return true; |
||
1651 | } |
||
1652 | if (preg_match('/[a-z0-9]{1,12}\-(19|20)\d\d\-(720P|x264)/i', $this->releaseName)) { |
||
1653 | if ($this->isMusicForeign()) { |
||
1654 | return true; |
||
1655 | } |
||
1656 | $this->tmpCat = Category::MUSIC_VIDEO; |
||
1657 | |||
1658 | return true; |
||
1659 | } |
||
1660 | |||
1661 | return false; |
||
1662 | } |
||
1663 | |||
1664 | /** |
||
1665 | * @return bool |
||
1666 | */ |
||
1667 | public function isMusicLossless(): bool |
||
1668 | { |
||
1669 | if (preg_match('/\[(19|20)\d\d\][-._ ]\[FLAC\]|(\(|\[)flac(\)|\])|FLAC\-(19|20)\d\d\-[a-z0-9]{1,12}|\.flac"|(19|20)\d\d\sFLAC|[-._ ]FLAC.+(19|20)\d\d[-._ ]| FLAC$/i', $this->releaseName)) { |
||
1670 | if ($this->isMusicForeign()) { |
||
1671 | return true; |
||
1672 | } |
||
1673 | $this->tmpCat = Category::MUSIC_LOSSLESS; |
||
1674 | |||
1675 | return true; |
||
1676 | } |
||
1677 | |||
1678 | return false; |
||
1679 | } |
||
1680 | |||
1681 | /** |
||
1682 | * @return bool |
||
1683 | */ |
||
1684 | public function isMusicMP3(): bool |
||
1704 | } |
||
1705 | |||
1706 | /** |
||
1707 | * @return bool |
||
1708 | */ |
||
1709 | public function isMusicOther(): bool |
||
1710 | { |
||
1711 | 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)) { |
||
1712 | switch (true) { |
||
1713 | case $this->isMusicForeign(): |
||
1714 | break; |
||
1715 | default: |
||
1716 | $this->tmpCat = Category::MUSIC_OTHER; |
||
1717 | break; |
||
1718 | } |
||
1719 | |||
1720 | return true; |
||
1721 | } |
||
1722 | 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)) { |
||
1723 | $this->tmpCat = Category::MUSIC_OTHER; |
||
1724 | |||
1725 | return true; |
||
1726 | } |
||
1727 | |||
1728 | return false; |
||
1729 | } |
||
1730 | |||
1731 | // Books. |
||
1732 | |||
1733 | /** |
||
1734 | * @return bool|null |
||
1735 | */ |
||
1736 | public function isBook(): ?bool |
||
1749 | } |
||
1750 | } |
||
1751 | |||
1752 | /** |
||
1753 | * @return bool|null |
||
1754 | */ |
||
1755 | public function isBookForeign(): ?bool |
||
1756 | { |
||
1757 | switch (true) { |
||
1758 | case $this->categorizeForeign === false: |
||
1759 | return false; |
||
1760 | 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): |
||
1761 | $this->tmpCat = Category::BOOKS_FOREIGN; |
||
1762 | |||
1763 | return true; |
||
1764 | default: |
||
1765 | return false; |
||
1766 | } |
||
1767 | } |
||
1768 | |||
1769 | /** |
||
1770 | * @return bool |
||
1771 | */ |
||
1772 | public function isComic(): bool |
||
1773 | { |
||
1774 | switch (true) { |
||
1775 | case ! preg_match('/[\. ](cbr|cbz)|[\( ]c2c|cbr|cbz[\) ]|comix|^\(comic|[\.\-_\(\[ ]comics?[-._ ]|comic.+book|covers.+digital|DC.+(Adventures|Universe)|digital.+(son|zone)|Graphic.+Novel|[\.\-_h ]manga|Total[-._ ]Marvel/i', $this->releaseName): |
||
1776 | return false; |
||
1777 | case $this->isBookForeign(): |
||
1778 | break; |
||
1779 | default: |
||
1780 | $this->tmpCat = Category::BOOKS_COMICS; |
||
1781 | break; |
||
1782 | } |
||
1783 | |||
1784 | return true; |
||
1785 | } |
||
1786 | |||
1787 | /** |
||
1788 | * @return bool |
||
1789 | */ |
||
1790 | public function isTechnicalBook(): bool |
||
1791 | { |
||
1792 | switch (true) { |
||
1793 | case ! preg_match('/^\(?(atz|bb|css|c ?t|Drawing|Gabler|IOS|Iphone|Lynda|Manning|Medic(al|ine)|MIT|No[-._ ]Starch|Packt|Peachpit|Pragmatic|Revista|Servo|SmartBooks|Spektrum|Strata|Sybex|Syngress|Vieweg|Wiley|Woods|Wrox)[-._ ]|[-._ ](Ajax|CSS|DIY|Javascript|(My|Postgre)?SQL|XNA)[-._ ]|3DS\.\-_ ]Max|Academic|Adobe|Algebra|Analysis|Appleworks|Archaeology|Bitdefender|Birkhauser|Britannica|[-._ ]C\+\+|C[-._ ](\+\+|Sharp|Plus)|Chemistry|Circuits|Cook(book|ing)|(Beginners?|Complete|Communications|Definitive|Essential|Hackers?|Practical|Professionals?)[-._ ]Guide|Developer|Diagnostic|Disassembl(er|ing|y)|Debugg(er|ing)|Dreamweaver|Economics|Education|Electronics|Enc(i|y)clopedia|Engineer(ing|s)|Essays|Exercizes|For.+Beginners|Focal[-._ ]Press|For[-._ ]Dummies|FreeBSD|Fundamentals[-._ ]of[-._ ]|(Galileo|Island)[-._ ]Press|Geography|Grammar|Guide[-._ ](For|To)|Hacking|Google|Handboo?k|How[-._ ](It|To)|Intoduction[-._ ]to|Iphone|jQuery|Lessons[-._ ]In|Learning|LibreOffice|Linux|Manual|Marketing|Masonry|Mathematic(al|s)?|Medical|Microsoft|National[-._ ]Academies|Nero[-._ ]\d+|OReilly|OS[-._ ]X[-._ ]|Official[-._ ]Guide|Open(GL|Office)|Pediatric|Periodic.+Table|Photoshop|Physics|Power(PC|Point|Shell)|Programm(ers?|ier||ing)|Raspberry.+Pi|Remedies|Service\s?Manual|SitePoint|Sketching|Statistics|Stock.+Market|Students|Theory|Training|Tutsplus|Ubuntu|Understanding[-._ ](and|Of|The)|Visual[-._ ]Studio|Textbook|VMWare|wii?max|Windows[-._ ](8|7|Vista|XP)|^Wood[-._ ]|Woodwork|WordPress|Work(book|shop)|Youtube/i', $this->releaseName): |
||
1794 | return false; |
||
1795 | case $this->isBookForeign(): |
||
1796 | break; |
||
1797 | default: |
||
1798 | $this->tmpCat = Category::BOOKS_TECHNICAL; |
||
1799 | break; |
||
1800 | } |
||
1801 | |||
1802 | return true; |
||
1803 | } |
||
1804 | |||
1805 | /** |
||
1806 | * @return bool |
||
1807 | */ |
||
1808 | public function isMagazine(): bool |
||
1809 | { |
||
1810 | switch (true) { |
||
1811 | case ! preg_match('/[a-z\-\._ ][-._ ](January|February|March|April|May|June|July|August|September|October|November|December)[-._ ](\d{1,2},)?20\d\d[-._ ]|^\(.+[ .]\d{1,2}[ .]20\d\d[ .].+\.scr|[-._ ](Catalogue|FHM|NUTS|Pictorial|Tatler|XXX)[-._ ]|^\(?(Allehanda|Club|Computer([a-z0-9]+)?|Connect \d+|Corriere|ct|Diario|Digit(al)?|Esquire|FHM|Gadgets|Galileo|Glam|GQ|Infosat|Inked|Instyle|io|Kicker|Liberation|New Scientist|NGV|Nuts|Popular|Professional|Reise|Sette(tv)?|Springer|Stuff|Studentlitteratur|Vegetarian|Vegetable|Videomarkt|Wired)[-._ ]|Brady(.+)?Games|Catalog|Columbus.+Dispatch|Correspondenten|Corriere[-._ ]Della[-._ ]Sera|Cosmopolitan|Dagbladet|Digital[-._ ]Guide|Economist|Eload ?24|ExtraTime|Fatto[-._ ]Quotidiano|Flight[-._ ](International|Journal)|Finanzwoche|France.+Football|Foto.+Video|Games?(Master|Markt|tar|TM)|Gardening|Gazzetta|Globe[-._ ]And[-._ ]Mail|Guitar|Heimkino|Hustler|La.+(Lettura|Rblica|Stampa)|Le[-._ ](Monde|Temps)|Les[-._ ]Echos|e?Magazin(es?)?|Mac(life|welt)|Marie.+Claire|Maxim|Men.+(Health|Fitness)|Motocross|Motorcycle|Mountain[-._ ]Bike|MusikWoche|National[-._ ]Geographic|New[-._ ]Yorker|PC([-._ ](Gamer|Welt|World)|Games|Go|Tip)|Penthouse|Photograph(er|ic)|Playboy|Posten|Quotidiano|(Golf|Readers?).+Digest|SFX[-._ ]UK|Recipe(.+Guide|s)|SkyNews|Sport[-._ ]?Week|Strategy.+Guide|TabletPC|Tattoo[-._ ]Life|The[-._ ]Guardian|Tageszeitung|Tid(bits|ning)|Top[-._ ]Gear[-._ ]|Total[-._ ]Guitar|Travel[-._ ]Guides?|Tribune[-._ ]De[-._ ]|US[-._ ]Weekly|USA[-._ ]Today|TruePDF|Vogue|Verlag|Warcraft|Web.+Designer|What[-._ ]Car|Zeitung/i', $this->releaseName): |
||
1812 | return false; |
||
1813 | case $this->isBookForeign(): |
||
1814 | break; |
||
1815 | default: |
||
1816 | $this->tmpCat = Category::BOOKS_MAGAZINES; |
||
1817 | break; |
||
1818 | } |
||
1819 | |||
1820 | return true; |
||
1821 | } |
||
1822 | |||
1823 | /** |
||
1824 | * @return bool |
||
1825 | */ |
||
1826 | public function isBookOther(): bool |
||
1827 | { |
||
1828 | if (preg_match('/"\d\d-\d\d-20\d\d\./i', $this->releaseName)) { |
||
1829 | $this->tmpCat = Category::BOOKS_UNKNOWN; |
||
1830 | |||
1831 | return true; |
||
1832 | } |
||
1833 | |||
1834 | return false; |
||
1835 | } |
||
1836 | |||
1837 | /** |
||
1838 | * @return bool |
||
1839 | */ |
||
1840 | public function isEBook(): bool |
||
1841 | { |
||
1842 | switch (true) { |
||
1843 | case ! preg_match('/^ePub|[-._ ](Ebook|E?\-book|\) WW|Publishing)|[\.\-_\(\[ ](azw|epub|html|mobi|pdf|rtf|tif|txt)[\.\-_\)\] ]|[\. ](azw|doc|epub|mobi|pdf)(?![\w .])|\.ebook-\w$/i', $this->releaseName): |
||
1844 | return false; |
||
1845 | case $this->isBookForeign(): |
||
1846 | break; |
||
1847 | default: |
||
1848 | $this->tmpCat = Category::BOOKS_EBOOK; |
||
1849 | break; |
||
1850 | } |
||
1851 | |||
1852 | return true; |
||
1853 | } |
||
1854 | |||
1855 | // Misc, all hash/misc go in other misc. |
||
1856 | |||
1857 | /** |
||
1858 | * @return bool |
||
1859 | */ |
||
1860 | public function isMisc(): bool |
||
1877 | } |
||
1878 | |||
1879 | /** |
||
1880 | * @param string $regex Regex to use for match |
||
1881 | * @param string $fromName Poster that needs to be matched by regex |
||
1882 | * @param string $category Category to set if there is a match |
||
1883 | * |
||
1884 | * @return bool |
||
1885 | */ |
||
1886 | public function checkPoster($regex, $fromName, $category): bool |
||
1887 | { |
||
1888 | if (preg_match($regex, $fromName)) { |
||
1889 | $this->tmpCat = $category; |
||
1890 | |||
1891 | return true; |
||
1892 | } |
||
1893 | |||
1894 | return false; |
||
1895 | } |
||
1896 | } |
||
1897 |
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.