Reformatted code according to PSR12.
This commit is contained in:
@@ -30,24 +30,24 @@ trait CommonTrait
|
||||
} catch (Throwable $e) {
|
||||
return new Response(
|
||||
status: false,
|
||||
error: new Error(
|
||||
message: 'Unhandled exception was thrown in [%(client): %(backend)] %(action). %(message)',
|
||||
context: [
|
||||
'action' => $action ?? 'context',
|
||||
'backend' => $context->backendName,
|
||||
'client' => $context->clientName,
|
||||
'message' => $e->getMessage(),
|
||||
'exception' => [
|
||||
'file' => $e->getFile(),
|
||||
'line' => $e->getLine(),
|
||||
'kind' => get_class($e),
|
||||
'message' => $e->getMessage(),
|
||||
'trace' => $context->trace ? $e->getTrace() : [],
|
||||
]
|
||||
],
|
||||
level: Levels::WARNING,
|
||||
previous: $e
|
||||
)
|
||||
error: new Error(
|
||||
message: 'Unhandled exception was thrown in [%(client): %(backend)] %(action). %(message)',
|
||||
context: [
|
||||
'action' => $action ?? 'context',
|
||||
'backend' => $context->backendName,
|
||||
'client' => $context->clientName,
|
||||
'message' => $e->getMessage(),
|
||||
'exception' => [
|
||||
'file' => $e->getFile(),
|
||||
'line' => $e->getLine(),
|
||||
'kind' => get_class($e),
|
||||
'message' => $e->getMessage(),
|
||||
'trace' => $context->trace ? $e->getTrace() : [],
|
||||
]
|
||||
],
|
||||
level: Levels::WARNING,
|
||||
previous: $e
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,7 +154,7 @@ final class ParseWebhook
|
||||
iState::COLUMN_META_DATA => [
|
||||
$context->backendName => [
|
||||
iState::COLUMN_GUIDS => $guid->parse(
|
||||
guids: ag($json, 'Item.ProviderIds', []),
|
||||
guids: ag($json, 'Item.ProviderIds', []),
|
||||
context: $logContext
|
||||
),
|
||||
]
|
||||
@@ -182,31 +182,31 @@ final class ParseWebhook
|
||||
|
||||
$entity = $this->createEntity(
|
||||
context: $context,
|
||||
guid: $guid,
|
||||
item: $obj,
|
||||
opts: ['override' => $fields, Options::DISABLE_GUID => $disableGuid],
|
||||
guid: $guid,
|
||||
item: $obj,
|
||||
opts: ['override' => $fields, Options::DISABLE_GUID => $disableGuid],
|
||||
)->setIsTainted(isTainted: true === in_array($event, self::WEBHOOK_TAINTED_EVENTS));
|
||||
|
||||
if (false === $entity->hasGuids() && false === $entity->hasRelativeGuid()) {
|
||||
return new Response(
|
||||
status: false,
|
||||
error: new Error(
|
||||
message: 'Ignoring [%(backend)] [%(title)] webhook event. No valid/supported external ids.',
|
||||
context: [
|
||||
'backend' => $context->backendName,
|
||||
'title' => $entity->getName(),
|
||||
'context' => [
|
||||
'attributes' => $request->getAttributes(),
|
||||
'parsed' => $entity->getAll(),
|
||||
'payload' => $request->getParsedBody(),
|
||||
],
|
||||
],
|
||||
level: Levels::ERROR
|
||||
),
|
||||
extra: [
|
||||
'http_code' => 200,
|
||||
'message' => $context->backendName . ': Import ignored. No valid/supported external ids.'
|
||||
error: new Error(
|
||||
message: 'Ignoring [%(backend)] [%(title)] webhook event. No valid/supported external ids.',
|
||||
context: [
|
||||
'backend' => $context->backendName,
|
||||
'title' => $entity->getName(),
|
||||
'context' => [
|
||||
'attributes' => $request->getAttributes(),
|
||||
'parsed' => $entity->getAll(),
|
||||
'payload' => $request->getParsedBody(),
|
||||
],
|
||||
],
|
||||
level: Levels::ERROR
|
||||
),
|
||||
extra: [
|
||||
'http_code' => 200,
|
||||
'message' => $context->backendName . ': Import ignored. No valid/supported external ids.'
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -214,28 +214,28 @@ final class ParseWebhook
|
||||
} catch (Throwable $e) {
|
||||
return new Response(
|
||||
status: false,
|
||||
error: new Error(
|
||||
message: 'Unhandled exception was thrown during [%(backend)] webhook event parsing.',
|
||||
context: [
|
||||
'backend' => $context->backendName,
|
||||
'exception' => [
|
||||
'file' => $e->getFile(),
|
||||
'line' => $e->getLine(),
|
||||
'kind' => get_class($e),
|
||||
'message' => $e->getMessage(),
|
||||
],
|
||||
'context' => [
|
||||
'attributes' => $request->getAttributes(),
|
||||
'payload' => $request->getParsedBody(),
|
||||
],
|
||||
'trace' => $context->trace ? $e->getTrace() : [],
|
||||
],
|
||||
level: Levels::ERROR
|
||||
),
|
||||
extra: [
|
||||
'http_code' => 200,
|
||||
'message' => $context->backendName . ': Failed to handle payload. Check logs.'
|
||||
error: new Error(
|
||||
message: 'Unhandled exception was thrown during [%(backend)] webhook event parsing.',
|
||||
context: [
|
||||
'backend' => $context->backendName,
|
||||
'exception' => [
|
||||
'file' => $e->getFile(),
|
||||
'line' => $e->getLine(),
|
||||
'kind' => get_class($e),
|
||||
'message' => $e->getMessage(),
|
||||
],
|
||||
'context' => [
|
||||
'attributes' => $request->getAttributes(),
|
||||
'payload' => $request->getParsedBody(),
|
||||
],
|
||||
'trace' => $context->trace ? $e->getTrace() : [],
|
||||
],
|
||||
level: Levels::ERROR
|
||||
),
|
||||
extra: [
|
||||
'http_code' => 200,
|
||||
'message' => $context->backendName . ': Failed to handle payload. Check logs.'
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,9 +67,9 @@ class Backup extends Import
|
||||
|
||||
$entity = $this->createEntity(
|
||||
context: $context,
|
||||
guid: $guid,
|
||||
item: $item,
|
||||
opts: $opts + ['library' => ag($logContext, 'library.id')]
|
||||
guid: $guid,
|
||||
item: $item,
|
||||
opts: $opts + ['library' => ag($logContext, 'library.id')]
|
||||
);
|
||||
$arr = [
|
||||
iState::COLUMN_TYPE => $entity->type,
|
||||
|
||||
@@ -85,9 +85,9 @@ class Export extends Import
|
||||
|
||||
$rItem = $this->createEntity(
|
||||
context: $context,
|
||||
guid: $guid,
|
||||
item: $item,
|
||||
opts: $opts + ['library' => ag($logContext, 'library.id')]
|
||||
guid: $guid,
|
||||
item: $item,
|
||||
opts: $opts + ['library' => ag($logContext, 'library.id')]
|
||||
);
|
||||
|
||||
if (!$rItem->hasGuids() && !$rItem->hasRelativeGuid()) {
|
||||
|
||||
@@ -56,23 +56,23 @@ class GetIdentifier
|
||||
if (200 !== $response->getStatusCode()) {
|
||||
return new Response(
|
||||
status: false,
|
||||
error: new Error(
|
||||
message: 'Request for [%(backend)] %(action) returned with unexpected [%(status_code)] status code.',
|
||||
context: [
|
||||
'action' => $this->action,
|
||||
'client' => $context->clientName,
|
||||
'backend' => $context->backendName,
|
||||
'status_code' => $response->getStatusCode(),
|
||||
],
|
||||
level: Levels::WARNING
|
||||
)
|
||||
error: new Error(
|
||||
message: 'Request for [%(backend)] %(action) returned with unexpected [%(status_code)] status code.',
|
||||
context: [
|
||||
'action' => $this->action,
|
||||
'client' => $context->clientName,
|
||||
'backend' => $context->backendName,
|
||||
'status_code' => $response->getStatusCode(),
|
||||
],
|
||||
level: Levels::WARNING
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$item = json_decode(
|
||||
json: $response->getContent(),
|
||||
json: $response->getContent(),
|
||||
associative: true,
|
||||
flags: JSON_THROW_ON_ERROR | JSON_INVALID_UTF8_IGNORE
|
||||
flags: JSON_THROW_ON_ERROR | JSON_INVALID_UTF8_IGNORE
|
||||
);
|
||||
|
||||
if (true === $context->trace) {
|
||||
@@ -85,11 +85,11 @@ class GetIdentifier
|
||||
}
|
||||
|
||||
return new Response(
|
||||
status: true,
|
||||
status: true,
|
||||
response: ag($item, 'Id', null)
|
||||
);
|
||||
},
|
||||
action: $this->action,
|
||||
action: $this->action,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,10 +5,10 @@ declare(strict_types=1);
|
||||
namespace App\Backends\Jellyfin\Action;
|
||||
|
||||
use App\Backends\Common\CommonTrait;
|
||||
use App\Backends\Common\Context;
|
||||
use App\Backends\Common\Error;
|
||||
use App\Backends\Common\Levels;
|
||||
use App\Backends\Common\Response;
|
||||
use App\Backends\Common\Context;
|
||||
use App\Backends\Jellyfin\JellyfinClient;
|
||||
use App\Libs\Options;
|
||||
use JsonException;
|
||||
@@ -55,14 +55,14 @@ class GetLibrariesList
|
||||
if (200 !== $response->getStatusCode()) {
|
||||
return new Response(
|
||||
status: false,
|
||||
error: new Error(
|
||||
message: 'Request for [%(backend)] libraries returned with unexpected [%(status_code)] status code.',
|
||||
context: [
|
||||
'backend' => $context->backendName,
|
||||
'status_code' => $response->getStatusCode(),
|
||||
],
|
||||
level: Levels::ERROR
|
||||
),
|
||||
error: new Error(
|
||||
message: 'Request for [%(backend)] libraries returned with unexpected [%(status_code)] status code.',
|
||||
context: [
|
||||
'backend' => $context->backendName,
|
||||
'status_code' => $response->getStatusCode(),
|
||||
],
|
||||
level: Levels::ERROR
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -87,16 +87,16 @@ class GetLibrariesList
|
||||
if (empty($listDirs)) {
|
||||
return new Response(
|
||||
status: false,
|
||||
error: new Error(
|
||||
message: 'Request for [%(backend)] libraries returned empty list.',
|
||||
context: [
|
||||
'backend' => $context->backendName,
|
||||
'response' => [
|
||||
'body' => $json
|
||||
],
|
||||
],
|
||||
level: Levels::WARNING
|
||||
),
|
||||
error: new Error(
|
||||
message: 'Request for [%(backend)] libraries returned empty list.',
|
||||
context: [
|
||||
'backend' => $context->backendName,
|
||||
'response' => [
|
||||
'body' => $json
|
||||
],
|
||||
],
|
||||
level: Levels::WARNING
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,11 +5,11 @@ declare(strict_types=1);
|
||||
namespace App\Backends\Jellyfin\Action;
|
||||
|
||||
use App\Backends\Common\CommonTrait;
|
||||
use App\Backends\Common\Context;
|
||||
use App\Backends\Common\Error;
|
||||
use App\Backends\Common\GuidInterface as iGuid;
|
||||
use App\Backends\Common\Levels;
|
||||
use App\Backends\Common\Response;
|
||||
use App\Backends\Common\Context;
|
||||
use App\Backends\Jellyfin\JellyfinActionTrait;
|
||||
use App\Backends\Jellyfin\JellyfinClient;
|
||||
use App\Libs\Options;
|
||||
@@ -54,17 +54,17 @@ class GetLibrary
|
||||
if (null === ($section = ag($libraries, $id))) {
|
||||
return new Response(
|
||||
status: false,
|
||||
error: new Error(
|
||||
message: 'No Library with id [%(id)] found in [%(backend)] response.',
|
||||
context: [
|
||||
'id' => $id,
|
||||
'backend' => $context->backendName,
|
||||
'response' => [
|
||||
'body' => $libraries
|
||||
],
|
||||
],
|
||||
level: Levels::WARNING
|
||||
),
|
||||
error: new Error(
|
||||
message: 'No Library with id [%(id)] found in [%(backend)] response.',
|
||||
context: [
|
||||
'id' => $id,
|
||||
'backend' => $context->backendName,
|
||||
'response' => [
|
||||
'body' => $libraries
|
||||
],
|
||||
],
|
||||
level: Levels::WARNING
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -84,14 +84,14 @@ class GetLibrary
|
||||
)) {
|
||||
return new Response(
|
||||
status: false,
|
||||
error: new Error(
|
||||
message: 'The Requested [%(backend)] Library [%(library.id): %(library.title)] returned with unsupported type [%(library.type)].',
|
||||
context: [
|
||||
'backend' => $context->backendName,
|
||||
...$logContext,
|
||||
],
|
||||
level: Levels::WARNING
|
||||
),
|
||||
error: new Error(
|
||||
message: 'The Requested [%(backend)] Library [%(library.id): %(library.title)] returned with unsupported type [%(library.type)].',
|
||||
context: [
|
||||
'backend' => $context->backendName,
|
||||
...$logContext,
|
||||
],
|
||||
level: Levels::WARNING
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -120,26 +120,26 @@ class GetLibrary
|
||||
if (200 !== $response->getStatusCode()) {
|
||||
return new Response(
|
||||
status: false,
|
||||
error: new Error(
|
||||
message: 'Request for [%(backend)] library [%(library.title)] returned with unexpected [%(status_code)] status code.',
|
||||
context: [
|
||||
'backend' => $context->backendName,
|
||||
'status_code' => $response->getStatusCode(),
|
||||
...$logContext,
|
||||
],
|
||||
level: Levels::ERROR
|
||||
),
|
||||
error: new Error(
|
||||
message: 'Request for [%(backend)] library [%(library.title)] returned with unexpected [%(status_code)] status code.',
|
||||
context: [
|
||||
'backend' => $context->backendName,
|
||||
'status_code' => $response->getStatusCode(),
|
||||
...$logContext,
|
||||
],
|
||||
level: Levels::ERROR
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
$it = Items::fromIterable(
|
||||
iterable: httpClientChunks($this->http->stream($response)),
|
||||
options: [
|
||||
'pointer' => '/Items',
|
||||
'decoder' => new ErrorWrappingDecoder(
|
||||
new ExtJsonDecoder(assoc: true, options: JSON_INVALID_UTF8_IGNORE)
|
||||
)
|
||||
]
|
||||
options: [
|
||||
'pointer' => '/Items',
|
||||
'decoder' => new ErrorWrappingDecoder(
|
||||
new ExtJsonDecoder(assoc: true, options: JSON_INVALID_UTF8_IGNORE)
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
$list = [];
|
||||
|
||||
@@ -81,29 +81,29 @@ class GetMetaData
|
||||
if (200 !== $response->getStatusCode()) {
|
||||
return new Response(
|
||||
status: false,
|
||||
error: new Error(
|
||||
message: 'Request for [%(backend)] item [%(id)] returned with unexpected [%(status_code)] status code.',
|
||||
context: [
|
||||
'id' => $id,
|
||||
'client' => $context->clientName,
|
||||
'backend' => $context->backendName,
|
||||
'status_code' => $response->getStatusCode(),
|
||||
]
|
||||
)
|
||||
error: new Error(
|
||||
message: 'Request for [%(backend)] item [%(id)] returned with unexpected [%(status_code)] status code.',
|
||||
context: [
|
||||
'id' => $id,
|
||||
'client' => $context->clientName,
|
||||
'backend' => $context->backendName,
|
||||
'status_code' => $response->getStatusCode(),
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$item = json_decode(
|
||||
json: $response->getContent(),
|
||||
json: $response->getContent(),
|
||||
associative: true,
|
||||
flags: JSON_THROW_ON_ERROR | JSON_INVALID_UTF8_IGNORE
|
||||
flags: JSON_THROW_ON_ERROR | JSON_INVALID_UTF8_IGNORE
|
||||
);
|
||||
|
||||
if (null !== $cacheKey) {
|
||||
$this->cache->set(
|
||||
key: $cacheKey,
|
||||
key: $cacheKey,
|
||||
value: $item,
|
||||
ttl: $opts[Options::CACHE_TTL] ?? new DateInterval('PT5M')
|
||||
ttl: $opts[Options::CACHE_TTL] ?? new DateInterval('PT5M')
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,10 +5,10 @@ declare(strict_types=1);
|
||||
namespace App\Backends\Jellyfin\Action;
|
||||
|
||||
use App\Backends\Common\CommonTrait;
|
||||
use App\Backends\Common\Context;
|
||||
use App\Backends\Common\Error;
|
||||
use App\Backends\Common\Levels;
|
||||
use App\Backends\Common\Response;
|
||||
use App\Backends\Common\Context;
|
||||
use App\Libs\Options;
|
||||
use JsonException;
|
||||
use Psr\Log\LoggerInterface;
|
||||
@@ -56,21 +56,21 @@ class GetUsersList
|
||||
if (200 !== $response->getStatusCode()) {
|
||||
return new Response(
|
||||
status: false,
|
||||
error: new Error(
|
||||
message: 'Request for [%(backend)] users list returned with unexpected [%(status_code)] status code.',
|
||||
context: [
|
||||
'backend' => $context->backendName,
|
||||
'status_code' => $response->getStatusCode(),
|
||||
],
|
||||
level: Levels::ERROR
|
||||
),
|
||||
error: new Error(
|
||||
message: 'Request for [%(backend)] users list returned with unexpected [%(status_code)] status code.',
|
||||
context: [
|
||||
'backend' => $context->backendName,
|
||||
'status_code' => $response->getStatusCode(),
|
||||
],
|
||||
level: Levels::ERROR
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
$json = json_decode(
|
||||
json: $response->getContent(),
|
||||
json: $response->getContent(),
|
||||
associative: true,
|
||||
flags: JSON_THROW_ON_ERROR | JSON_INVALID_UTF8_IGNORE
|
||||
flags: JSON_THROW_ON_ERROR | JSON_INVALID_UTF8_IGNORE
|
||||
);
|
||||
|
||||
if ($context->trace) {
|
||||
|
||||
@@ -22,18 +22,19 @@ use JsonMachine\Items;
|
||||
use JsonMachine\JsonDecoder\DecodingError;
|
||||
use JsonMachine\JsonDecoder\ErrorWrappingDecoder;
|
||||
use JsonMachine\JsonDecoder\ExtJsonDecoder;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Psr\Log\LoggerInterface as iLogger;
|
||||
use Symfony\Contracts\HttpClient\Exception\ExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
||||
use Symfony\Contracts\HttpClient\HttpClientInterface as iHttp;
|
||||
use Symfony\Contracts\HttpClient\ResponseInterface as iResponse;
|
||||
use Throwable;
|
||||
|
||||
class Import
|
||||
{
|
||||
use CommonTrait, JellyfinActionTrait;
|
||||
use CommonTrait;
|
||||
use JellyfinActionTrait;
|
||||
|
||||
public function __construct(protected HttpClientInterface $http, protected LoggerInterface $logger)
|
||||
public function __construct(protected iHttp $http, protected iLogger $logger)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -56,15 +57,15 @@ class Import
|
||||
return $this->tryResponse($context, fn() => $this->getLibraries(
|
||||
context: $context,
|
||||
handle: fn(array $logContext = []) => fn(iResponse $response) => $this->handle(
|
||||
context: $context,
|
||||
response: $response,
|
||||
context: $context,
|
||||
response: $response,
|
||||
callback: fn(array $item, array $logContext = []) => $this->process(
|
||||
context: $context,
|
||||
guid: $guid,
|
||||
mapper: $mapper,
|
||||
item: $item,
|
||||
context: $context,
|
||||
guid: $guid,
|
||||
mapper: $mapper,
|
||||
item: $item,
|
||||
logContext: $logContext,
|
||||
opts: $opts + ['after' => $after],
|
||||
opts: $opts + ['after' => $after],
|
||||
),
|
||||
logContext: $logContext
|
||||
),
|
||||
@@ -109,9 +110,9 @@ class Import
|
||||
}
|
||||
|
||||
$json = json_decode(
|
||||
json: $response->getContent(),
|
||||
json: $response->getContent(),
|
||||
associative: true,
|
||||
flags: JSON_THROW_ON_ERROR | JSON_INVALID_UTF8_IGNORE
|
||||
flags: JSON_THROW_ON_ERROR | JSON_INVALID_UTF8_IGNORE
|
||||
);
|
||||
|
||||
$listDirs = ag($json, 'Items', []);
|
||||
@@ -349,15 +350,15 @@ class Import
|
||||
try {
|
||||
$it = Items::fromIterable(
|
||||
iterable: httpClientChunks($this->http->stream($response)),
|
||||
options: [
|
||||
'pointer' => '/Items',
|
||||
'decoder' => new ErrorWrappingDecoder(
|
||||
innerDecoder: new ExtJsonDecoder(
|
||||
assoc: true,
|
||||
options: JSON_INVALID_UTF8_IGNORE
|
||||
)
|
||||
)
|
||||
]
|
||||
options: [
|
||||
'pointer' => '/Items',
|
||||
'decoder' => new ErrorWrappingDecoder(
|
||||
innerDecoder: new ExtJsonDecoder(
|
||||
assoc: true,
|
||||
options: JSON_INVALID_UTF8_IGNORE
|
||||
)
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
foreach ($it as $entity) {
|
||||
@@ -453,9 +454,9 @@ class Import
|
||||
Guid::fromArray(
|
||||
payload: $guid->get(guids: $providersId, context: $logContext),
|
||||
context: [
|
||||
'backend' => $context->backendName,
|
||||
...$logContext,
|
||||
]
|
||||
'backend' => $context->backendName,
|
||||
...$logContext,
|
||||
]
|
||||
)->getAll()
|
||||
);
|
||||
}
|
||||
@@ -524,19 +525,19 @@ class Import
|
||||
|
||||
$entity = $this->createEntity(
|
||||
context: $context,
|
||||
guid: $guid,
|
||||
item: $item,
|
||||
opts: $opts + [
|
||||
'library' => ag($logContext, 'library.id'),
|
||||
'override' => [
|
||||
iState::COLUMN_EXTRA => [
|
||||
$context->backendName => [
|
||||
iState::COLUMN_EXTRA_EVENT => 'task.import',
|
||||
iState::COLUMN_EXTRA_DATE => makeDate('now'),
|
||||
],
|
||||
],
|
||||
]
|
||||
],
|
||||
guid: $guid,
|
||||
item: $item,
|
||||
opts: $opts + [
|
||||
'library' => ag($logContext, 'library.id'),
|
||||
'override' => [
|
||||
iState::COLUMN_EXTRA => [
|
||||
$context->backendName => [
|
||||
iState::COLUMN_EXTRA_EVENT => 'task.import',
|
||||
iState::COLUMN_EXTRA_DATE => makeDate('now'),
|
||||
],
|
||||
],
|
||||
]
|
||||
],
|
||||
);
|
||||
|
||||
if (false === $entity->hasGuids() && false === $entity->hasRelativeGuid()) {
|
||||
|
||||
@@ -143,7 +143,7 @@ final class ParseWebhook
|
||||
$context->backendName => [
|
||||
iState::COLUMN_WATCHED => true === $isPlayed ? '1' : '0',
|
||||
iState::COLUMN_GUIDS => $guid->parse(
|
||||
guids: $providersId,
|
||||
guids: $providersId,
|
||||
context: $logContext
|
||||
),
|
||||
]
|
||||
@@ -170,31 +170,31 @@ final class ParseWebhook
|
||||
|
||||
$entity = $this->createEntity(
|
||||
context: $context,
|
||||
guid: $guid,
|
||||
item: $obj,
|
||||
opts: ['override' => $fields, Options::DISABLE_GUID => $disableGuid],
|
||||
guid: $guid,
|
||||
item: $obj,
|
||||
opts: ['override' => $fields, Options::DISABLE_GUID => $disableGuid],
|
||||
)->setIsTainted(isTainted: true === in_array($event, self::WEBHOOK_TAINTED_EVENTS));
|
||||
|
||||
if (false === $entity->hasGuids() && false === $entity->hasRelativeGuid()) {
|
||||
return new Response(
|
||||
status: false,
|
||||
error: new Error(
|
||||
message: 'Ignoring [%(backend)] [%(title)] webhook event. No valid/supported external ids.',
|
||||
context: [
|
||||
'backend' => $context->backendName,
|
||||
'title' => $entity->getName(),
|
||||
'context' => [
|
||||
'attributes' => $request->getAttributes(),
|
||||
'parsed' => $entity->getAll(),
|
||||
'payload' => $request->getParsedBody(),
|
||||
],
|
||||
],
|
||||
level: Levels::ERROR
|
||||
),
|
||||
extra: [
|
||||
'http_code' => 200,
|
||||
'message' => $context->backendName . ': Import ignored. No valid/supported external ids.'
|
||||
error: new Error(
|
||||
message: 'Ignoring [%(backend)] [%(title)] webhook event. No valid/supported external ids.',
|
||||
context: [
|
||||
'backend' => $context->backendName,
|
||||
'title' => $entity->getName(),
|
||||
'context' => [
|
||||
'attributes' => $request->getAttributes(),
|
||||
'parsed' => $entity->getAll(),
|
||||
'payload' => $request->getParsedBody(),
|
||||
],
|
||||
],
|
||||
level: Levels::ERROR
|
||||
),
|
||||
extra: [
|
||||
'http_code' => 200,
|
||||
'message' => $context->backendName . ': Import ignored. No valid/supported external ids.'
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -202,28 +202,28 @@ final class ParseWebhook
|
||||
} catch (Throwable $e) {
|
||||
return new Response(
|
||||
status: false,
|
||||
error: new Error(
|
||||
message: 'Unhandled exception was thrown during [%(backend)] webhook event parsing.',
|
||||
context: [
|
||||
'backend' => $context->backendName,
|
||||
'exception' => [
|
||||
'file' => $e->getFile(),
|
||||
'line' => $e->getLine(),
|
||||
'kind' => get_class($e),
|
||||
'message' => $e->getMessage(),
|
||||
'trace' => $context->trace ? $e->getTrace() : [],
|
||||
],
|
||||
'context' => [
|
||||
'attributes' => $request->getAttributes(),
|
||||
'payload' => $request->getParsedBody(),
|
||||
],
|
||||
],
|
||||
level: Levels::ERROR
|
||||
),
|
||||
extra: [
|
||||
'http_code' => 200,
|
||||
'message' => $context->backendName . ': Failed to handle payload. Check logs.'
|
||||
error: new Error(
|
||||
message: 'Unhandled exception was thrown during [%(backend)] webhook event parsing.',
|
||||
context: [
|
||||
'backend' => $context->backendName,
|
||||
'exception' => [
|
||||
'file' => $e->getFile(),
|
||||
'line' => $e->getLine(),
|
||||
'kind' => get_class($e),
|
||||
'message' => $e->getMessage(),
|
||||
'trace' => $context->trace ? $e->getTrace() : [],
|
||||
],
|
||||
'context' => [
|
||||
'attributes' => $request->getAttributes(),
|
||||
'payload' => $request->getParsedBody(),
|
||||
],
|
||||
],
|
||||
level: Levels::ERROR
|
||||
),
|
||||
extra: [
|
||||
'http_code' => 200,
|
||||
'message' => $context->backendName . ': Failed to handle payload. Check logs.'
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,10 +5,10 @@ declare(strict_types=1);
|
||||
namespace App\Backends\Jellyfin\Action;
|
||||
|
||||
use App\Backends\Common\CommonTrait;
|
||||
use App\Backends\Common\Context;
|
||||
use App\Backends\Common\Error;
|
||||
use App\Backends\Common\Levels;
|
||||
use App\Backends\Common\Response;
|
||||
use App\Backends\Common\Context;
|
||||
use App\Backends\Jellyfin\JellyfinClient;
|
||||
use App\Libs\Options;
|
||||
use JsonException;
|
||||
@@ -79,22 +79,22 @@ class SearchQuery
|
||||
if (200 !== $response->getStatusCode()) {
|
||||
return new Response(
|
||||
status: false,
|
||||
error: new Error(
|
||||
message: 'Search request for [%(query)] in [%(backend)] returned with unexpected [%(status_code)] status code.',
|
||||
context: [
|
||||
'backend' => $context->backendName,
|
||||
'query' => $query,
|
||||
'status_code' => $response->getStatusCode(),
|
||||
],
|
||||
level: Levels::ERROR
|
||||
),
|
||||
error: new Error(
|
||||
message: 'Search request for [%(query)] in [%(backend)] returned with unexpected [%(status_code)] status code.',
|
||||
context: [
|
||||
'backend' => $context->backendName,
|
||||
'query' => $query,
|
||||
'status_code' => $response->getStatusCode(),
|
||||
],
|
||||
level: Levels::ERROR
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
$json = json_decode(
|
||||
json: $response->getContent(),
|
||||
json: $response->getContent(),
|
||||
associative: true,
|
||||
flags: JSON_THROW_ON_ERROR | JSON_INVALID_UTF8_IGNORE
|
||||
flags: JSON_THROW_ON_ERROR | JSON_INVALID_UTF8_IGNORE
|
||||
);
|
||||
|
||||
if ($context->trace) {
|
||||
|
||||
@@ -123,8 +123,8 @@ trait JellyfinActionTrait
|
||||
if (null !== $parentId) {
|
||||
$builder[iState::COLUMN_PARENT] = $this->getEpisodeParent(
|
||||
context: $context,
|
||||
guid: $guid,
|
||||
id: $parentId
|
||||
guid: $guid,
|
||||
id: $parentId
|
||||
);
|
||||
$metadata[iState::COLUMN_PARENT] = $builder[iState::COLUMN_PARENT];
|
||||
}
|
||||
@@ -219,9 +219,9 @@ trait JellyfinActionTrait
|
||||
Guid::fromArray(
|
||||
payload: $guid->get(guids: $providersId, context: $logContext),
|
||||
context: [
|
||||
'backend' => $context->backendName,
|
||||
...$logContext,
|
||||
]
|
||||
'backend' => $context->backendName,
|
||||
...$logContext,
|
||||
]
|
||||
)->getAll()
|
||||
);
|
||||
|
||||
|
||||
@@ -70,9 +70,9 @@ final class Backup extends Import
|
||||
|
||||
$entity = $this->createEntity(
|
||||
context: $context,
|
||||
guid: $guid,
|
||||
item: $item,
|
||||
opts: $opts
|
||||
guid: $guid,
|
||||
item: $item,
|
||||
opts: $opts
|
||||
);
|
||||
|
||||
$arr = [
|
||||
|
||||
@@ -88,9 +88,9 @@ final class Export extends Import
|
||||
|
||||
$rItem = $this->createEntity(
|
||||
context: $context,
|
||||
guid: $guid,
|
||||
item: $item,
|
||||
opts: $opts
|
||||
guid: $guid,
|
||||
item: $item,
|
||||
opts: $opts
|
||||
);
|
||||
|
||||
if (!$rItem->hasGuids() && !$rItem->hasRelativeGuid()) {
|
||||
|
||||
@@ -5,10 +5,10 @@ declare(strict_types=1);
|
||||
namespace App\Backends\Plex\Action;
|
||||
|
||||
use App\Backends\Common\CommonTrait;
|
||||
use App\Backends\Common\Context;
|
||||
use App\Backends\Common\Error;
|
||||
use App\Backends\Common\Levels;
|
||||
use App\Backends\Common\Response;
|
||||
use App\Backends\Common\Context;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Psr\SimpleCache\CacheInterface;
|
||||
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
||||
@@ -56,25 +56,25 @@ final class GetIdentifier
|
||||
if (200 !== $response->getStatusCode()) {
|
||||
return new Response(
|
||||
status: false,
|
||||
error: new Error(
|
||||
message: 'Request for [%(backend)] %(action) returned with unexpected [%(status_code)] status code.',
|
||||
context: [
|
||||
'action' => $this->action,
|
||||
'client' => $context->clientName,
|
||||
'backend' => $context->backendName,
|
||||
'status_code' => $response->getStatusCode(),
|
||||
],
|
||||
level: Levels::WARNING
|
||||
)
|
||||
error: new Error(
|
||||
message: 'Request for [%(backend)] %(action) returned with unexpected [%(status_code)] status code.',
|
||||
context: [
|
||||
'action' => $this->action,
|
||||
'client' => $context->clientName,
|
||||
'backend' => $context->backendName,
|
||||
'status_code' => $response->getStatusCode(),
|
||||
],
|
||||
level: Levels::WARNING
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$content = $response->getContent();
|
||||
|
||||
$item = json_decode(
|
||||
json: $content,
|
||||
json: $content,
|
||||
associative: true,
|
||||
flags: JSON_THROW_ON_ERROR | JSON_INVALID_UTF8_IGNORE
|
||||
flags: JSON_THROW_ON_ERROR | JSON_INVALID_UTF8_IGNORE
|
||||
);
|
||||
|
||||
if (true === $context->trace) {
|
||||
@@ -87,11 +87,11 @@ final class GetIdentifier
|
||||
}
|
||||
|
||||
return new Response(
|
||||
status: true,
|
||||
status: true,
|
||||
response: ag($item, 'MediaContainer.machineIdentifier', null)
|
||||
);
|
||||
},
|
||||
action: $this->action
|
||||
action: $this->action
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,10 +5,10 @@ declare(strict_types=1);
|
||||
namespace App\Backends\Plex\Action;
|
||||
|
||||
use App\Backends\Common\CommonTrait;
|
||||
use App\Backends\Common\Context;
|
||||
use App\Backends\Common\Error;
|
||||
use App\Backends\Common\Levels;
|
||||
use App\Backends\Common\Response;
|
||||
use App\Backends\Common\Context;
|
||||
use App\Backends\Plex\PlexClient;
|
||||
use App\Libs\Options;
|
||||
use JsonException;
|
||||
@@ -55,14 +55,14 @@ final class GetLibrariesList
|
||||
if (200 !== $response->getStatusCode()) {
|
||||
return new Response(
|
||||
status: false,
|
||||
error: new Error(
|
||||
message: 'Request for [%(backend)] libraries returned with unexpected [%(status_code)] status code.',
|
||||
context: [
|
||||
'backend' => $context->backendName,
|
||||
'status_code' => $response->getStatusCode(),
|
||||
],
|
||||
level: Levels::ERROR
|
||||
),
|
||||
error: new Error(
|
||||
message: 'Request for [%(backend)] libraries returned with unexpected [%(status_code)] status code.',
|
||||
context: [
|
||||
'backend' => $context->backendName,
|
||||
'status_code' => $response->getStatusCode(),
|
||||
],
|
||||
level: Levels::ERROR
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -87,16 +87,16 @@ final class GetLibrariesList
|
||||
if (empty($listDirs)) {
|
||||
return new Response(
|
||||
status: false,
|
||||
error: new Error(
|
||||
message: 'Request for [%(backend)] libraries returned empty list.',
|
||||
context: [
|
||||
'backend' => $context->backendName,
|
||||
'response' => [
|
||||
'body' => $json
|
||||
],
|
||||
],
|
||||
level: Levels::WARNING
|
||||
),
|
||||
error: new Error(
|
||||
message: 'Request for [%(backend)] libraries returned empty list.',
|
||||
context: [
|
||||
'backend' => $context->backendName,
|
||||
'response' => [
|
||||
'body' => $json
|
||||
],
|
||||
],
|
||||
level: Levels::WARNING
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,11 +5,11 @@ declare(strict_types=1);
|
||||
namespace App\Backends\Plex\Action;
|
||||
|
||||
use App\Backends\Common\CommonTrait;
|
||||
use App\Backends\Common\Context;
|
||||
use App\Backends\Common\Error;
|
||||
use App\Backends\Common\GuidInterface as iGuid;
|
||||
use App\Backends\Common\Levels;
|
||||
use App\Backends\Common\Response;
|
||||
use App\Backends\Common\Context;
|
||||
use App\Backends\Plex\PlexActionTrait;
|
||||
use App\Backends\Plex\PlexClient;
|
||||
use App\Libs\Options;
|
||||
@@ -59,17 +59,17 @@ final class GetLibrary
|
||||
if (null === ($section = ag($libraries, $id))) {
|
||||
return new Response(
|
||||
status: false,
|
||||
error: new Error(
|
||||
message: 'No Library with id [%(id)] found in [%(backend)] response.',
|
||||
context: [
|
||||
'id' => $id,
|
||||
'backend' => $context->backendName,
|
||||
'response' => [
|
||||
'body' => $libraries
|
||||
],
|
||||
],
|
||||
level: Levels::WARNING
|
||||
),
|
||||
error: new Error(
|
||||
message: 'No Library with id [%(id)] found in [%(backend)] response.',
|
||||
context: [
|
||||
'id' => $id,
|
||||
'backend' => $context->backendName,
|
||||
'response' => [
|
||||
'body' => $libraries
|
||||
],
|
||||
],
|
||||
level: Levels::WARNING
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -86,14 +86,14 @@ final class GetLibrary
|
||||
if (true !== in_array(ag($logContext, 'library.type'), [PlexClient::TYPE_MOVIE, PlexClient::TYPE_SHOW])) {
|
||||
return new Response(
|
||||
status: false,
|
||||
error: new Error(
|
||||
message: 'The Requested [%(backend)] Library [%(library.title)] returned with unsupported type [%(library.type)].',
|
||||
context: [
|
||||
'backend' => $context->backendName,
|
||||
...$logContext,
|
||||
],
|
||||
level: Levels::WARNING
|
||||
),
|
||||
error: new Error(
|
||||
message: 'The Requested [%(backend)] Library [%(library.title)] returned with unsupported type [%(library.type)].',
|
||||
context: [
|
||||
'backend' => $context->backendName,
|
||||
...$logContext,
|
||||
],
|
||||
level: Levels::WARNING
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -118,31 +118,31 @@ final class GetLibrary
|
||||
if (200 !== $response->getStatusCode()) {
|
||||
return new Response(
|
||||
status: false,
|
||||
error: new Error(
|
||||
message: 'Request for [%(backend)] library [%(library.title)] returned with unexpected [%(status_code)] status code.',
|
||||
context: [
|
||||
'backend' => $context->backendName,
|
||||
'status_code' => $response->getStatusCode(),
|
||||
...$logContext,
|
||||
],
|
||||
level: Levels::ERROR
|
||||
),
|
||||
error: new Error(
|
||||
message: 'Request for [%(backend)] library [%(library.title)] returned with unexpected [%(status_code)] status code.',
|
||||
context: [
|
||||
'backend' => $context->backendName,
|
||||
'status_code' => $response->getStatusCode(),
|
||||
...$logContext,
|
||||
],
|
||||
level: Levels::ERROR
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
$it = Items::fromIterable(
|
||||
iterable: httpClientChunks(
|
||||
stream: $this->http->stream($response)
|
||||
),
|
||||
options: [
|
||||
'pointer' => '/MediaContainer/Metadata',
|
||||
'decoder' => new ErrorWrappingDecoder(
|
||||
innerDecoder: new ExtJsonDecoder(
|
||||
assoc: true,
|
||||
options: JSON_INVALID_UTF8_IGNORE
|
||||
)
|
||||
)
|
||||
]
|
||||
stream: $this->http->stream($response)
|
||||
),
|
||||
options: [
|
||||
'pointer' => '/MediaContainer/Metadata',
|
||||
'decoder' => new ErrorWrappingDecoder(
|
||||
innerDecoder: new ExtJsonDecoder(
|
||||
assoc: true,
|
||||
options: JSON_INVALID_UTF8_IGNORE
|
||||
)
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
$list = $requests = [];
|
||||
@@ -220,9 +220,9 @@ final class GetLibrary
|
||||
}
|
||||
|
||||
$json = json_decode(
|
||||
json: $response->getContent(),
|
||||
json: $response->getContent(),
|
||||
associative: true,
|
||||
flags: JSON_THROW_ON_ERROR | JSON_INVALID_UTF8_IGNORE
|
||||
flags: JSON_THROW_ON_ERROR | JSON_INVALID_UTF8_IGNORE
|
||||
);
|
||||
|
||||
$list[] = $this->process(
|
||||
@@ -235,22 +235,22 @@ final class GetLibrary
|
||||
} catch (JsonException|HttpExceptionInterface $e) {
|
||||
return new Response(
|
||||
status: false,
|
||||
error: new Error(
|
||||
message: 'Unhandled exception was thrown during request for [%(backend)] %(item.type) [%(item.title)] metadata.',
|
||||
context: [
|
||||
'backend' => $context->backendName,
|
||||
'exception' => [
|
||||
'file' => $e->getFile(),
|
||||
'line' => $e->getLine(),
|
||||
'kind' => get_class($e),
|
||||
'message' => $e->getMessage(),
|
||||
'trace' => $context->trace ? $e->getTrace() : [],
|
||||
],
|
||||
...$requestContext,
|
||||
],
|
||||
level: Levels::WARNING,
|
||||
previous: $e
|
||||
)
|
||||
error: new Error(
|
||||
message: 'Unhandled exception was thrown during request for [%(backend)] %(item.type) [%(item.title)] metadata.',
|
||||
context: [
|
||||
'backend' => $context->backendName,
|
||||
'exception' => [
|
||||
'file' => $e->getFile(),
|
||||
'line' => $e->getLine(),
|
||||
'kind' => get_class($e),
|
||||
'message' => $e->getMessage(),
|
||||
'trace' => $context->trace ? $e->getTrace() : [],
|
||||
],
|
||||
...$requestContext,
|
||||
],
|
||||
level: Levels::WARNING,
|
||||
previous: $e
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,9 +5,9 @@ declare(strict_types=1);
|
||||
namespace App\Backends\Plex\Action;
|
||||
|
||||
use App\Backends\Common\CommonTrait;
|
||||
use App\Backends\Common\Context;
|
||||
use App\Backends\Common\Error;
|
||||
use App\Backends\Common\Response;
|
||||
use App\Backends\Common\Context;
|
||||
use App\Libs\Options;
|
||||
use DateInterval;
|
||||
use Psr\Log\LoggerInterface;
|
||||
@@ -68,31 +68,31 @@ final class GetMetaData
|
||||
if (200 !== $response->getStatusCode()) {
|
||||
return new Response(
|
||||
status: false,
|
||||
error: new Error(
|
||||
message: 'Request for [%(backend)] item [%(id)] returned with unexpected [%(status_code)] status code.',
|
||||
context: [
|
||||
'id' => $id,
|
||||
'client' => $context->clientName,
|
||||
'backend' => $context->backendName,
|
||||
'status_code' => $response->getStatusCode(),
|
||||
]
|
||||
)
|
||||
error: new Error(
|
||||
message: 'Request for [%(backend)] item [%(id)] returned with unexpected [%(status_code)] status code.',
|
||||
context: [
|
||||
'id' => $id,
|
||||
'client' => $context->clientName,
|
||||
'backend' => $context->backendName,
|
||||
'status_code' => $response->getStatusCode(),
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$content = $response->getContent();
|
||||
|
||||
$item = json_decode(
|
||||
json: $content,
|
||||
json: $content,
|
||||
associative: true,
|
||||
flags: JSON_THROW_ON_ERROR | JSON_INVALID_UTF8_IGNORE
|
||||
flags: JSON_THROW_ON_ERROR | JSON_INVALID_UTF8_IGNORE
|
||||
);
|
||||
|
||||
if (null !== $cacheKey) {
|
||||
$this->cache->set(
|
||||
key: $cacheKey,
|
||||
key: $cacheKey,
|
||||
value: $item,
|
||||
ttl: $opts[Options::CACHE_TTL] ?? new DateInterval('PT5M')
|
||||
ttl: $opts[Options::CACHE_TTL] ?? new DateInterval('PT5M')
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,10 +5,10 @@ declare(strict_types=1);
|
||||
namespace App\Backends\Plex\Action;
|
||||
|
||||
use App\Backends\Common\CommonTrait;
|
||||
use App\Backends\Common\Context;
|
||||
use App\Backends\Common\Error;
|
||||
use App\Backends\Common\Levels;
|
||||
use App\Backends\Common\Response;
|
||||
use App\Backends\Common\Context;
|
||||
use App\Libs\Container;
|
||||
use App\Libs\Options;
|
||||
use JsonException;
|
||||
@@ -66,21 +66,21 @@ final class GetUsersList
|
||||
if (200 !== $response->getStatusCode()) {
|
||||
return new Response(
|
||||
status: false,
|
||||
error: new Error(
|
||||
message: 'Request for [%(backend)] users list returned with unexpected [%(status_code)] status code.',
|
||||
context: [
|
||||
'backend' => $context->backendName,
|
||||
'status_code' => $response->getStatusCode(),
|
||||
],
|
||||
level: Levels::ERROR
|
||||
),
|
||||
error: new Error(
|
||||
message: 'Request for [%(backend)] users list returned with unexpected [%(status_code)] status code.',
|
||||
context: [
|
||||
'backend' => $context->backendName,
|
||||
'status_code' => $response->getStatusCode(),
|
||||
],
|
||||
level: Levels::ERROR
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
$json = json_decode(
|
||||
json: $response->getContent(),
|
||||
json: $response->getContent(),
|
||||
associative: true,
|
||||
flags: JSON_THROW_ON_ERROR | JSON_INVALID_UTF8_IGNORE
|
||||
flags: JSON_THROW_ON_ERROR | JSON_INVALID_UTF8_IGNORE
|
||||
);
|
||||
|
||||
if ($context->trace) {
|
||||
@@ -115,8 +115,8 @@ final class GetUsersList
|
||||
|
||||
if (true === (bool)ag($opts, 'tokens')) {
|
||||
$tokenRequest = $this->getUserToken(
|
||||
context: $context,
|
||||
userId: ag($user, 'uuid'),
|
||||
context: $context,
|
||||
userId: ag($user, 'uuid'),
|
||||
username: ag($data, 'name'),
|
||||
);
|
||||
|
||||
@@ -175,23 +175,23 @@ final class GetUsersList
|
||||
if (201 !== $response->getStatusCode()) {
|
||||
return new Response(
|
||||
status: false,
|
||||
error: new Error(
|
||||
message: 'Request for [%(backend)] user [%(username)] temporary access token responded with unexpected [%(status_code)] status code.',
|
||||
context: [
|
||||
'backend' => $context->backendName,
|
||||
'username' => $username,
|
||||
'user_id' => $userId,
|
||||
'status_code' => $response->getStatusCode(),
|
||||
],
|
||||
level: Levels::ERROR
|
||||
),
|
||||
error: new Error(
|
||||
message: 'Request for [%(backend)] user [%(username)] temporary access token responded with unexpected [%(status_code)] status code.',
|
||||
context: [
|
||||
'backend' => $context->backendName,
|
||||
'username' => $username,
|
||||
'user_id' => $userId,
|
||||
'status_code' => $response->getStatusCode(),
|
||||
],
|
||||
level: Levels::ERROR
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
$json = json_decode(
|
||||
json: $response->getContent(),
|
||||
json: $response->getContent(),
|
||||
associative: true,
|
||||
flags: JSON_THROW_ON_ERROR | JSON_INVALID_UTF8_IGNORE
|
||||
flags: JSON_THROW_ON_ERROR | JSON_INVALID_UTF8_IGNORE
|
||||
);
|
||||
|
||||
if ($context->trace) {
|
||||
@@ -233,9 +233,9 @@ final class GetUsersList
|
||||
]);
|
||||
|
||||
$json = json_decode(
|
||||
json: $response->getContent(),
|
||||
json: $response->getContent(),
|
||||
associative: true,
|
||||
flags: JSON_THROW_ON_ERROR | JSON_INVALID_UTF8_IGNORE
|
||||
flags: JSON_THROW_ON_ERROR | JSON_INVALID_UTF8_IGNORE
|
||||
);
|
||||
|
||||
if ($context->trace) {
|
||||
@@ -257,35 +257,35 @@ final class GetUsersList
|
||||
|
||||
return new Response(
|
||||
status: false,
|
||||
error: new Error(
|
||||
message: 'No permanent access token found in [%(backend)] user [%(username)] response.',
|
||||
context: [
|
||||
'backend' => $context->backendName,
|
||||
'username' => $username,
|
||||
'user_id' => $userId,
|
||||
],
|
||||
level: Levels::ERROR
|
||||
),
|
||||
error: new Error(
|
||||
message: 'No permanent access token found in [%(backend)] user [%(username)] response.',
|
||||
context: [
|
||||
'backend' => $context->backendName,
|
||||
'username' => $username,
|
||||
'user_id' => $userId,
|
||||
],
|
||||
level: Levels::ERROR
|
||||
),
|
||||
);
|
||||
} catch (Throwable $e) {
|
||||
return new Response(
|
||||
status: false,
|
||||
error: new Error(
|
||||
message: 'Unhandled exception was thrown during request for [%(backend)] [%(username)] access token.',
|
||||
context: [
|
||||
'backend' => $context->backendName,
|
||||
'username' => $username,
|
||||
'user_id' => $userId,
|
||||
'exception' => [
|
||||
'file' => after($e->getFile(), ROOT_PATH),
|
||||
'line' => $e->getLine(),
|
||||
'kind' => get_class($e),
|
||||
'message' => $e->getMessage(),
|
||||
'trace' => $context->trace ? $e->getTrace() : [],
|
||||
],
|
||||
],
|
||||
level: Levels::ERROR
|
||||
),
|
||||
error: new Error(
|
||||
message: 'Unhandled exception was thrown during request for [%(backend)] [%(username)] access token.',
|
||||
context: [
|
||||
'backend' => $context->backendName,
|
||||
'username' => $username,
|
||||
'user_id' => $userId,
|
||||
'exception' => [
|
||||
'file' => after($e->getFile(), ROOT_PATH),
|
||||
'line' => $e->getLine(),
|
||||
'kind' => get_class($e),
|
||||
'message' => $e->getMessage(),
|
||||
'trace' => $context->trace ? $e->getTrace() : [],
|
||||
],
|
||||
],
|
||||
level: Levels::ERROR
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,18 +22,19 @@ use JsonMachine\Items;
|
||||
use JsonMachine\JsonDecoder\DecodingError;
|
||||
use JsonMachine\JsonDecoder\ErrorWrappingDecoder;
|
||||
use JsonMachine\JsonDecoder\ExtJsonDecoder;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Psr\Log\LoggerInterface as iLogger;
|
||||
use Symfony\Contracts\HttpClient\Exception\ExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
||||
use Symfony\Contracts\HttpClient\HttpClientInterface as iHttp;
|
||||
use Symfony\Contracts\HttpClient\ResponseInterface as iResponse;
|
||||
use Throwable;
|
||||
|
||||
class Import
|
||||
{
|
||||
use CommonTrait, PlexActionTrait;
|
||||
use CommonTrait;
|
||||
use PlexActionTrait;
|
||||
|
||||
public function __construct(protected HttpClientInterface $http, protected LoggerInterface $logger)
|
||||
public function __construct(protected iHttp $http, protected iLogger $logger)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -56,15 +57,15 @@ class Import
|
||||
return $this->tryResponse($context, fn() => $this->getLibraries(
|
||||
context: $context,
|
||||
handle: fn(array $logContext = []) => fn(iResponse $response) => $this->handle(
|
||||
context: $context,
|
||||
response: $response,
|
||||
context: $context,
|
||||
response: $response,
|
||||
callback: fn(array $item, array $logContext = []) => $this->process(
|
||||
context: $context,
|
||||
guid: $guid,
|
||||
mapper: $mapper,
|
||||
item: $item,
|
||||
context: $context,
|
||||
guid: $guid,
|
||||
mapper: $mapper,
|
||||
item: $item,
|
||||
logContext: $logContext,
|
||||
opts: $opts + ['after' => $after],
|
||||
opts: $opts + ['after' => $after],
|
||||
),
|
||||
logContext: $logContext
|
||||
),
|
||||
@@ -110,9 +111,9 @@ class Import
|
||||
}
|
||||
|
||||
$json = json_decode(
|
||||
json: $response->getContent(),
|
||||
json: $response->getContent(),
|
||||
associative: true,
|
||||
flags: JSON_THROW_ON_ERROR | JSON_INVALID_UTF8_IGNORE
|
||||
flags: JSON_THROW_ON_ERROR | JSON_INVALID_UTF8_IGNORE
|
||||
);
|
||||
|
||||
$listDirs = ag($json, 'MediaContainer.Directory', []);
|
||||
@@ -374,15 +375,15 @@ class Import
|
||||
try {
|
||||
$it = Items::fromIterable(
|
||||
iterable: httpClientChunks($this->http->stream($response)),
|
||||
options: [
|
||||
'pointer' => '/MediaContainer/Metadata',
|
||||
'decoder' => new ErrorWrappingDecoder(
|
||||
innerDecoder: new ExtJsonDecoder(
|
||||
assoc: true,
|
||||
options: JSON_INVALID_UTF8_IGNORE
|
||||
)
|
||||
)
|
||||
]
|
||||
options: [
|
||||
'pointer' => '/MediaContainer/Metadata',
|
||||
'decoder' => new ErrorWrappingDecoder(
|
||||
innerDecoder: new ExtJsonDecoder(
|
||||
assoc: true,
|
||||
options: JSON_INVALID_UTF8_IGNORE
|
||||
)
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
foreach ($it as $entity) {
|
||||
@@ -566,18 +567,18 @@ class Import
|
||||
|
||||
$entity = $this->createEntity(
|
||||
context: $context,
|
||||
guid: $guid,
|
||||
item: $item,
|
||||
opts: $opts + [
|
||||
'override' => [
|
||||
iState::COLUMN_EXTRA => [
|
||||
$context->backendName => [
|
||||
iState::COLUMN_EXTRA_EVENT => 'task.import',
|
||||
iState::COLUMN_EXTRA_DATE => makeDate('now'),
|
||||
],
|
||||
],
|
||||
],
|
||||
]
|
||||
guid: $guid,
|
||||
item: $item,
|
||||
opts: $opts + [
|
||||
'override' => [
|
||||
iState::COLUMN_EXTRA => [
|
||||
$context->backendName => [
|
||||
iState::COLUMN_EXTRA_EVENT => 'task.import',
|
||||
iState::COLUMN_EXTRA_DATE => makeDate('now'),
|
||||
],
|
||||
],
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
if (!$entity->hasGuids() && !$entity->hasRelativeGuid()) {
|
||||
|
||||
@@ -155,7 +155,7 @@ final class ParseWebhook
|
||||
$context->backendName => [
|
||||
iState::COLUMN_WATCHED => true === $isPlayed ? '1' : '0',
|
||||
iState::COLUMN_GUIDS => $guid->parse(
|
||||
guids: ag($item, 'Guid', []),
|
||||
guids: ag($item, 'Guid', []),
|
||||
context: $logContext
|
||||
),
|
||||
]
|
||||
@@ -181,31 +181,31 @@ final class ParseWebhook
|
||||
|
||||
$entity = $this->createEntity(
|
||||
context: $context,
|
||||
guid: $guid,
|
||||
item: $obj,
|
||||
opts: ['override' => $fields, Options::DISABLE_GUID => $disableGuid],
|
||||
guid: $guid,
|
||||
item: $obj,
|
||||
opts: ['override' => $fields, Options::DISABLE_GUID => $disableGuid],
|
||||
)->setIsTainted(isTainted: true === in_array($event, self::WEBHOOK_TAINTED_EVENTS));
|
||||
|
||||
if (false === $entity->hasGuids() && false === $entity->hasRelativeGuid()) {
|
||||
return new Response(
|
||||
status: false,
|
||||
error: new Error(
|
||||
message: 'Ignoring [%(backend)] [%(title)] webhook event. No valid/supported external ids.',
|
||||
context: [
|
||||
'backend' => $context->backendName,
|
||||
'title' => $entity->getName(),
|
||||
'context' => [
|
||||
'attributes' => $request->getAttributes(),
|
||||
'parsed' => $entity->getAll(),
|
||||
'payload' => $request->getParsedBody(),
|
||||
],
|
||||
],
|
||||
level: Levels::ERROR
|
||||
),
|
||||
extra: [
|
||||
'http_code' => 200,
|
||||
'message' => $context->backendName . ': Import ignored. No valid/supported external ids.'
|
||||
error: new Error(
|
||||
message: 'Ignoring [%(backend)] [%(title)] webhook event. No valid/supported external ids.',
|
||||
context: [
|
||||
'backend' => $context->backendName,
|
||||
'title' => $entity->getName(),
|
||||
'context' => [
|
||||
'attributes' => $request->getAttributes(),
|
||||
'parsed' => $entity->getAll(),
|
||||
'payload' => $request->getParsedBody(),
|
||||
],
|
||||
],
|
||||
level: Levels::ERROR
|
||||
),
|
||||
extra: [
|
||||
'http_code' => 200,
|
||||
'message' => $context->backendName . ': Import ignored. No valid/supported external ids.'
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -213,28 +213,28 @@ final class ParseWebhook
|
||||
} catch (Throwable $e) {
|
||||
return new Response(
|
||||
status: false,
|
||||
error: new Error(
|
||||
message: 'Unhandled exception was thrown during [%(backend)] webhook event parsing.',
|
||||
context: [
|
||||
'backend' => $context->backendName,
|
||||
'exception' => [
|
||||
'file' => $e->getFile(),
|
||||
'line' => $e->getLine(),
|
||||
'kind' => get_class($e),
|
||||
'message' => $e->getMessage(),
|
||||
'trace' => $context->trace ? $e->getTrace() : [],
|
||||
],
|
||||
'context' => [
|
||||
'attributes' => $request->getAttributes(),
|
||||
'payload' => $request->getParsedBody(),
|
||||
],
|
||||
],
|
||||
level: Levels::ERROR
|
||||
),
|
||||
extra: [
|
||||
'http_code' => 200,
|
||||
'message' => $context->backendName . ': Failed to handle payload. Check logs.'
|
||||
error: new Error(
|
||||
message: 'Unhandled exception was thrown during [%(backend)] webhook event parsing.',
|
||||
context: [
|
||||
'backend' => $context->backendName,
|
||||
'exception' => [
|
||||
'file' => $e->getFile(),
|
||||
'line' => $e->getLine(),
|
||||
'kind' => get_class($e),
|
||||
'message' => $e->getMessage(),
|
||||
'trace' => $context->trace ? $e->getTrace() : [],
|
||||
],
|
||||
'context' => [
|
||||
'attributes' => $request->getAttributes(),
|
||||
'payload' => $request->getParsedBody(),
|
||||
],
|
||||
],
|
||||
level: Levels::ERROR
|
||||
),
|
||||
extra: [
|
||||
'http_code' => 200,
|
||||
'message' => $context->backendName . ': Failed to handle payload. Check logs.'
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,10 +5,10 @@ declare(strict_types=1);
|
||||
namespace App\Backends\Plex\Action;
|
||||
|
||||
use App\Backends\Common\CommonTrait;
|
||||
use App\Backends\Common\Context;
|
||||
use App\Backends\Common\Error;
|
||||
use App\Backends\Common\Levels;
|
||||
use App\Backends\Common\Response;
|
||||
use App\Backends\Common\Context;
|
||||
use App\Libs\Options;
|
||||
use JsonException;
|
||||
use Psr\Log\LoggerInterface;
|
||||
@@ -81,22 +81,22 @@ final class SearchQuery
|
||||
if (200 !== $response->getStatusCode()) {
|
||||
return new Response(
|
||||
status: false,
|
||||
error: new Error(
|
||||
message: 'Search request for [%(query)] in [%(backend)] returned with unexpected [%(status_code)] status code.',
|
||||
context: [
|
||||
'backend' => $context->backendName,
|
||||
'query' => $query,
|
||||
'status_code' => $response->getStatusCode(),
|
||||
],
|
||||
level: Levels::ERROR
|
||||
),
|
||||
error: new Error(
|
||||
message: 'Search request for [%(query)] in [%(backend)] returned with unexpected [%(status_code)] status code.',
|
||||
context: [
|
||||
'backend' => $context->backendName,
|
||||
'query' => $query,
|
||||
'status_code' => $response->getStatusCode(),
|
||||
],
|
||||
level: Levels::ERROR
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
$json = json_decode(
|
||||
json: $response->getContent(),
|
||||
json: $response->getContent(),
|
||||
associative: true,
|
||||
flags: JSON_THROW_ON_ERROR | JSON_INVALID_UTF8_IGNORE
|
||||
flags: JSON_THROW_ON_ERROR | JSON_INVALID_UTF8_IGNORE
|
||||
);
|
||||
|
||||
if ($context->trace) {
|
||||
|
||||
@@ -139,8 +139,8 @@ trait PlexActionTrait
|
||||
if (null !== ($parentId = ag($item, ['grandparentRatingKey', 'parentRatingKey']))) {
|
||||
$builder[iState::COLUMN_PARENT] = $this->getEpisodeParent(
|
||||
context: $context,
|
||||
guid: $guid,
|
||||
id: $parentId
|
||||
guid: $guid,
|
||||
id: $parentId
|
||||
);
|
||||
$metadata[iState::COLUMN_PARENT] = $builder[iState::COLUMN_PARENT];
|
||||
}
|
||||
|
||||
@@ -97,9 +97,9 @@ final class PDODataMigration
|
||||
|
||||
foreach ($stmt as $row) {
|
||||
$row['meta'] = json_decode(
|
||||
json: $row['meta'] ?? '[]',
|
||||
json: $row['meta'] ?? '[]',
|
||||
associative: true,
|
||||
flags: JSON_INVALID_UTF8_IGNORE
|
||||
flags: JSON_INVALID_UTF8_IGNORE
|
||||
);
|
||||
|
||||
$extra = [
|
||||
@@ -146,10 +146,10 @@ final class PDODataMigration
|
||||
iFace::COLUMN_EPISODE => ag($row['meta'], iFace::COLUMN_EPISODE, null),
|
||||
iFace::COLUMN_PARENT => json_encode(
|
||||
value: array_intersect_key(
|
||||
$row,
|
||||
ag($row['meta'], iFace::COLUMN_PARENT, []),
|
||||
Guid::getSupported(includeVirtual: false)
|
||||
),
|
||||
$row,
|
||||
ag($row['meta'], iFace::COLUMN_PARENT, []),
|
||||
Guid::getSupported(includeVirtual: false)
|
||||
),
|
||||
flags: $this->jFlags
|
||||
),
|
||||
iFace::COLUMN_GUIDS => json_encode(
|
||||
@@ -158,32 +158,32 @@ final class PDODataMigration
|
||||
),
|
||||
iFace::COLUMN_META_DATA => json_encode(
|
||||
value: (function () use ($metadata): array {
|
||||
$list = [];
|
||||
$list = [];
|
||||
|
||||
foreach (Config::get('servers', []) as $name => $info) {
|
||||
if (true !== (bool)ag($info, 'import.enabled', false)) {
|
||||
continue;
|
||||
}
|
||||
$list[$name] = $metadata;
|
||||
}
|
||||
foreach (Config::get('servers', []) as $name => $info) {
|
||||
if (true !== (bool)ag($info, 'import.enabled', false)) {
|
||||
continue;
|
||||
}
|
||||
$list[$name] = $metadata;
|
||||
}
|
||||
|
||||
return $list;
|
||||
})(),
|
||||
return $list;
|
||||
})(),
|
||||
flags: $this->jFlags
|
||||
),
|
||||
iFace::COLUMN_EXTRA => json_encode(
|
||||
value: (function () use ($extra): array {
|
||||
$list = [];
|
||||
$list = [];
|
||||
|
||||
foreach (Config::get('servers', []) as $name => $info) {
|
||||
if (true !== (bool)ag($info, 'import.enabled', false)) {
|
||||
continue;
|
||||
}
|
||||
$list[$name] = $extra;
|
||||
}
|
||||
foreach (Config::get('servers', []) as $name => $info) {
|
||||
if (true !== (bool)ag($info, 'import.enabled', false)) {
|
||||
continue;
|
||||
}
|
||||
$list[$name] = $extra;
|
||||
}
|
||||
|
||||
return $list;
|
||||
})(),
|
||||
return $list;
|
||||
})(),
|
||||
flags: $this->jFlags
|
||||
),
|
||||
]
|
||||
@@ -262,27 +262,27 @@ final class PDODataMigration
|
||||
|
||||
foreach ($oldDB->query("SELECT * FROM state") as $row) {
|
||||
$row[iFace::COLUMN_EXTRA] = json_decode(
|
||||
json: $row[iFace::COLUMN_EXTRA] ?? '[]',
|
||||
json: $row[iFace::COLUMN_EXTRA] ?? '[]',
|
||||
associative: true,
|
||||
flags: JSON_INVALID_UTF8_IGNORE
|
||||
flags: JSON_INVALID_UTF8_IGNORE
|
||||
);
|
||||
|
||||
$row[iFace::COLUMN_GUIDS] = json_decode(
|
||||
json: $row[iFace::COLUMN_GUIDS] ?? '[]',
|
||||
json: $row[iFace::COLUMN_GUIDS] ?? '[]',
|
||||
associative: true,
|
||||
flags: JSON_INVALID_UTF8_IGNORE
|
||||
flags: JSON_INVALID_UTF8_IGNORE
|
||||
);
|
||||
|
||||
$row[iFace::COLUMN_PARENT] = json_decode(
|
||||
json: $row[iFace::COLUMN_PARENT] ?? '[]',
|
||||
json: $row[iFace::COLUMN_PARENT] ?? '[]',
|
||||
associative: true,
|
||||
flags: JSON_INVALID_UTF8_IGNORE
|
||||
flags: JSON_INVALID_UTF8_IGNORE
|
||||
);
|
||||
|
||||
$row['suids'] = json_decode(
|
||||
json: $row['suids'] ?? '[]',
|
||||
json: $row['suids'] ?? '[]',
|
||||
associative: true,
|
||||
flags: JSON_INVALID_UTF8_IGNORE
|
||||
flags: JSON_INVALID_UTF8_IGNORE
|
||||
);
|
||||
|
||||
$extra = [
|
||||
@@ -330,9 +330,9 @@ final class PDODataMigration
|
||||
iFace::COLUMN_EPISODE => $row[iFace::COLUMN_EPISODE] ?? null,
|
||||
iFace::COLUMN_PARENT => json_encode(
|
||||
value: array_intersect_key(
|
||||
$row[iFace::COLUMN_PARENT] ?? [],
|
||||
Guid::getSupported(includeVirtual: false)
|
||||
),
|
||||
$row[iFace::COLUMN_PARENT] ?? [],
|
||||
Guid::getSupported(includeVirtual: false)
|
||||
),
|
||||
flags: $this->jFlags
|
||||
),
|
||||
iFace::COLUMN_GUIDS => json_encode(
|
||||
@@ -341,37 +341,37 @@ final class PDODataMigration
|
||||
),
|
||||
iFace::COLUMN_META_DATA => json_encode(
|
||||
value: (function () use ($row, $metadata): array {
|
||||
$list = [];
|
||||
$list = [];
|
||||
|
||||
foreach (Config::get('servers', []) as $name => $info) {
|
||||
$list[$name] = [];
|
||||
if (null !== ($row['suids'][$name] ?? null)) {
|
||||
$list[$name][iFace::COLUMN_ID] = $row['suids'][$name];
|
||||
}
|
||||
foreach (Config::get('servers', []) as $name => $info) {
|
||||
$list[$name] = [];
|
||||
if (null !== ($row['suids'][$name] ?? null)) {
|
||||
$list[$name][iFace::COLUMN_ID] = $row['suids'][$name];
|
||||
}
|
||||
|
||||
$list[$name] += $metadata;
|
||||
}
|
||||
$list[$name] += $metadata;
|
||||
}
|
||||
|
||||
return $list;
|
||||
})(),
|
||||
return $list;
|
||||
})(),
|
||||
flags: $this->jFlags
|
||||
),
|
||||
iFace::COLUMN_EXTRA => json_encode(
|
||||
value: (function () use ($row, $extra): array {
|
||||
$list = [];
|
||||
$list = [];
|
||||
|
||||
foreach (Config::get('servers', []) as $name => $info) {
|
||||
$list[$name] = [];
|
||||
foreach (Config::get('servers', []) as $name => $info) {
|
||||
$list[$name] = [];
|
||||
|
||||
if (null !== ($row['suids'][$name] ?? null)) {
|
||||
continue;
|
||||
}
|
||||
if (null !== ($row['suids'][$name] ?? null)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$list[$name] += $extra;
|
||||
}
|
||||
$list[$name] += $extra;
|
||||
}
|
||||
|
||||
return $list;
|
||||
})(),
|
||||
return $list;
|
||||
})(),
|
||||
flags: $this->jFlags
|
||||
),
|
||||
];
|
||||
|
||||
@@ -161,15 +161,15 @@ final class StateEntity implements iFace
|
||||
$this->guids,
|
||||
Guid::getSupported(includeVirtual: true)
|
||||
), context: [
|
||||
'backend' => $this->via,
|
||||
'backend_id' => ag($this->getMetadata($this->via) ?? [], 'id'),
|
||||
'item' => [
|
||||
'id' => $this->id,
|
||||
'type' => $this->type,
|
||||
'year' => $this->year,
|
||||
'title' => $this->getName()
|
||||
]
|
||||
'backend' => $this->via,
|
||||
'backend_id' => ag($this->getMetadata($this->via) ?? [], 'id'),
|
||||
'item' => [
|
||||
'id' => $this->id,
|
||||
'type' => $this->type,
|
||||
'year' => $this->year,
|
||||
'title' => $this->getName()
|
||||
]
|
||||
]
|
||||
)->getPointers();
|
||||
}
|
||||
|
||||
|
||||
@@ -62,24 +62,24 @@ class JellyfinServer implements ServerInterface
|
||||
): ServerInterface {
|
||||
$cloned = clone $this;
|
||||
$cloned->context = new Context(
|
||||
clientName: static::NAME,
|
||||
backendName: $name,
|
||||
backendUrl: $url,
|
||||
cache: $this->cache->withData(static::NAME . '_' . $name, $options),
|
||||
backendId: $uuid,
|
||||
backendToken: $token,
|
||||
backendUser: $userId,
|
||||
clientName: static::NAME,
|
||||
backendName: $name,
|
||||
backendUrl: $url,
|
||||
cache: $this->cache->withData(static::NAME . '_' . $name, $options),
|
||||
backendId: $uuid,
|
||||
backendToken: $token,
|
||||
backendUser: $userId,
|
||||
backendHeaders: array_replace_recursive(
|
||||
[
|
||||
'headers' => [
|
||||
'Accept' => 'application/json',
|
||||
'X-MediaBrowser-Token' => $token,
|
||||
],
|
||||
],
|
||||
$options['client'] ?? []
|
||||
),
|
||||
trace: true === ag($options, Options::DEBUG_TRACE),
|
||||
options: $options
|
||||
[
|
||||
'headers' => [
|
||||
'Accept' => 'application/json',
|
||||
'X-MediaBrowser-Token' => $token,
|
||||
],
|
||||
],
|
||||
$options['client'] ?? []
|
||||
),
|
||||
trace: true === ag($options, Options::DEBUG_TRACE),
|
||||
options: $options
|
||||
);
|
||||
|
||||
$cloned->guid = $cloned->guid->withContext($cloned->context);
|
||||
@@ -156,9 +156,9 @@ class JellyfinServer implements ServerInterface
|
||||
{
|
||||
$response = Container::get(SearchQuery::class)(
|
||||
context: $this->context,
|
||||
query: $query,
|
||||
limit: $limit,
|
||||
opts: $opts
|
||||
query: $query,
|
||||
limit: $limit,
|
||||
opts: $opts
|
||||
);
|
||||
|
||||
if ($response->hasError()) {
|
||||
@@ -179,8 +179,8 @@ class JellyfinServer implements ServerInterface
|
||||
{
|
||||
$response = Container::get(SearchId::class)(
|
||||
context: $this->context,
|
||||
id: $id,
|
||||
opts: $opts
|
||||
id: $id,
|
||||
opts: $opts
|
||||
);
|
||||
|
||||
if ($response->hasError()) {
|
||||
@@ -206,9 +206,9 @@ class JellyfinServer implements ServerInterface
|
||||
{
|
||||
$response = Container::get(GetLibrary::class)(
|
||||
context: $this->context,
|
||||
guid: $this->guid,
|
||||
id: $id,
|
||||
opts: $opts
|
||||
guid: $this->guid,
|
||||
id: $id,
|
||||
opts: $opts
|
||||
);
|
||||
|
||||
if ($response->hasError()) {
|
||||
@@ -240,10 +240,10 @@ class JellyfinServer implements ServerInterface
|
||||
public function push(array $entities, QueueRequests $queue, DateTimeInterface|null $after = null): array
|
||||
{
|
||||
$response = Container::get(Push::class)(
|
||||
context: $this->context,
|
||||
context: $this->context,
|
||||
entities: $entities,
|
||||
queue: $queue,
|
||||
after: $after
|
||||
queue: $queue,
|
||||
after: $after
|
||||
);
|
||||
|
||||
if ($response->hasError()) {
|
||||
@@ -261,12 +261,12 @@ class JellyfinServer implements ServerInterface
|
||||
{
|
||||
$response = Container::get(Import::class)(
|
||||
context: $this->context,
|
||||
guid: $this->guid,
|
||||
mapper: $mapper,
|
||||
after: $after,
|
||||
opts: [
|
||||
Options::DISABLE_GUID => (bool)Config::get('episodes.disable.guid'),
|
||||
]
|
||||
guid: $this->guid,
|
||||
mapper: $mapper,
|
||||
after: $after,
|
||||
opts: [
|
||||
Options::DISABLE_GUID => (bool)Config::get('episodes.disable.guid'),
|
||||
]
|
||||
);
|
||||
|
||||
if ($response->hasError()) {
|
||||
@@ -284,9 +284,9 @@ class JellyfinServer implements ServerInterface
|
||||
{
|
||||
$response = Container::get(Backup::class)(
|
||||
context: $this->context,
|
||||
guid: $this->guid,
|
||||
mapper: $mapper,
|
||||
opts: $opts + ['writer' => $writer]
|
||||
guid: $this->guid,
|
||||
mapper: $mapper,
|
||||
opts: $opts + ['writer' => $writer]
|
||||
);
|
||||
|
||||
if ($response->hasError()) {
|
||||
@@ -304,13 +304,13 @@ class JellyfinServer implements ServerInterface
|
||||
{
|
||||
$response = Container::get(Export::class)(
|
||||
context: $this->context,
|
||||
guid: $this->guid,
|
||||
mapper: $mapper,
|
||||
after: $after,
|
||||
opts: [
|
||||
'queue' => $queue,
|
||||
Options::DISABLE_GUID => (bool)Config::get('episodes.disable.guid'),
|
||||
]
|
||||
guid: $this->guid,
|
||||
mapper: $mapper,
|
||||
after: $after,
|
||||
opts: [
|
||||
'queue' => $queue,
|
||||
Options::DISABLE_GUID => (bool)Config::get('episodes.disable.guid'),
|
||||
]
|
||||
);
|
||||
|
||||
if ($response->hasError()) {
|
||||
|
||||
@@ -61,24 +61,24 @@ class PlexServer implements ServerInterface
|
||||
): ServerInterface {
|
||||
$cloned = clone $this;
|
||||
$cloned->context = new Context(
|
||||
clientName: static::NAME,
|
||||
backendName: $name,
|
||||
backendUrl: $url,
|
||||
cache: $this->cache->withData(static::NAME . '_' . $name, $options),
|
||||
backendId: $uuid,
|
||||
backendToken: $token,
|
||||
backendUser: $userId,
|
||||
clientName: static::NAME,
|
||||
backendName: $name,
|
||||
backendUrl: $url,
|
||||
cache: $this->cache->withData(static::NAME . '_' . $name, $options),
|
||||
backendId: $uuid,
|
||||
backendToken: $token,
|
||||
backendUser: $userId,
|
||||
backendHeaders: array_replace_recursive(
|
||||
[
|
||||
'headers' => [
|
||||
'Accept' => 'application/json',
|
||||
'X-Plex-Token' => $token,
|
||||
],
|
||||
],
|
||||
$options['client'] ?? []
|
||||
),
|
||||
trace: true === ag($options, Options::DEBUG_TRACE),
|
||||
options: $options
|
||||
[
|
||||
'headers' => [
|
||||
'Accept' => 'application/json',
|
||||
'X-Plex-Token' => $token,
|
||||
],
|
||||
],
|
||||
$options['client'] ?? []
|
||||
),
|
||||
trace: true === ag($options, Options::DEBUG_TRACE),
|
||||
options: $options
|
||||
);
|
||||
|
||||
$cloned->guid = $this->guid->withContext($cloned->context);
|
||||
@@ -141,7 +141,7 @@ class PlexServer implements ServerInterface
|
||||
{
|
||||
$response = Container::get(ParseWebhook::class)(
|
||||
context: $this->context,
|
||||
guid: $this->guid,
|
||||
guid: $this->guid,
|
||||
request: $request
|
||||
);
|
||||
|
||||
@@ -163,9 +163,9 @@ class PlexServer implements ServerInterface
|
||||
{
|
||||
$response = Container::get(SearchQuery::class)(
|
||||
context: $this->context,
|
||||
query: $query,
|
||||
limit: $limit,
|
||||
opts: $opts
|
||||
query: $query,
|
||||
limit: $limit,
|
||||
opts: $opts
|
||||
);
|
||||
|
||||
if ($response->hasError()) {
|
||||
@@ -232,10 +232,10 @@ class PlexServer implements ServerInterface
|
||||
public function push(array $entities, QueueRequests $queue, DateTimeInterface|null $after = null): array
|
||||
{
|
||||
$response = Container::get(Push::class)(
|
||||
context: $this->context,
|
||||
context: $this->context,
|
||||
entities: $entities,
|
||||
queue: $queue,
|
||||
after: $after
|
||||
queue: $queue,
|
||||
after: $after
|
||||
);
|
||||
|
||||
if ($response->hasError()) {
|
||||
@@ -253,12 +253,12 @@ class PlexServer implements ServerInterface
|
||||
{
|
||||
$response = Container::get(Import::class)(
|
||||
context: $this->context,
|
||||
guid: $this->guid,
|
||||
mapper: $mapper,
|
||||
after: $after,
|
||||
opts: [
|
||||
Options::DISABLE_GUID => (bool)Config::get('episodes.disable.guid'),
|
||||
]
|
||||
guid: $this->guid,
|
||||
mapper: $mapper,
|
||||
after: $after,
|
||||
opts: [
|
||||
Options::DISABLE_GUID => (bool)Config::get('episodes.disable.guid'),
|
||||
]
|
||||
);
|
||||
|
||||
if ($response->hasError()) {
|
||||
@@ -276,9 +276,9 @@ class PlexServer implements ServerInterface
|
||||
{
|
||||
$response = Container::get(Backup::class)(
|
||||
context: $this->context,
|
||||
guid: $this->guid,
|
||||
mapper: $mapper,
|
||||
opts: $opts + ['writer' => $writer]
|
||||
guid: $this->guid,
|
||||
mapper: $mapper,
|
||||
opts: $opts + ['writer' => $writer]
|
||||
);
|
||||
|
||||
if ($response->hasError()) {
|
||||
@@ -296,13 +296,13 @@ class PlexServer implements ServerInterface
|
||||
{
|
||||
$response = Container::get(Export::class)(
|
||||
context: $this->context,
|
||||
guid: $this->guid,
|
||||
mapper: $mapper,
|
||||
after: $after,
|
||||
opts: [
|
||||
'queue' => $queue,
|
||||
Options::DISABLE_GUID => (bool)Config::get('episodes.disable.guid'),
|
||||
],
|
||||
guid: $this->guid,
|
||||
mapper: $mapper,
|
||||
after: $after,
|
||||
opts: [
|
||||
'queue' => $queue,
|
||||
Options::DISABLE_GUID => (bool)Config::get('episodes.disable.guid'),
|
||||
],
|
||||
);
|
||||
|
||||
if ($response->hasError()) {
|
||||
|
||||
Reference in New Issue
Block a user