From 5e3739648b65a25dd1e2ce45e3e32db4a894b776 Mon Sep 17 00:00:00 2001 From: Ryan Meek <25127328+maykar@users.noreply.github.com> Date: Sun, 17 May 2020 14:58:31 -0400 Subject: [PATCH] Check image type as sonarr changed order of images --- custom_components/sonarr_upcoming_media/sensor.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/custom_components/sonarr_upcoming_media/sensor.py b/custom_components/sonarr_upcoming_media/sensor.py index 9a6446e..1490d8f 100644 --- a/custom_components/sonarr_upcoming_media/sensor.py +++ b/custom_components/sonarr_upcoming_media/sensor.py @@ -119,16 +119,16 @@ def device_state_attributes(self): else: card_item['genres'] = '' try: - card_item['poster'] = re.sub('.jpg', '_t.jpg', - show['series']['images'][2]['url']) + for img in show['series']['images']: + if img['coverType'] == 'poster': + card_item['poster'] = re.sub('.jpg', '_t.jpg', img['url']) except: continue try: - if '.jpg' in show['series']['images'][0]['url']: - card_item['fanart'] = re.sub('.jpg', '_t.jpg', - show['series']['images'][0]['url']) - else: - card_item['fanart'] = '' + card_item['fanart'] = '' + for img in show['series']['images']: + if img['coverType'] == 'fanart': + card_item['fanart'] = re.sub('.jpg', '_t.jpg', img['url']) except: pass card_json.append(card_item)