Workaround some backends sending invalid UTF8 content.

This commit is contained in:
Abdulmhsen B. A. A
2022-05-10 22:36:44 +03:00
parent 998ad6eec5
commit 15f789d366
2 changed files with 37 additions and 8 deletions

View File

@@ -160,7 +160,11 @@ class JellyfinServer implements ServerInterface
return null;
}
$json = json_decode($response->getContent(), true, flags: JSON_THROW_ON_ERROR);
$json = json_decode(
json: $response->getContent(),
associative: true,
flags: JSON_THROW_ON_ERROR | JSON_INVALID_UTF8_IGNORE
);
$this->uuid = ag($json, 'Id', null);
@@ -185,7 +189,11 @@ class JellyfinServer implements ServerInterface
);
}
$json = json_decode($response->getContent(), true, flags: JSON_THROW_ON_ERROR);
$json = json_decode(
json: $response->getContent(),
associative: true,
flags: JSON_THROW_ON_ERROR | JSON_INVALID_UTF8_IGNORE
);
$list = [];
@@ -676,7 +684,7 @@ class JellyfinServer implements ServerInterface
$json = json_decode(
json: $response->getContent(),
associative: true,
flags: JSON_THROW_ON_ERROR
flags: JSON_THROW_ON_ERROR | JSON_INVALID_UTF8_IGNORE
);
$json = ag($json, 'Items', [])[0] ?? [];
@@ -1617,7 +1625,11 @@ class JellyfinServer implements ServerInterface
return [];
}
$json = json_decode($response->getContent(), true, flags: JSON_THROW_ON_ERROR);
$json = json_decode(
json: $response->getContent(),
associative: true,
flags: JSON_THROW_ON_ERROR | JSON_INVALID_UTF8_IGNORE
);
if (null === ($type = ag($json, 'Type'))) {
return [];

View File

@@ -168,7 +168,11 @@ class PlexServer implements ServerInterface
return null;
}
$json = json_decode($response->getContent(false), true, flags: JSON_THROW_ON_ERROR);
$json = json_decode(
json: $response->getContent(false),
associative: true,
flags: JSON_THROW_ON_ERROR | JSON_INVALID_UTF8_IGNORE
);
$this->uuid = ag($json, 'MediaContainer.machineIdentifier', null);
@@ -200,7 +204,11 @@ class PlexServer implements ServerInterface
);
}
$json = json_decode($response->getContent(), true, flags: JSON_THROW_ON_ERROR);
$json = json_decode(
json: $response->getContent(),
associative: true,
flags: JSON_THROW_ON_ERROR | JSON_INVALID_UTF8_IGNORE
);
$list = [];
@@ -1810,7 +1818,12 @@ class PlexServer implements ServerInterface
return null;
}
$json = json_decode($response->getContent(), true, flags: JSON_THROW_ON_ERROR);
$json = json_decode(
json: $response->getContent(),
associative: true,
flags: JSON_THROW_ON_ERROR | JSON_INVALID_UTF8_IGNORE
);
$tempToken = ag($json, 'authToken', null);
$url = Container::getNew(UriInterface::class)->withPort(443)->withScheme('https')->withHost('plex.tv')
@@ -1839,7 +1852,11 @@ class PlexServer implements ServerInterface
],
]);
$json = json_decode($response->getContent(), true, flags: JSON_THROW_ON_ERROR);
$json = json_decode(
json: $response->getContent(),
associative: true,
flags: JSON_THROW_ON_ERROR | JSON_INVALID_UTF8_IGNORE
);
foreach ($json ?? [] as $server) {
if (ag($server, 'clientIdentifier') !== $uuid) {