NNTmux /
newznab-tmux
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | namespace App\Services; |
||
| 6 | |||
| 7 | use App\Services\AdditionalProcessing\AdditionalProcessingOrchestrator; |
||
|
0 ignored issues
–
show
|
|||
| 8 | use App\Services\NameFixing\NameFixingService; |
||
| 9 | use Blacklight\Nfo; |
||
| 10 | use Blacklight\NNTP; |
||
| 11 | use dariusiii\rarinfo\Par2Info; |
||
| 12 | use Illuminate\Contracts\Foundation\Application; |
||
| 13 | |||
| 14 | /** |
||
| 15 | * Orchestrates post-processing of releases. |
||
| 16 | * |
||
| 17 | * This service coordinates various post-processing operations including: |
||
| 18 | * - NFO processing |
||
| 19 | * - Movie/TV/Anime lookups |
||
| 20 | * - Music/Books/Games/Console processing |
||
| 21 | * - XXX content processing |
||
| 22 | * - Additional processing (RAR/ZIP contents, samples, etc.) |
||
| 23 | */ |
||
| 24 | final class PostProcessService |
||
| 25 | { |
||
| 26 | private readonly bool $echoOutput; |
||
| 27 | private readonly bool $alternateNNTP; |
||
| 28 | private readonly bool $addPar2; |
||
| 29 | |||
| 30 | private readonly NameFixingService $nameFixingService; |
||
| 31 | private readonly Par2Info $par2Info; |
||
| 32 | private readonly Nfo $nfo; |
||
| 33 | |||
| 34 | private readonly Par2Processor $par2Processor; |
||
| 35 | private readonly TvProcessor $tvProcessor; |
||
| 36 | private readonly NfoProcessor $nfoProcessor; |
||
| 37 | private readonly MoviesProcessor $moviesProcessor; |
||
| 38 | private readonly MusicProcessor $musicProcessor; |
||
| 39 | private readonly BooksProcessor $booksProcessor; |
||
| 40 | private readonly ConsolesProcessor $consolesProcessor; |
||
| 41 | private readonly GamesProcessor $gamesProcessor; |
||
| 42 | private readonly AnimeProcessor $animeProcessor; |
||
| 43 | private readonly XXXProcessor $xxxProcessor; |
||
| 44 | |||
| 45 | public function __construct( |
||
| 46 | ?NameFixingService $nameFixingService = null, |
||
| 47 | ?Par2Info $par2Info = null, |
||
| 48 | ?Nfo $nfo = null, |
||
| 49 | ?Par2Processor $par2Processor = null, |
||
| 50 | ?TvProcessor $tvProcessor = null, |
||
| 51 | ?NfoProcessor $nfoProcessor = null, |
||
| 52 | ?MoviesProcessor $moviesProcessor = null, |
||
| 53 | ?MusicProcessor $musicProcessor = null, |
||
| 54 | ?BooksProcessor $booksProcessor = null, |
||
| 55 | ?ConsolesProcessor $consolesProcessor = null, |
||
| 56 | ?GamesProcessor $gamesProcessor = null, |
||
| 57 | ?AnimeProcessor $animeProcessor = null, |
||
| 58 | ?XXXProcessor $xxxProcessor = null, |
||
| 59 | ) { |
||
| 60 | $this->echoOutput = (bool) config('nntmux.echocli'); |
||
|
0 ignored issues
–
show
|
|||
| 61 | $this->addPar2 = (bool) config('nntmux_settings.add_par2'); |
||
|
0 ignored issues
–
show
|
|||
| 62 | $this->alternateNNTP = (bool) config('nntmux_nntp.use_alternate_nntp_server'); |
||
|
0 ignored issues
–
show
|
|||
| 63 | |||
| 64 | // Core dependencies |
||
| 65 | $this->nameFixingService = $nameFixingService ?? new NameFixingService(); |
||
|
0 ignored issues
–
show
|
|||
| 66 | $this->par2Info = $par2Info ?? new Par2Info(); |
||
|
0 ignored issues
–
show
|
|||
| 67 | $this->nfo = $nfo ?? new Nfo(); |
||
|
0 ignored issues
–
show
|
|||
| 68 | |||
| 69 | // Processors |
||
| 70 | $this->par2Processor = $par2Processor ?? new Par2Processor( |
||
|
0 ignored issues
–
show
|
|||
| 71 | $this->nameFixingService, |
||
| 72 | $this->par2Info, |
||
| 73 | $this->addPar2, |
||
| 74 | $this->alternateNNTP |
||
| 75 | ); |
||
| 76 | $this->tvProcessor = $tvProcessor ?? new TvProcessor($this->echoOutput); |
||
|
0 ignored issues
–
show
|
|||
| 77 | $this->nfoProcessor = $nfoProcessor ?? new NfoProcessor($this->nfo, $this->echoOutput); |
||
|
0 ignored issues
–
show
|
|||
| 78 | $this->moviesProcessor = $moviesProcessor ?? new MoviesProcessor($this->echoOutput); |
||
|
0 ignored issues
–
show
|
|||
| 79 | $this->musicProcessor = $musicProcessor ?? new MusicProcessor($this->echoOutput); |
||
|
0 ignored issues
–
show
|
|||
| 80 | $this->booksProcessor = $booksProcessor ?? new BooksProcessor($this->echoOutput); |
||
|
0 ignored issues
–
show
|
|||
| 81 | $this->consolesProcessor = $consolesProcessor ?? new ConsolesProcessor($this->echoOutput); |
||
|
0 ignored issues
–
show
|
|||
| 82 | $this->gamesProcessor = $gamesProcessor ?? new GamesProcessor($this->echoOutput); |
||
|
0 ignored issues
–
show
|
|||
| 83 | $this->animeProcessor = $animeProcessor ?? new AnimeProcessor($this->echoOutput); |
||
|
0 ignored issues
–
show
|
|||
| 84 | $this->xxxProcessor = $xxxProcessor ?? new XXXProcessor($this->echoOutput); |
||
|
0 ignored issues
–
show
|
|||
| 85 | } |
||
| 86 | |||
| 87 | /** |
||
| 88 | * Run all post-processing types. |
||
| 89 | * |
||
| 90 | * @throws \Exception |
||
| 91 | */ |
||
| 92 | public function processAll(NNTP $nntp): void |
||
| 93 | { |
||
| 94 | $this->processAdditional(); |
||
| 95 | $this->processNfos($nntp); |
||
| 96 | $this->processMovies(); |
||
| 97 | $this->processMusic(); |
||
| 98 | $this->processConsoles(); |
||
| 99 | $this->processGames(); |
||
| 100 | $this->processAnime(); |
||
| 101 | $this->processTv(); |
||
| 102 | $this->processXXX(); |
||
| 103 | $this->processBooks(); |
||
| 104 | } |
||
| 105 | |||
| 106 | /** |
||
| 107 | * Process anime releases using AniDB. |
||
| 108 | * |
||
| 109 | * @param string $groupID Optional group ID filter |
||
| 110 | * @param string $guidChar Optional GUID character filter |
||
| 111 | * |
||
| 112 | * @throws \Exception |
||
| 113 | */ |
||
| 114 | public function processAnime(string $groupID = '', string $guidChar = ''): void |
||
| 115 | { |
||
| 116 | $this->animeProcessor->process($groupID, $guidChar); |
||
| 117 | } |
||
| 118 | |||
| 119 | /** |
||
| 120 | * Process book releases using Amazon. |
||
| 121 | * |
||
| 122 | * @param string $groupID Optional group ID filter |
||
| 123 | * @param string $guidChar Optional GUID character filter |
||
| 124 | * |
||
| 125 | * @throws \Exception |
||
| 126 | */ |
||
| 127 | public function processBooks(string $groupID = '', string $guidChar = ''): void |
||
| 128 | { |
||
| 129 | $this->booksProcessor->process($groupID, $guidChar); |
||
| 130 | } |
||
| 131 | |||
| 132 | /** |
||
| 133 | * Process console game releases. |
||
| 134 | * |
||
| 135 | * @throws \Exception |
||
| 136 | */ |
||
| 137 | public function processConsoles(): void |
||
| 138 | { |
||
| 139 | $this->consolesProcessor->process(); |
||
| 140 | } |
||
| 141 | |||
| 142 | /** |
||
| 143 | * Process PC game releases. |
||
| 144 | * |
||
| 145 | * @throws \Exception |
||
| 146 | */ |
||
| 147 | public function processGames(): void |
||
| 148 | { |
||
| 149 | $this->gamesProcessor->process(); |
||
| 150 | } |
||
| 151 | |||
| 152 | /** |
||
| 153 | * Process movie releases using IMDB/TMDB. |
||
| 154 | * |
||
| 155 | * @param string $groupID Optional group ID filter |
||
| 156 | * @param string $guidChar Optional GUID character filter |
||
| 157 | * @param int|string|null $processMovies Processing mode (0=skip, 1=all, 2=renamed only, ''=check setting) |
||
| 158 | * |
||
| 159 | * @throws \Exception |
||
| 160 | */ |
||
| 161 | public function processMovies( |
||
| 162 | string $groupID = '', |
||
| 163 | string $guidChar = '', |
||
| 164 | int|string|null $processMovies = '' |
||
| 165 | ): void { |
||
| 166 | $this->moviesProcessor->process($groupID, $guidChar, $processMovies); |
||
| 167 | } |
||
| 168 | |||
| 169 | /** |
||
| 170 | * Process music releases. |
||
| 171 | * |
||
| 172 | * @throws \Exception |
||
| 173 | */ |
||
| 174 | public function processMusic(): void |
||
| 175 | { |
||
| 176 | $this->musicProcessor->process(); |
||
| 177 | } |
||
| 178 | |||
| 179 | /** |
||
| 180 | * Process NFO files for releases. |
||
| 181 | * |
||
| 182 | * @param NNTP $nntp NNTP connection for downloading NFOs |
||
| 183 | * @param string $groupID Optional group ID filter |
||
| 184 | * @param string $guidChar Optional GUID character filter |
||
| 185 | * |
||
| 186 | * @throws \Exception |
||
| 187 | */ |
||
| 188 | public function processNfos(NNTP $nntp, string $groupID = '', string $guidChar = ''): void |
||
| 189 | { |
||
| 190 | $this->nfoProcessor->process($nntp, $groupID, $guidChar); |
||
| 191 | } |
||
| 192 | |||
| 193 | /** |
||
| 194 | * Process TV releases. |
||
| 195 | * |
||
| 196 | * @param string $groupID Optional group ID filter |
||
| 197 | * @param string $guidChar Optional GUID character filter |
||
| 198 | * @param int|string|null $processTV Processing mode (0=skip, 1=all, 2=renamed only, ''=check setting) |
||
| 199 | * @param string $mode Processing mode ('pipeline' or 'parallel') |
||
| 200 | * |
||
| 201 | * @throws \Exception |
||
| 202 | */ |
||
| 203 | public function processTv( |
||
| 204 | string $groupID = '', |
||
| 205 | string $guidChar = '', |
||
| 206 | int|string|null $processTV = '', |
||
| 207 | string $mode = 'pipeline' |
||
| 208 | ): void { |
||
| 209 | if ($guidChar === '') { |
||
| 210 | $forkingService = new ForkingService(); |
||
| 211 | $processTV = is_numeric($processTV) |
||
| 212 | ? $processTV |
||
| 213 | : \App\Models\Settings::settingValue('lookuptv'); |
||
| 214 | $renamedOnly = ((int) $processTV === 2); |
||
| 215 | |||
| 216 | $forkingService->processTv($renamedOnly); |
||
| 217 | } else { |
||
| 218 | $this->tvProcessor->process($groupID, $guidChar, $processTV, $mode); |
||
| 219 | } |
||
| 220 | } |
||
| 221 | |||
| 222 | /** |
||
| 223 | * Process XXX releases. |
||
| 224 | * |
||
| 225 | * @throws \Exception |
||
| 226 | */ |
||
| 227 | public function processXXX(): void |
||
| 228 | { |
||
| 229 | $this->xxxProcessor->process(); |
||
| 230 | } |
||
| 231 | |||
| 232 | /** |
||
| 233 | * Process additional release data (RAR/ZIP contents, samples, media info). |
||
| 234 | * |
||
| 235 | * @param int|string $groupID Optional group ID filter |
||
| 236 | * @param string $guidChar Optional GUID character filter |
||
| 237 | * |
||
| 238 | * @throws \Exception |
||
| 239 | */ |
||
| 240 | public function processAdditional(int|string $groupID = '', string $guidChar = ''): void |
||
| 241 | { |
||
| 242 | app(AdditionalProcessingOrchestrator::class)->start($groupID, $guidChar); |
||
| 243 | } |
||
| 244 | |||
| 245 | /** |
||
| 246 | * Attempt to get a better name from a PAR2 file and re-categorize. |
||
| 247 | * |
||
| 248 | * @param string $messageID Message ID from NZB |
||
| 249 | * @param int $relID Release ID |
||
| 250 | * @param int $groupID Group ID |
||
| 251 | * @param NNTP $nntp NNTP connection |
||
| 252 | * @param int $show Display mode (0=apply, 1=show only) |
||
| 253 | * |
||
| 254 | * @throws \Exception |
||
| 255 | */ |
||
| 256 | public function parsePAR2( |
||
| 257 | string $messageID, |
||
| 258 | int $relID, |
||
| 259 | int $groupID, |
||
| 260 | NNTP $nntp, |
||
| 261 | int $show |
||
| 262 | ): bool { |
||
| 263 | return $this->par2Processor->parseFromMessage($messageID, $relID, $groupID, $nntp, $show); |
||
| 264 | } |
||
| 265 | } |
||
| 266 | |||
| 267 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths