@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | protected function buildFullLayout(): bool |
| 41 | 41 | { |
| 42 | 42 | // Window 0: Monitor + Binaries + Backfill + Releases |
| 43 | - if (! $this->sessionManager->createSession('Monitor')) { |
|
| 43 | + if (!$this->sessionManager->createSession('Monitor')) { |
|
| 44 | 44 | return false; |
| 45 | 45 | } |
| 46 | 46 | |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | protected function buildBasicLayout(): bool |
| 94 | 94 | { |
| 95 | 95 | // Window 0: Monitor + Releases |
| 96 | - if (! $this->sessionManager->createSession('Monitor')) { |
|
| 96 | + if (!$this->sessionManager->createSession('Monitor')) { |
|
| 97 | 97 | return false; |
| 98 | 98 | } |
| 99 | 99 | |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | protected function buildStrippedLayout(): bool |
| 139 | 139 | { |
| 140 | 140 | // Window 0: Monitor + Sequential |
| 141 | - if (! $this->sessionManager->createSession('Monitor')) { |
|
| 141 | + if (!$this->sessionManager->createSession('Monitor')) { |
|
| 142 | 142 | return false; |
| 143 | 143 | } |
| 144 | 144 | |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | $this->paneManager->createWindow($windowIndex, 'redis'); |
| 243 | 243 | |
| 244 | 244 | // Check if custom args provided for simple redis-cli output |
| 245 | - if (! empty($redisArgs) && $redisArgs !== 'NULL') { |
|
| 245 | + if (!empty($redisArgs) && $redisArgs !== 'NULL') { |
|
| 246 | 246 | $this->paneManager->respawnPane("{$windowIndex}.0", "watch -n{$refreshInterval} -c 'redis-cli -h {$redisHost} -p {$redisPort} {$redisArgs}'"); |
| 247 | 247 | } else { |
| 248 | 248 | // Use modern visual monitoring script |
@@ -47,7 +47,7 @@ |
||
| 47 | 47 | if (preg_match('/^(\d+)\.jpg$/', $filename, $matches)) { |
| 48 | 48 | $anidbid = $matches[1]; |
| 49 | 49 | $newFilename = "{$anidbid}-cover.jpg"; |
| 50 | - $newPath = $animeCoverPath . $newFilename; |
|
| 50 | + $newPath = $animeCoverPath.$newFilename; |
|
| 51 | 51 | |
| 52 | 52 | // Skip if new format already exists |
| 53 | 53 | if (file_exists($newPath)) { |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | use Symfony\Component\Process\Process; |
| 16 | 16 | use Zip as ZipStream; |
| 17 | 17 | |
| 18 | -if (! function_exists('getRawHtml')) { |
|
| 18 | +if (!function_exists('getRawHtml')) { |
|
| 19 | 19 | /** |
| 20 | 20 | * @param bool $cookie |
| 21 | 21 | * @return bool|mixed|string |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | } |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | -if (! function_exists('makeFieldLinks')) { |
|
| 109 | +if (!function_exists('makeFieldLinks')) { |
|
| 110 | 110 | /** |
| 111 | 111 | * @return string |
| 112 | 112 | * |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | } |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | -if (! function_exists('getUserBrowseOrder')) { |
|
| 139 | +if (!function_exists('getUserBrowseOrder')) { |
|
| 140 | 140 | /** |
| 141 | 141 | * @param string $orderBy |
| 142 | 142 | */ |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | } |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | -if (! function_exists('getUserBrowseOrdering')) { |
|
| 165 | +if (!function_exists('getUserBrowseOrdering')) { |
|
| 166 | 166 | function getUserBrowseOrdering(): array |
| 167 | 167 | { |
| 168 | 168 | return [ |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | } |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | -if (! function_exists('getSimilarName')) { |
|
| 195 | +if (!function_exists('getSimilarName')) { |
|
| 196 | 196 | /** |
| 197 | 197 | * @param string $name |
| 198 | 198 | */ |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | } |
| 203 | 203 | } |
| 204 | 204 | |
| 205 | -if (! function_exists('human_filesize')) { |
|
| 205 | +if (!function_exists('human_filesize')) { |
|
| 206 | 206 | /** |
| 207 | 207 | * @param int $decimals |
| 208 | 208 | */ |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | } |
| 216 | 216 | } |
| 217 | 217 | |
| 218 | -if (! function_exists('bcdechex')) { |
|
| 218 | +if (!function_exists('bcdechex')) { |
|
| 219 | 219 | /** |
| 220 | 220 | * @return string |
| 221 | 221 | */ |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | } |
| 233 | 233 | } |
| 234 | 234 | |
| 235 | -if (! function_exists('runCmd')) { |
|
| 235 | +if (!function_exists('runCmd')) { |
|
| 236 | 236 | /** |
| 237 | 237 | * Run CLI command. |
| 238 | 238 | * |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | } |
| 261 | 261 | } |
| 262 | 262 | |
| 263 | -if (! function_exists('escapeString')) { |
|
| 263 | +if (!function_exists('escapeString')) { |
|
| 264 | 264 | |
| 265 | 265 | function escapeString($string): string |
| 266 | 266 | { |
@@ -268,7 +268,7 @@ discard block |
||
| 268 | 268 | } |
| 269 | 269 | } |
| 270 | 270 | |
| 271 | -if (! function_exists('realDuration')) { |
|
| 271 | +if (!function_exists('realDuration')) { |
|
| 272 | 272 | |
| 273 | 273 | function realDuration($milliseconds): string |
| 274 | 274 | { |
@@ -278,7 +278,7 @@ discard block |
||
| 278 | 278 | } |
| 279 | 279 | } |
| 280 | 280 | |
| 281 | -if (! function_exists('is_it_json')) { |
|
| 281 | +if (!function_exists('is_it_json')) { |
|
| 282 | 282 | /** |
| 283 | 283 | * @throws JsonException |
| 284 | 284 | */ |
@@ -293,7 +293,7 @@ discard block |
||
| 293 | 293 | } |
| 294 | 294 | } |
| 295 | 295 | |
| 296 | -if (! function_exists('getStreamingZip')) { |
|
| 296 | +if (!function_exists('getStreamingZip')) { |
|
| 297 | 297 | /** |
| 298 | 298 | * @throws Exception |
| 299 | 299 | */ |
@@ -320,7 +320,7 @@ discard block |
||
| 320 | 320 | } |
| 321 | 321 | } |
| 322 | 322 | |
| 323 | -if (! function_exists('release_flag')) { |
|
| 323 | +if (!function_exists('release_flag')) { |
|
| 324 | 324 | // Function inspired by c0r3@newznabforums adds country flags on the browse page. |
| 325 | 325 | /** |
| 326 | 326 | * @param string $text Text to match against. |
@@ -457,7 +457,7 @@ discard block |
||
| 457 | 457 | } |
| 458 | 458 | } |
| 459 | 459 | |
| 460 | -if (! function_exists('getReleaseCover')) { |
|
| 460 | +if (!function_exists('getReleaseCover')) { |
|
| 461 | 461 | /** |
| 462 | 462 | * Get the cover image URL for a release based on its type and ID |
| 463 | 463 | * |
@@ -470,7 +470,7 @@ discard block |
||
| 470 | 470 | $coverId = null; |
| 471 | 471 | |
| 472 | 472 | // Helper function to get value from object or array |
| 473 | - $getValue = function ($data, $key) { |
|
| 473 | + $getValue = function($data, $key) { |
|
| 474 | 474 | if (is_array($data)) { |
| 475 | 475 | return $data[$key] ?? null; |
| 476 | 476 | } elseif (is_object($data)) { |
@@ -489,25 +489,25 @@ discard block |
||
| 489 | 489 | $xxxinfo_id = $getValue($release, 'xxxinfo_id'); |
| 490 | 490 | $anidbid = $getValue($release, 'anidbid'); |
| 491 | 491 | |
| 492 | - if (! empty($imdbid) && $imdbid > 0) { |
|
| 492 | + if (!empty($imdbid) && $imdbid > 0) { |
|
| 493 | 493 | $coverType = 'movies'; |
| 494 | 494 | $coverId = str_pad($imdbid, 7, '0', STR_PAD_LEFT); |
| 495 | - } elseif (! empty($musicinfo_id)) { |
|
| 495 | + } elseif (!empty($musicinfo_id)) { |
|
| 496 | 496 | $coverType = 'music'; |
| 497 | 497 | $coverId = $musicinfo_id; |
| 498 | - } elseif (! empty($consoleinfo_id)) { |
|
| 498 | + } elseif (!empty($consoleinfo_id)) { |
|
| 499 | 499 | $coverType = 'console'; |
| 500 | 500 | $coverId = $consoleinfo_id; |
| 501 | - } elseif (! empty($bookinfo_id)) { |
|
| 501 | + } elseif (!empty($bookinfo_id)) { |
|
| 502 | 502 | $coverType = 'book'; |
| 503 | 503 | $coverId = $bookinfo_id; |
| 504 | - } elseif (! empty($gamesinfo_id)) { |
|
| 504 | + } elseif (!empty($gamesinfo_id)) { |
|
| 505 | 505 | $coverType = 'games'; |
| 506 | 506 | $coverId = $gamesinfo_id; |
| 507 | - } elseif (! empty($xxxinfo_id)) { |
|
| 507 | + } elseif (!empty($xxxinfo_id)) { |
|
| 508 | 508 | $coverType = 'xxx'; |
| 509 | 509 | $coverId = $xxxinfo_id; |
| 510 | - } elseif (! empty($anidbid) && $anidbid > 0) { |
|
| 510 | + } elseif (!empty($anidbid) && $anidbid > 0) { |
|
| 511 | 511 | $coverType = 'anime'; |
| 512 | 512 | $coverId = $anidbid; |
| 513 | 513 | } |
@@ -523,10 +523,10 @@ discard block |
||
| 523 | 523 | } |
| 524 | 524 | } |
| 525 | 525 | |
| 526 | -if (! function_exists('sanitize')) { |
|
| 526 | +if (!function_exists('sanitize')) { |
|
| 527 | 527 | function sanitize(array|string $phrases, array $doNotSanitize = []): string |
| 528 | 528 | { |
| 529 | - if (! is_array($phrases)) { |
|
| 529 | + if (!is_array($phrases)) { |
|
| 530 | 530 | $wordArray = explode(' ', str_replace('.', ' ', $phrases)); |
| 531 | 531 | } else { |
| 532 | 532 | $wordArray = $phrases; |
@@ -537,9 +537,9 @@ discard block |
||
| 537 | 537 | foreach ($wordArray as $words) { |
| 538 | 538 | $words = preg_split('/\s+/', $words); |
| 539 | 539 | foreach ($words as $st) { |
| 540 | - if (Str::startsWith($st, ['!', '+', '-', '?', '*']) && Str::length($st) > 1 && ! preg_match('/([!+?\-*]){2,}/', $st)) { |
|
| 540 | + if (Str::startsWith($st, ['!', '+', '-', '?', '*']) && Str::length($st) > 1 && !preg_match('/([!+?\-*]){2,}/', $st)) { |
|
| 541 | 541 | $str = $st; |
| 542 | - } elseif (Str::endsWith($st, ['+', '-', '?', '*']) && Str::length($st) > 1 && ! preg_match('/([!+?\-*]){2,}/', $st)) { |
|
| 542 | + } elseif (Str::endsWith($st, ['+', '-', '?', '*']) && Str::length($st) > 1 && !preg_match('/([!+?\-*]){2,}/', $st)) { |
|
| 543 | 543 | $str = $st; |
| 544 | 544 | } else { |
| 545 | 545 | $str = Sanitizer::escape($st, $doNotSanitize); |
@@ -554,7 +554,7 @@ discard block |
||
| 554 | 554 | } |
| 555 | 555 | } |
| 556 | 556 | |
| 557 | -if (! function_exists('formatBytes')) { |
|
| 557 | +if (!function_exists('formatBytes')) { |
|
| 558 | 558 | /** |
| 559 | 559 | * Format bytes into human-readable file size. |
| 560 | 560 | * |
@@ -573,7 +573,7 @@ discard block |
||
| 573 | 573 | } |
| 574 | 574 | } |
| 575 | 575 | |
| 576 | -if (! function_exists('csp_nonce')) { |
|
| 576 | +if (!function_exists('csp_nonce')) { |
|
| 577 | 577 | /** |
| 578 | 578 | * Generate a CSP nonce for inline scripts |
| 579 | 579 | * This should be stored in the request and reused across the request lifecycle |
@@ -590,7 +590,7 @@ discard block |
||
| 590 | 590 | } |
| 591 | 591 | } |
| 592 | 592 | |
| 593 | -if (! function_exists('userDate')) { |
|
| 593 | +if (!function_exists('userDate')) { |
|
| 594 | 594 | /** |
| 595 | 595 | * Format a date/time string according to the authenticated user's timezone |
| 596 | 596 | * |
@@ -622,7 +622,7 @@ discard block |
||
| 622 | 622 | } |
| 623 | 623 | } |
| 624 | 624 | |
| 625 | -if (! function_exists('userDateDiffForHumans')) { |
|
| 625 | +if (!function_exists('userDateDiffForHumans')) { |
|
| 626 | 626 | /** |
| 627 | 627 | * Format a date/time string as a human-readable diff according to the authenticated user's timezone |
| 628 | 628 | * |
@@ -653,7 +653,7 @@ discard block |
||
| 653 | 653 | } |
| 654 | 654 | } |
| 655 | 655 | |
| 656 | -if (! function_exists('getAvailableTimezones')) { |
|
| 656 | +if (!function_exists('getAvailableTimezones')) { |
|
| 657 | 657 | /** |
| 658 | 658 | * Get a list of available timezones grouped by region |
| 659 | 659 | * |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | foreach ($chunks as $chunk) { |
| 121 | 121 | foreach ($chunk as $release) { |
| 122 | 122 | $searchname = $release->searchname ?? ''; |
| 123 | - $progressBar->setMessage("Processing: " . substr($searchname, 0, 50) . "..."); |
|
| 123 | + $progressBar->setMessage("Processing: ".substr($searchname, 0, 50)."..."); |
|
| 124 | 124 | |
| 125 | 125 | try { |
| 126 | 126 | // Extract clean title from searchname |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | |
| 147 | 147 | // Check if we should skip (if not forcing and data exists) |
| 148 | 148 | // Don't skip if we're retrying failed releases (anidbid <= 0) |
| 149 | - if (! $force && ! $missingOnly && ! $retryFailed) { |
|
| 149 | + if (!$force && !$missingOnly && !$retryFailed) { |
|
| 150 | 150 | // Check if release already has complete AniList data |
| 151 | 151 | if ($release->anidbid > 0) { |
| 152 | 152 | $anidbInfo = DB::table('anidb_info') |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | $this->enforceRateLimit(); |
| 170 | 170 | $searchResults = $populateAniList->searchAnime($cleanTitle, 1); |
| 171 | 171 | |
| 172 | - if (! $searchResults || empty($searchResults)) { |
|
| 172 | + if (!$searchResults || empty($searchResults)) { |
|
| 173 | 173 | // Try with spaces replaced for broader matching |
| 174 | 174 | $altTitle = preg_replace('/\s+/', ' ', $cleanTitle); |
| 175 | 175 | if ($altTitle !== $cleanTitle) { |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | } |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | - if (! $searchResults || empty($searchResults)) { |
|
| 181 | + if (!$searchResults || empty($searchResults)) { |
|
| 182 | 182 | $notFound++; |
| 183 | 183 | $failedSearchnames[] = [ |
| 184 | 184 | 'searchname' => $searchname, |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | $anilistData = $searchResults[0]; |
| 200 | 200 | $anilistId = $anilistData['id'] ?? null; |
| 201 | 201 | |
| 202 | - if (! $anilistId) { |
|
| 202 | + if (!$anilistId) { |
|
| 203 | 203 | $notFound++; |
| 204 | 204 | $failedSearchnames[] = [ |
| 205 | 205 | 'searchname' => $searchname, |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | ->where('anilist_id', $anilistId) |
| 228 | 228 | ->value('anidbid'); |
| 229 | 229 | |
| 230 | - if (! $anidbid) { |
|
| 230 | + if (!$anidbid) { |
|
| 231 | 231 | // Fallback: use anilist_id as anidbid |
| 232 | 232 | $anidbid = (int) $anilistId; |
| 233 | 233 | } |
@@ -271,7 +271,7 @@ discard block |
||
| 271 | 271 | $this->line(" - {$item['searchname']} -> {$cleanedTitle} ({$item['reason']})"); |
| 272 | 272 | } |
| 273 | 273 | if (count($failedSearchnames) > 10) { |
| 274 | - $this->line(" ... and " . (count($failedSearchnames) - 10) . " more."); |
|
| 274 | + $this->line(" ... and ".(count($failedSearchnames) - 10)." more."); |
|
| 275 | 275 | } |
| 276 | 276 | } |
| 277 | 277 | |
@@ -281,7 +281,7 @@ discard block |
||
| 281 | 281 | $failed++; |
| 282 | 282 | if ($this->getOutput()->isVerbose()) { |
| 283 | 283 | $this->newLine(); |
| 284 | - $this->error("Error processing release ID {$release->id}: " . $e->getMessage()); |
|
| 284 | + $this->error("Error processing release ID {$release->id}: ".$e->getMessage()); |
|
| 285 | 285 | } |
| 286 | 286 | } |
| 287 | 287 | |
@@ -319,8 +319,8 @@ discard block |
||
| 319 | 319 | foreach ($examples as $item) { |
| 320 | 320 | $cleanedTitle = $item['cleaned_title'] ?? '(extraction failed)'; |
| 321 | 321 | $rows[] = [ |
| 322 | - substr($item['searchname'], 0, 60) . (strlen($item['searchname']) > 60 ? '...' : ''), |
|
| 323 | - substr($cleanedTitle, 0, 40) . (strlen($cleanedTitle) > 40 ? '...' : ''), |
|
| 322 | + substr($item['searchname'], 0, 60).(strlen($item['searchname']) > 60 ? '...' : ''), |
|
| 323 | + substr($cleanedTitle, 0, 40).(strlen($cleanedTitle) > 40 ? '...' : ''), |
|
| 324 | 324 | $item['reason'], |
| 325 | 325 | ]; |
| 326 | 326 | } |
@@ -331,7 +331,7 @@ discard block |
||
| 331 | 331 | ); |
| 332 | 332 | |
| 333 | 333 | if (count($failedSearchnames) > 20) { |
| 334 | - $this->line("... and " . (count($failedSearchnames) - 20) . " more. Use --verbose to see all."); |
|
| 334 | + $this->line("... and ".(count($failedSearchnames) - 20)." more. Use --verbose to see all."); |
|
| 335 | 335 | } |
| 336 | 336 | } |
| 337 | 337 | |
@@ -467,7 +467,7 @@ discard block |
||
| 467 | 467 | $now = time(); |
| 468 | 468 | |
| 469 | 469 | // Clean old timestamps (older than 1 minute) |
| 470 | - $this->requestTimestamps = array_filter($this->requestTimestamps, function ($timestamp) use ($now) { |
|
| 470 | + $this->requestTimestamps = array_filter($this->requestTimestamps, function($timestamp) use ($now) { |
|
| 471 | 471 | return ($now - $timestamp) < 60; |
| 472 | 472 | }); |
| 473 | 473 | |
@@ -476,20 +476,20 @@ discard block |
||
| 476 | 476 | // If we're at or over the limit, wait |
| 477 | 477 | if ($requestCount >= self::RATE_LIMIT_PER_MINUTE) { |
| 478 | 478 | // Calculate wait time based on oldest request |
| 479 | - if (! empty($this->requestTimestamps)) { |
|
| 479 | + if (!empty($this->requestTimestamps)) { |
|
| 480 | 480 | $oldestRequest = min($this->requestTimestamps); |
| 481 | 481 | $waitTime = 60 - ($now - $oldestRequest) + 1; // +1 for safety margin |
| 482 | 482 | |
| 483 | 483 | if ($waitTime > 0 && $waitTime <= 60) { |
| 484 | 484 | if ($this->getOutput()->isVerbose()) { |
| 485 | 485 | $this->newLine(); |
| 486 | - $this->warn("Rate limit reached ({$requestCount}/" . self::RATE_LIMIT_PER_MINUTE . "). Waiting {$waitTime} seconds..."); |
|
| 486 | + $this->warn("Rate limit reached ({$requestCount}/".self::RATE_LIMIT_PER_MINUTE."). Waiting {$waitTime} seconds..."); |
|
| 487 | 487 | } |
| 488 | 488 | sleep($waitTime); |
| 489 | 489 | |
| 490 | 490 | // Clean timestamps again after waiting |
| 491 | 491 | $now = time(); |
| 492 | - $this->requestTimestamps = array_filter($this->requestTimestamps, function ($timestamp) use ($now) { |
|
| 492 | + $this->requestTimestamps = array_filter($this->requestTimestamps, function($timestamp) use ($now) { |
|
| 493 | 493 | return ($now - $timestamp) < 60; |
| 494 | 494 | }); |
| 495 | 495 | } |
@@ -501,7 +501,7 @@ discard block |
||
| 501 | 501 | $minDelay = 60.0 / self::RATE_LIMIT_PER_MINUTE; |
| 502 | 502 | |
| 503 | 503 | // If we have recent requests, ensure we wait at least the minimum delay |
| 504 | - if (! empty($this->requestTimestamps)) { |
|
| 504 | + if (!empty($this->requestTimestamps)) { |
|
| 505 | 505 | $lastRequest = max($this->requestTimestamps); |
| 506 | 506 | $timeSinceLastRequest = $now - $lastRequest; |
| 507 | 507 | |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | */ |
| 40 | 40 | public function isConfigured(): bool |
| 41 | 41 | { |
| 42 | - return ! empty($this->apiKey); |
|
| 42 | + return !empty($this->apiKey); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | /** |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | */ |
| 52 | 52 | protected function get(string $endpoint, array $params = []): ?array |
| 53 | 53 | { |
| 54 | - if (! $this->isConfigured()) { |
|
| 54 | + if (!$this->isConfigured()) { |
|
| 55 | 55 | Log::warning('TMDB API key is not configured'); |
| 56 | 56 | |
| 57 | 57 | return null; |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | { |
| 144 | 144 | $params = []; |
| 145 | 145 | |
| 146 | - if (! empty($appendToResponse)) { |
|
| 146 | + if (!empty($appendToResponse)) { |
|
| 147 | 147 | $params['append_to_response'] = implode(',', $appendToResponse); |
| 148 | 148 | } |
| 149 | 149 | |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | { |
| 211 | 211 | $params = []; |
| 212 | 212 | |
| 213 | - if (! empty($appendToResponse)) { |
|
| 213 | + if (!empty($appendToResponse)) { |
|
| 214 | 214 | $params['append_to_response'] = implode(',', $appendToResponse); |
| 215 | 215 | } |
| 216 | 216 | |
@@ -309,7 +309,7 @@ discard block |
||
| 309 | 309 | $value = $data; |
| 310 | 310 | |
| 311 | 311 | foreach ($keys as $key) { |
| 312 | - if (! is_array($value) || ! array_key_exists($key, $value)) { |
|
| 312 | + if (!is_array($value) || !array_key_exists($key, $value)) { |
|
| 313 | 313 | return $default; |
| 314 | 314 | } |
| 315 | 315 | $value = $value[$key]; |
@@ -15,7 +15,7 @@ |
||
| 15 | 15 | public function register(): void |
| 16 | 16 | { |
| 17 | 17 | // Register the pipeline as a singleton |
| 18 | - $this->app->singleton(CategorizationPipeline::class, function ($app) { |
|
| 18 | + $this->app->singleton(CategorizationPipeline::class, function($app) { |
|
| 19 | 19 | return CategorizationPipeline::createDefault(); |
| 20 | 20 | }); |
| 21 | 21 | |
@@ -85,7 +85,7 @@ |
||
| 85 | 85 | { |
| 86 | 86 | $categorizers = $this->pipeline->getCategorizers(); |
| 87 | 87 | |
| 88 | - return $categorizers->map(function ($categorizer) { |
|
| 88 | + return $categorizers->map(function($categorizer) { |
|
| 89 | 89 | return [ |
| 90 | 90 | 'name' => $categorizer->getName(), |
| 91 | 91 | 'priority' => $categorizer->getPriority(), |
@@ -38,9 +38,9 @@ discard block |
||
| 38 | 38 | protected function checkTechnical(string $name): ?CategorizationResult |
| 39 | 39 | { |
| 40 | 40 | $publishers = 'Apress|Addison[._ -]Wesley|Manning|No[._ -]Starch|OReilly|Packt|Pragmatic|Wiley|Wrox'; |
| 41 | - if (preg_match('/\b(' . $publishers . ')\b/i', $name)) return $this->matched(Category::BOOKS_TECHNICAL, 0.9, 'technical_publisher'); |
|
| 41 | + if (preg_match('/\b('.$publishers.')\b/i', $name)) return $this->matched(Category::BOOKS_TECHNICAL, 0.9, 'technical_publisher'); |
|
| 42 | 42 | $subjects = 'Programming|Python|JavaScript|Java|Database|Linux|DevOps|Machine[._ -]Learning|Data[._ -]Science'; |
| 43 | - if (preg_match('/\b(' . $subjects . ')\b/i', $name) && preg_match('/\b(Book|Guide|Tutorial|Learn)\b/i', $name)) { |
|
| 43 | + if (preg_match('/\b('.$subjects.')\b/i', $name) && preg_match('/\b(Book|Guide|Tutorial|Learn)\b/i', $name)) { |
|
| 44 | 44 | return $this->matched(Category::BOOKS_TECHNICAL, 0.85, 'technical_subject'); |
| 45 | 45 | } |
| 46 | 46 | return null; |
@@ -49,14 +49,14 @@ discard block |
||
| 49 | 49 | { |
| 50 | 50 | if (preg_match('/[._ -](Monthly|Weekly|Annual|Quarterly|Issue)[._ -]/i', $name)) return $this->matched(Category::BOOKS_MAGAZINES, 0.9, 'magazine_frequency'); |
| 51 | 51 | $magazines = 'Forbes|Fortune|GQ|National[._ -]Geographic|Newsweek|Time|Vogue|Wired|PC[._ -]Gamer'; |
| 52 | - if (preg_match('/\b(' . $magazines . ')\b/i', $name)) return $this->matched(Category::BOOKS_MAGAZINES, 0.85, 'magazine_title'); |
|
| 52 | + if (preg_match('/\b('.$magazines.')\b/i', $name)) return $this->matched(Category::BOOKS_MAGAZINES, 0.85, 'magazine_title'); |
|
| 53 | 53 | return null; |
| 54 | 54 | } |
| 55 | 55 | protected function checkEbook(string $name): ?CategorizationResult |
| 56 | 56 | { |
| 57 | 57 | $formats = 'EPUB|MOBI|AZW\d?|PDF|FB2|DJVU|LIT'; |
| 58 | - if (preg_match('/\.(' . $formats . ')$/i', $name)) return $this->matched(Category::BOOKS_EBOOK, 0.9, 'ebook_format'); |
|
| 59 | - if (preg_match('/\b(' . $formats . ')\b/i', $name)) return $this->matched(Category::BOOKS_EBOOK, 0.85, 'ebook_indicator'); |
|
| 58 | + if (preg_match('/\.('.$formats.')$/i', $name)) return $this->matched(Category::BOOKS_EBOOK, 0.9, 'ebook_format'); |
|
| 59 | + if (preg_match('/\b('.$formats.')\b/i', $name)) return $this->matched(Category::BOOKS_EBOOK, 0.85, 'ebook_indicator'); |
|
| 60 | 60 | if (preg_match('/\b(E-?book|Kindle|Kobo|Nook)\b/i', $name)) return $this->matched(Category::BOOKS_EBOOK, 0.8, 'ebook_platform'); |
| 61 | 61 | return null; |
| 62 | 62 | } |
@@ -9,36 +9,62 @@ discard block |
||
| 9 | 9 | public function getName(): string { return 'Book'; } |
| 10 | 10 | public function shouldSkip(ReleaseContext $context): bool |
| 11 | 11 | { |
| 12 | - if ($context->hasAdultMarkers()) return true; |
|
| 13 | - if (preg_match('/\.PS4-[A-Z0-9]+$/i', $context->releaseName)) return true; |
|
| 14 | - if (preg_match('/\b(?:PS[1-5]|PlayStation|Xbox|Switch|Nintendo|Wii|3DS|GameCube)\b/i', $context->releaseName)) return true; |
|
| 12 | + if ($context->hasAdultMarkers()) { |
|
| 13 | + return true; |
|
| 14 | + } |
|
| 15 | + if (preg_match('/\.PS4-[A-Z0-9]+$/i', $context->releaseName)) { |
|
| 16 | + return true; |
|
| 17 | + } |
|
| 18 | + if (preg_match('/\b(?:PS[1-5]|PlayStation|Xbox|Switch|Nintendo|Wii|3DS|GameCube)\b/i', $context->releaseName)) { |
|
| 19 | + return true; |
|
| 20 | + } |
|
| 15 | 21 | // Skip TV shows (season patterns) |
| 16 | - if (preg_match('/[._ -]S\d{1,3}[._ -]?(E\d|Complete|Full|1080|720|480|2160|WEB|HDTV|BluRay)/i', $context->releaseName)) return true; |
|
| 22 | + if (preg_match('/[._ -]S\d{1,3}[._ -]?(E\d|Complete|Full|1080|720|480|2160|WEB|HDTV|BluRay)/i', $context->releaseName)) { |
|
| 23 | + return true; |
|
| 24 | + } |
|
| 17 | 25 | // Skip movies (year + quality patterns) |
| 18 | - if (preg_match('/\b(19|20)\d{2}\b.*\b(1080p|720p|2160p|BluRay|WEB-DL|BDRip|DVDRip)\b/i', $context->releaseName)) return true; |
|
| 26 | + if (preg_match('/\b(19|20)\d{2}\b.*\b(1080p|720p|2160p|BluRay|WEB-DL|BDRip|DVDRip)\b/i', $context->releaseName)) { |
|
| 27 | + return true; |
|
| 28 | + } |
|
| 19 | 29 | return false; |
| 20 | 30 | } |
| 21 | 31 | public function categorize(ReleaseContext $context): CategorizationResult |
| 22 | 32 | { |
| 23 | 33 | $name = $context->releaseName; |
| 24 | - if ($result = $this->checkComic($name)) return $result; |
|
| 25 | - if ($result = $this->checkTechnical($name)) return $result; |
|
| 26 | - if ($result = $this->checkMagazine($name)) return $result; |
|
| 27 | - if ($result = $this->checkEbook($name)) return $result; |
|
| 34 | + if ($result = $this->checkComic($name)) { |
|
| 35 | + return $result; |
|
| 36 | + } |
|
| 37 | + if ($result = $this->checkTechnical($name)) { |
|
| 38 | + return $result; |
|
| 39 | + } |
|
| 40 | + if ($result = $this->checkMagazine($name)) { |
|
| 41 | + return $result; |
|
| 42 | + } |
|
| 43 | + if ($result = $this->checkEbook($name)) { |
|
| 44 | + return $result; |
|
| 45 | + } |
|
| 28 | 46 | return $this->noMatch(); |
| 29 | 47 | } |
| 30 | 48 | protected function checkComic(string $name): ?CategorizationResult |
| 31 | 49 | { |
| 32 | - if (preg_match('/\b(?:CBR|CBZ|C2C)\b|\.(?:cbr|cbz)$/i', $name)) return $this->matched(Category::BOOKS_COMICS, 0.9, 'comic_format'); |
|
| 50 | + if (preg_match('/\b(?:CBR|CBZ|C2C)\b|\.(?:cbr|cbz)$/i', $name)) { |
|
| 51 | + return $this->matched(Category::BOOKS_COMICS, 0.9, 'comic_format'); |
|
| 52 | + } |
|
| 33 | 53 | if (preg_match('/\b(?:Marvel|DC[._ -]Comics|Image[._ -]Comics|Dark[._ -]Horse|IDW)\b/i', $name) && |
| 34 | - preg_match('/\b(?:Comics?|Annual|Issue|Vol|TPB)\b/i', $name)) return $this->matched(Category::BOOKS_COMICS, 0.85, 'comic_publisher'); |
|
| 35 | - if (preg_match('/\b(?:Manga|Manhwa|Manhua|Webtoon)\b/i', $name)) return $this->matched(Category::BOOKS_COMICS, 0.85, 'manga'); |
|
| 54 | + preg_match('/\b(?:Comics?|Annual|Issue|Vol|TPB)\b/i', $name)) { |
|
| 55 | + return $this->matched(Category::BOOKS_COMICS, 0.85, 'comic_publisher'); |
|
| 56 | + } |
|
| 57 | + if (preg_match('/\b(?:Manga|Manhwa|Manhua|Webtoon)\b/i', $name)) { |
|
| 58 | + return $this->matched(Category::BOOKS_COMICS, 0.85, 'manga'); |
|
| 59 | + } |
|
| 36 | 60 | return null; |
| 37 | 61 | } |
| 38 | 62 | protected function checkTechnical(string $name): ?CategorizationResult |
| 39 | 63 | { |
| 40 | 64 | $publishers = 'Apress|Addison[._ -]Wesley|Manning|No[._ -]Starch|OReilly|Packt|Pragmatic|Wiley|Wrox'; |
| 41 | - if (preg_match('/\b(' . $publishers . ')\b/i', $name)) return $this->matched(Category::BOOKS_TECHNICAL, 0.9, 'technical_publisher'); |
|
| 65 | + if (preg_match('/\b(' . $publishers . ')\b/i', $name)) { |
|
| 66 | + return $this->matched(Category::BOOKS_TECHNICAL, 0.9, 'technical_publisher'); |
|
| 67 | + } |
|
| 42 | 68 | $subjects = 'Programming|Python|JavaScript|Java|Database|Linux|DevOps|Machine[._ -]Learning|Data[._ -]Science'; |
| 43 | 69 | if (preg_match('/\b(' . $subjects . ')\b/i', $name) && preg_match('/\b(Book|Guide|Tutorial|Learn)\b/i', $name)) { |
| 44 | 70 | return $this->matched(Category::BOOKS_TECHNICAL, 0.85, 'technical_subject'); |
@@ -47,17 +73,27 @@ discard block |
||
| 47 | 73 | } |
| 48 | 74 | protected function checkMagazine(string $name): ?CategorizationResult |
| 49 | 75 | { |
| 50 | - if (preg_match('/[._ -](Monthly|Weekly|Annual|Quarterly|Issue)[._ -]/i', $name)) return $this->matched(Category::BOOKS_MAGAZINES, 0.9, 'magazine_frequency'); |
|
| 76 | + if (preg_match('/[._ -](Monthly|Weekly|Annual|Quarterly|Issue)[._ -]/i', $name)) { |
|
| 77 | + return $this->matched(Category::BOOKS_MAGAZINES, 0.9, 'magazine_frequency'); |
|
| 78 | + } |
|
| 51 | 79 | $magazines = 'Forbes|Fortune|GQ|National[._ -]Geographic|Newsweek|Time|Vogue|Wired|PC[._ -]Gamer'; |
| 52 | - if (preg_match('/\b(' . $magazines . ')\b/i', $name)) return $this->matched(Category::BOOKS_MAGAZINES, 0.85, 'magazine_title'); |
|
| 80 | + if (preg_match('/\b(' . $magazines . ')\b/i', $name)) { |
|
| 81 | + return $this->matched(Category::BOOKS_MAGAZINES, 0.85, 'magazine_title'); |
|
| 82 | + } |
|
| 53 | 83 | return null; |
| 54 | 84 | } |
| 55 | 85 | protected function checkEbook(string $name): ?CategorizationResult |
| 56 | 86 | { |
| 57 | 87 | $formats = 'EPUB|MOBI|AZW\d?|PDF|FB2|DJVU|LIT'; |
| 58 | - if (preg_match('/\.(' . $formats . ')$/i', $name)) return $this->matched(Category::BOOKS_EBOOK, 0.9, 'ebook_format'); |
|
| 59 | - if (preg_match('/\b(' . $formats . ')\b/i', $name)) return $this->matched(Category::BOOKS_EBOOK, 0.85, 'ebook_indicator'); |
|
| 60 | - if (preg_match('/\b(E-?book|Kindle|Kobo|Nook)\b/i', $name)) return $this->matched(Category::BOOKS_EBOOK, 0.8, 'ebook_platform'); |
|
| 88 | + if (preg_match('/\.(' . $formats . ')$/i', $name)) { |
|
| 89 | + return $this->matched(Category::BOOKS_EBOOK, 0.9, 'ebook_format'); |
|
| 90 | + } |
|
| 91 | + if (preg_match('/\b(' . $formats . ')\b/i', $name)) { |
|
| 92 | + return $this->matched(Category::BOOKS_EBOOK, 0.85, 'ebook_indicator'); |
|
| 93 | + } |
|
| 94 | + if (preg_match('/\b(E-?book|Kindle|Kobo|Nook)\b/i', $name)) { |
|
| 95 | + return $this->matched(Category::BOOKS_EBOOK, 0.8, 'ebook_platform'); |
|
| 96 | + } |
|
| 61 | 97 | return null; |
| 62 | 98 | } |
| 63 | 99 | } |
@@ -10,14 +10,30 @@ |
||
| 10 | 10 | public function categorize(ReleaseContext $context): CategorizationResult |
| 11 | 11 | { |
| 12 | 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'); |
|
| 13 | + if (empty($groupName)) { |
|
| 14 | + return $this->noMatch(); |
|
| 15 | + } |
|
| 16 | + if (preg_match('/alt\.binaries\..*?(tv|hdtv|tvseries)/i', $groupName)) { |
|
| 17 | + return $this->matched(Category::TV_OTHER, 0.6, 'group_tv'); |
|
| 18 | + } |
|
| 19 | + if (preg_match('/alt\.binaries\..*?(movies?|dvd|bluray|x264)/i', $groupName)) { |
|
| 20 | + return $this->matched(Category::MOVIE_OTHER, 0.6, 'group_movie'); |
|
| 21 | + } |
|
| 22 | + if (preg_match('/alt\.binaries\..*?(erotica|pictures\.erotica|xxx)/i', $groupName)) { |
|
| 23 | + return $this->matched(Category::XXX_OTHER, 0.7, 'group_xxx'); |
|
| 24 | + } |
|
| 25 | + if (preg_match('/alt\.binaries\..*?(sounds?|mp3|music|lossless)/i', $groupName)) { |
|
| 26 | + return $this->matched(Category::MUSIC_OTHER, 0.6, 'group_music'); |
|
| 27 | + } |
|
| 28 | + if (preg_match('/alt\.binaries\..*?(games?|console|psx|nintendo)/i', $groupName)) { |
|
| 29 | + return $this->matched(Category::GAME_OTHER, 0.6, 'group_game'); |
|
| 30 | + } |
|
| 31 | + if (preg_match('/alt\.binaries\..*?(warez|0day|apps?|software)/i', $groupName)) { |
|
| 32 | + return $this->matched(Category::PC_0DAY, 0.6, 'group_pc'); |
|
| 33 | + } |
|
| 34 | + if (preg_match('/alt\.binaries\..*?(e-?book|ebook|comics?)/i', $groupName)) { |
|
| 35 | + return $this->matched(Category::BOOKS_EBOOK, 0.6, 'group_book'); |
|
| 36 | + } |
|
| 21 | 37 | return $this->noMatch(); |
| 22 | 38 | } |
| 23 | 39 | } |