NNTmux /
newznab-tmux
| 1 | <?php |
||||
| 2 | |||||
| 3 | namespace App\Console\Commands; |
||||
| 4 | |||||
| 5 | use App\Services\NameFixing\NameFixingService; |
||||
| 6 | use Blacklight\NNTP; |
||||
| 7 | use Illuminate\Console\Command; |
||||
| 8 | |||||
| 9 | class FixReleaseNames extends Command |
||||
| 10 | { |
||||
| 11 | /** |
||||
| 12 | * The name and signature of the console command. |
||||
| 13 | * |
||||
| 14 | * @var string |
||||
| 15 | */ |
||||
| 16 | protected $signature = 'releases:fix-names |
||||
| 17 | {method : The method number (3-20) to use for fixing names} |
||||
| 18 | {--update : Actually update the names, otherwise just display results} |
||||
| 19 | {--category=other : Category to process: "other", "all", or "predb_id"} |
||||
| 20 | {--set-status : Set releases as checked after processing} |
||||
| 21 | {--show : Display detailed release changes rather than just counters}'; |
||||
| 22 | |||||
| 23 | /** |
||||
| 24 | * The console command description. |
||||
| 25 | * |
||||
| 26 | * @var string |
||||
| 27 | */ |
||||
| 28 | protected $description = 'Fix release names using various methods (NFO, file name, Par2, etc.)'; |
||||
| 29 | |||||
| 30 | /** |
||||
| 31 | * Execute the console command. |
||||
| 32 | */ |
||||
| 33 | public function handle(NameFixingService $nameFixingService, NNTP $nntp): int |
||||
| 34 | { |
||||
| 35 | $method = $this->argument('method'); |
||||
| 36 | $update = (bool) $this->option('update'); |
||||
| 37 | $setStatus = (bool) $this->option('set-status'); |
||||
| 38 | $show = $this->option('show'); |
||||
| 39 | |||||
| 40 | // Set category option |
||||
| 41 | $categoryOption = $this->option('category'); |
||||
| 42 | $other = 1; |
||||
| 43 | if ($categoryOption === 'all') { |
||||
| 44 | $other = 2; |
||||
| 45 | } elseif ($categoryOption === 'predb_id') { |
||||
| 46 | $other = 3; |
||||
| 47 | } |
||||
| 48 | |||||
| 49 | // Connect to NNTP if method requires it |
||||
| 50 | if ($method === '7' || $method === '8') { |
||||
| 51 | $compressedHeaders = config('nntmux_nntp.compressed_headers'); |
||||
| 52 | if ((config('nntmux_nntp.use_alternate_nntp_server') === true ? |
||||
| 53 | $nntp->doConnect($compressedHeaders, true) : |
||||
| 54 | $nntp->doConnect()) !== true) { |
||||
| 55 | $this->error('Unable to connect to usenet.'); |
||||
| 56 | |||||
| 57 | return 1; |
||||
| 58 | } |
||||
| 59 | } |
||||
| 60 | |||||
| 61 | switch ($method) { |
||||
| 62 | case '3': |
||||
| 63 | $nameFixingService->fixNamesWithNfo(1, $update, $other, $setStatus, $show); |
||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||
| 64 | break; |
||||
| 65 | case '4': |
||||
| 66 | $nameFixingService->fixNamesWithNfo(2, $update, $other, $setStatus, $show); |
||||
| 67 | break; |
||||
| 68 | case '5': |
||||
| 69 | $nameFixingService->fixNamesWithFiles(1, $update, $other, $setStatus, $show); |
||||
|
0 ignored issues
–
show
$show of type string is incompatible with the type boolean expected by parameter $show of App\Services\NameFixing\...ce::fixNamesWithFiles().
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 70 | break; |
||||
| 71 | case '6': |
||||
| 72 | $nameFixingService->fixNamesWithFiles(2, $update, $other, $setStatus, $show); |
||||
| 73 | break; |
||||
| 74 | case '7': |
||||
| 75 | $nameFixingService->fixNamesWithPar2(1, $update, $other, $setStatus, $show, $nntp); |
||||
|
0 ignored issues
–
show
$show of type string is incompatible with the type boolean expected by parameter $show of App\Services\NameFixing\...ice::fixNamesWithPar2().
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 76 | break; |
||||
| 77 | case '8': |
||||
| 78 | $nameFixingService->fixNamesWithPar2(2, $update, $other, $setStatus, $show, $nntp); |
||||
| 79 | break; |
||||
| 80 | case '9': |
||||
| 81 | $nameFixingService->fixNamesWithMedia(1, $update, $other, $setStatus, $show); |
||||
|
0 ignored issues
–
show
$show of type string is incompatible with the type boolean expected by parameter $show of App\Services\NameFixing\...ce::fixNamesWithMedia().
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 82 | break; |
||||
| 83 | case '10': |
||||
| 84 | $nameFixingService->fixNamesWithMedia(2, $update, $other, $setStatus, $show); |
||||
| 85 | break; |
||||
| 86 | case '11': |
||||
| 87 | $nameFixingService->fixXXXNamesWithFiles(1, $update, $other, $setStatus, $show); |
||||
|
0 ignored issues
–
show
$show of type string is incompatible with the type boolean expected by parameter $show of App\Services\NameFixing\...:fixXXXNamesWithFiles().
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 88 | break; |
||||
| 89 | case '12': |
||||
| 90 | $nameFixingService->fixXXXNamesWithFiles(2, $update, $other, $setStatus, $show); |
||||
| 91 | break; |
||||
| 92 | case '13': |
||||
| 93 | $nameFixingService->fixNamesWithSrr(1, $update, $other, $setStatus, $show); |
||||
|
0 ignored issues
–
show
$show of type string is incompatible with the type boolean expected by parameter $show of App\Services\NameFixing\...vice::fixNamesWithSrr().
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 94 | break; |
||||
| 95 | case '14': |
||||
| 96 | $nameFixingService->fixNamesWithSrr(2, $update, $other, $setStatus, $show); |
||||
| 97 | break; |
||||
| 98 | case '15': |
||||
| 99 | $nameFixingService->fixNamesWithParHash(1, $update, $other, $setStatus, $show); |
||||
|
0 ignored issues
–
show
$show of type string is incompatible with the type boolean expected by parameter $show of App\Services\NameFixing\...::fixNamesWithParHash().
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 100 | break; |
||||
| 101 | case '16': |
||||
| 102 | $nameFixingService->fixNamesWithParHash(2, $update, $other, $setStatus, $show); |
||||
| 103 | break; |
||||
| 104 | case '17': |
||||
| 105 | $nameFixingService->fixNamesWithMediaMovieName(1, $update, $other, $setStatus, $show); |
||||
|
0 ignored issues
–
show
$show of type string is incompatible with the type boolean expected by parameter $show of App\Services\NameFixing\...mesWithMediaMovieName().
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 106 | break; |
||||
| 107 | case '18': |
||||
| 108 | $nameFixingService->fixNamesWithMediaMovieName(2, $update, $other, $setStatus, $show); |
||||
| 109 | break; |
||||
| 110 | case '19': |
||||
| 111 | $nameFixingService->fixNamesWithCrc(1, $update, $other, $setStatus, $show); |
||||
|
0 ignored issues
–
show
$show of type string is incompatible with the type boolean expected by parameter $show of App\Services\NameFixing\...vice::fixNamesWithCrc().
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 112 | break; |
||||
| 113 | case '20': |
||||
| 114 | $nameFixingService->fixNamesWithCrc(2, $update, $other, $setStatus, $show); |
||||
| 115 | break; |
||||
| 116 | default: |
||||
| 117 | $this->showHelp(); |
||||
| 118 | |||||
| 119 | return 1; |
||||
| 120 | } |
||||
| 121 | |||||
| 122 | return 0; |
||||
| 123 | } |
||||
| 124 | |||||
| 125 | /** |
||||
| 126 | * Display detailed help information. |
||||
| 127 | */ |
||||
| 128 | protected function showHelp(): void |
||||
| 129 | { |
||||
| 130 | $this->info(''); |
||||
| 131 | $this->info('Usage Examples:'); |
||||
| 132 | $this->info(''); |
||||
| 133 | $this->info('php artisan releases:fix-names 3 : Fix release names using NFO in the past 6 hours.'); |
||||
| 134 | $this->info('php artisan releases:fix-names 4 : Fix release names using NFO.'); |
||||
| 135 | $this->info('php artisan releases:fix-names 5 : Fix release names in misc categories using File Name in the past 6 hours.'); |
||||
| 136 | $this->info('php artisan releases:fix-names 6 : Fix release names in misc categories using File Name.'); |
||||
| 137 | $this->info('php artisan releases:fix-names 7 : Fix release names in misc categories using Par2 Files in the past 6 hours.'); |
||||
| 138 | $this->info('php artisan releases:fix-names 8 : Fix release names in misc categories using Par2 Files.'); |
||||
| 139 | $this->info('php artisan releases:fix-names 9 : Fix release names in misc categories using UID in the past 6 hours.'); |
||||
| 140 | $this->info('php artisan releases:fix-names 10 : Fix release names in misc categories using UID.'); |
||||
| 141 | $this->info('php artisan releases:fix-names 11 : Fix SDPORN XXX release names using specific File Name in the past 6 hours.'); |
||||
| 142 | $this->info('php artisan releases:fix-names 12 : Fix SDPORN XXX release names using specific File Name.'); |
||||
| 143 | $this->info('php artisan releases:fix-names 13 : Fix release names using SRR files in the past 6 hours.'); |
||||
| 144 | $this->info('php artisan releases:fix-names 14 : Fix release names using SRR files.'); |
||||
| 145 | $this->info('php artisan releases:fix-names 15 : Fix release names using PAR2 hash_16K block in the past 6 hours.'); |
||||
| 146 | $this->info('php artisan releases:fix-names 16 : Fix release names using PAR2 hash_16K block.'); |
||||
| 147 | $this->info('php artisan releases:fix-names 17 : Fix release names using Mediainfo in the past 6 hours.'); |
||||
| 148 | $this->info('php artisan releases:fix-names 18 : Fix release names using Mediainfo.'); |
||||
| 149 | $this->info('php artisan releases:fix-names 19 : Fix release names using CRC32 in the past 6 hours.'); |
||||
| 150 | $this->info('php artisan releases:fix-names 20 : Fix release names using CRC32.'); |
||||
| 151 | $this->info(''); |
||||
| 152 | $this->info('Options:'); |
||||
| 153 | $this->info(' --update Actually update the names (default: only display potential changes)'); |
||||
| 154 | $this->info(' --category=VALUE Process "other" categories (default), "all" categories, or "predb_id" for unmatched'); |
||||
| 155 | $this->info(' --set-status Mark releases as checked so they won\'t be processed again'); |
||||
| 156 | $this->info(' --show Display detailed release changes (default: only show counters)'); |
||||
| 157 | $this->info(''); |
||||
| 158 | } |
||||
| 159 | } |
||||
| 160 |