option('folder'); if (! is_string($folderOption) || trim($folderOption) === '') { $this->error('Folder path must not be empty'); return; } $importFolder = rtrim($folderOption, '/\\'); if (! File::isDirectory($importFolder)) { $this->error('Folder path does not exist: '.$importFolder); return; } $useNzbName = (bool) $this->option('filename'); $deleteNZB = (bool) $this->option('delete'); $deleteFailedNZB = (bool) $this->option('delete-failed'); $source = $this->option('source') ? (int) $this->option('source') : 1; try { $files = array_values(array_filter( File::allFiles($importFolder), static function (SplFileInfo $file) use ($manifests): bool { $path = $file->getPathname(); if (! Str::endsWith(strtolower($path), ['.nzb', '.nzb.gz'])) { return true; } return $manifests->shouldImportNzb($path); } )); $this->info('Importing NZB files from '.$importFolder); $importer = new NzbImportService; $importer->beginImport( $files, $useNzbName, $deleteNZB, $deleteFailedNZB, $source, static function (array $result) use ($manifests): void { /** @var NzbImportStatus $status */ $status = $result['status']; $manifests->recordNzbOutcome( $result['path'], $status, $result['release_id'], $result['release_guid'], ); } ); } catch (Throwable $exception) { $this->error($exception->getMessage()); } } }