Potential fix for #261

This commit is contained in:
abdulmohsen
2022-11-02 16:30:14 +03:00
parent 535439236a
commit ed99b8e3c9
2 changed files with 20 additions and 4 deletions

View File

@@ -13,11 +13,13 @@ use App\Backends\Common\Response;
use App\Backends\Jellyfin\JellyfinActionTrait;
use App\Backends\Jellyfin\JellyfinClient;
use App\Libs\Options;
use JsonMachine\Exception\InvalidArgumentException;
use JsonMachine\Items;
use JsonMachine\JsonDecoder\DecodingError;
use JsonMachine\JsonDecoder\ErrorWrappingDecoder;
use JsonMachine\JsonDecoder\ExtJsonDecoder;
use Psr\Log\LoggerInterface;
use Symfony\Contracts\HttpClient\Exception\ExceptionInterface;
use Symfony\Contracts\HttpClient\HttpClientInterface;
class GetLibrary
@@ -45,8 +47,8 @@ class GetLibrary
}
/**
* @throws \Symfony\Contracts\HttpClient\Exception\ExceptionInterface
* @throws \JsonMachine\Exception\InvalidArgumentException
* @throws ExceptionInterface
* @throws InvalidArgumentException
*/
private function action(Context $context, string|int $id, array $opts = []): Response
{
@@ -173,7 +175,14 @@ class GetLibrary
'url' => (string)$url,
];
$list[] = $this->process($context, $entity, $logContext, $opts);
if (null !== ($indexNumberEnd = ag($entity, 'IndexNumberEnd'))) {
foreach (range((int)ag($entity, 'IndexNumber'), $indexNumberEnd) as $i) {
$entity['IndexNumber'] = $i;
$list[] = $this->process($context, $entity, $logContext, $opts);
}
} else {
$list[] = $this->process($context, $entity, $logContext, $opts);
}
}
return new Response(status: true, response: $list);

View File

@@ -603,7 +603,14 @@ class Import
continue;
}
$callback(item: $entity, logContext: $logContext);
if (null !== ($indexNumberEnd = ag($entity, 'IndexNumberEnd'))) {
foreach (range((int)ag($entity, 'IndexNumber'), $indexNumberEnd) as $i) {
$entity['IndexNumber'] = $i;
$callback(item: $entity, logContext: $logContext);
}
} else {
$callback(item: $entity, logContext: $logContext);
}
}
} catch (Throwable $e) {
$this->logger->error(