Skip to content

Commit

Permalink
Fixed broken url_base setting and updated manifest and release to 0.4.2
Browse files Browse the repository at this point in the history
  • Loading branch information
mkanet committed May 29, 2024
1 parent 0cc5da9 commit 131528a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion custom_components/sonarr_upcoming_media/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
"iot_class": "local_polling",
"issue_tracker": "https://github.com/custom-components/sensor.sonarr_upcoming_media/issues",
"requirements": [],
"version": "0.4.1"
"version": "0.4.2"
}

4 changes: 2 additions & 2 deletions custom_components/sonarr_upcoming_media/parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def days_until(date, tz):
now = time.mktime(now)
return int((date - now) / 86400)

def parse_data(data, tz, host, port, ssl):
def parse_data(data, tz, host, port, ssl, url_base=None):
import re
"""Return JSON for the sensor."""
attributes = {}
Expand Down Expand Up @@ -75,7 +75,7 @@ def parse_data(data, tz, host, port, ssl):
pass
series_title_slug = show['series']['titleSlug']
protocol = 'https' if ssl else 'http'
card_item['deep_link'] = f'{protocol}://{host}:{port}/series/{series_title_slug}'
card_item['deep_link'] = f'{protocol}://{host}:{port}/{url_base.strip("/") + "/" if url_base else ""}series/{series_title_slug}'
card_json.append(card_item)
attributes['data'] = card_json
return attributes
5 changes: 3 additions & 2 deletions custom_components/sonarr_upcoming_media/sonarr_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def __init__(
self._host = host
self._port = port
self._ssl = ssl
self._url_base = urlbase

self._address = 'http{0}://{1}:{2}/{3}api/v3/calendar?start={4}&end={5}&includeEpisodeImages=true&includeSeries=true'.format(
's' if ssl else '',
Expand All @@ -57,12 +58,12 @@ def update(self):
'data': parse_data(list(
filter(
lambda x: x['airDate'][:-10] == str(start),
api.json()))[:self._max], self._host, self._port, self._ssl)
api.json()))[:self._max], tz, self._host, self._port, self._ssl, self._url_base)
}

return {
'online': True,
'data': parse_data(api.json()[:self._max], tz, self._host, self._port, self._ssl)
'data': parse_data(api.json()[:self._max], tz, self._host, self._port, self._ssl, self._url_base)
}

raise SonarrCannotBeReached
Expand Down

0 comments on commit 131528a

Please sign in to comment.