Skip to content

Commit

Permalink
📺 fix for when tmdb data not present
Browse files Browse the repository at this point in the history
  • Loading branch information
iantrich committed Jan 29, 2019
1 parent b83cbb4 commit 9374895
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions custom_components/sensor/trakt.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ def save_token(hass, token):
data_file.write(json.dumps(token))


class TraktMyShowCalendarSensor(Entity):
"""Representation of a Trakt My Show Calendar sensor."""
class TraktUpcomingCalendarSensor(Entity):
"""Representation of a Trakt Upcoming Calendar sensor."""

def __init__(self, hass, config, token):
"""Initialize the sensor."""
Expand Down Expand Up @@ -181,18 +181,19 @@ def update(self):
release = '$day, $time'
else:
release = '$day, $date $time'

card_item = {
'airdate': show.airs_at.isoformat() + 'Z',
'release': release,
'flag': False,
'title': show.show,
'episode': show.title,
'number': 'S' + str(show.season) + 'E' + str(show.number),
'rating': tmdb_json['vote_average'],
'poster': image_url % ('500', tmdb_json['poster_path']),
'fanart': image_url % ('780', tmdb_json['backdrop_path']),
'runtime': tmdb_json['episode_run_time'][0] if len(tmdb_json['episode_run_time']) > 0 else '',
'studio': tmdb_json['networks'][0]['name'] if len(tmdb_json['networks']) > 0 else ''
'rating': tmdb_json.get('vote_average', ''),
'poster': image_url % ('500', tmdb_json.get('poster_path', '')),
'fanart': image_url % ('780', tmdb_json.get('backdrop_path', '')),
'runtime': tmdb_json.get('episode_run_time')[0] if len(tmdb_json.get('episode_run_time')) > 0 else '',
'studio': tmdb_json.get('networks')[0].get('name', '') if len(tmdb_json.get('networks')) > 0 else ''
}
card_json.append(card_item)

Expand Down

0 comments on commit 9374895

Please sign in to comment.