[UnogsBridge] Add fallback if not found any high-res image (#2301)

This commit is contained in:
csisoap 2021-10-19 10:22:17 +07:00 committed by GitHub
parent 927b08ed00
commit bdf15c3ce0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 3 deletions

View File

@ -113,9 +113,15 @@ class UnogsBridge extends BridgeAbstract {
private function getImage($nfid) {
$url = self::URI . '/api/title/bgimages?netflixid=' . $nfid;
$json = $this->getJSON($url);
end($json['bo1280x448']);
$position = key($json['bo1280x448']);
$image_link = $json['bo1280x448'][$position]['url'];
$image_wrapper = '';
if(isset($json['bo1280x448'])) {
$image_wrapper = 'bo1280x448';
} else {
$image_wrapper = 'bo665x375';
}
end($json[$image_wrapper]);
$position = key($json[$image_wrapper]);
$image_link = $json[$image_wrapper][$position]['url'];
return $image_link;
}