Some minor performance enhancement for guid parsing.
This commit is contained in:
@@ -73,19 +73,19 @@ class JellyfinGuid implements iGuid
|
||||
{
|
||||
$guid = [];
|
||||
|
||||
$id = ag($context, 'item.id', null);
|
||||
$type = ag($context, 'item.type', '??');
|
||||
$type = JellyfinClient::TYPE_MAPPER[$type] ?? $type;
|
||||
|
||||
foreach (array_change_key_case($guids, CASE_LOWER) as $key => $value) {
|
||||
if (null === (self::GUID_MAPPER[$key] ?? null) || empty($value)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
$id = ag($context, 'item.id', null);
|
||||
$type = ag($context, 'item.type', '??');
|
||||
$type = JellyfinClient::TYPE_MAPPER[$type] ?? $type;
|
||||
|
||||
if (true === isIgnoredId($this->context->backendName, $type, $key, $value, $id)) {
|
||||
if (true === $log) {
|
||||
$this->logger->info(
|
||||
$this->logger->debug(
|
||||
'Ignoring [%(backend)] external id [%(source)] for %(item.type) [%(item.title)] as requested.',
|
||||
[
|
||||
'backend' => $this->context->backendName,
|
||||
@@ -101,28 +101,6 @@ class JellyfinGuid implements iGuid
|
||||
continue;
|
||||
}
|
||||
|
||||
if (null !== ($guid[self::GUID_MAPPER[$key]] ?? null)) {
|
||||
if (true === $log) {
|
||||
$this->logger->info(
|
||||
'[%(backend)] reported multiple ids for same data source [%(key): %(ids)] for %(item.type) [%(item.title)].',
|
||||
[
|
||||
'backend' => $this->context->backendName,
|
||||
'key' => $key,
|
||||
'ids' => sprintf('%s, %s', $guid[self::GUID_MAPPER[$key]], $value),
|
||||
...$context
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
if (false === ctype_digit($value)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((int)$guid[self::GUID_MAPPER[$key]] < (int)$value) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$guid[self::GUID_MAPPER[$key]] = $value;
|
||||
} catch (Throwable $e) {
|
||||
if (true === $log) {
|
||||
|
||||
@@ -105,6 +105,10 @@ final class PlexGuid implements iGuid
|
||||
{
|
||||
$guid = [];
|
||||
|
||||
$id = ag($context, 'item.id', null);
|
||||
$type = ag($context, 'item.type', '??');
|
||||
$type = PlexClient::TYPE_MAPPER[$type] ?? $type;
|
||||
|
||||
foreach (array_column($guids, 'id') as $val) {
|
||||
try {
|
||||
if (empty($val)) {
|
||||
@@ -140,13 +144,9 @@ final class PlexGuid implements iGuid
|
||||
continue;
|
||||
}
|
||||
|
||||
$id = ag($context, 'item.id', null);
|
||||
$type = ag($context, 'item.type', '??');
|
||||
$type = PlexClient::TYPE_MAPPER[$type] ?? $type;
|
||||
|
||||
if (true === isIgnoredId($this->context->backendName, $type, $key, $value, $id)) {
|
||||
if (true === $log) {
|
||||
$this->logger->info(
|
||||
$this->logger->debug(
|
||||
'Ignoring [%(backend)] external id [%(source)] for %(item.type) [%(item.title)] as requested.',
|
||||
[
|
||||
'backend' => $this->context->backendName,
|
||||
|
||||
Reference in New Issue
Block a user