Skip to content

Commit

Permalink
Attempt to use json.load(fdesc) again
Browse files Browse the repository at this point in the history
This PR includes:
- Use json.load(fdesc)
- Early exit in tokenresolver
- Move caching functionality to utils.py
- Fix 2 issues
  • Loading branch information
dagwieers committed Dec 9, 2019
1 parent 85d065a commit 76dffc7
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
5 changes: 4 additions & 1 deletion resources/lib/apihelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,10 @@ def get_episodes(self, program=None, season=None, episodes=None, category=None,
seasons = None
if 'facets[seasonTitle]' not in unquote(search_url):
facets = search_json.get('facets', dict()).get('facets')
seasons = next((f.get('buckets', []) for f in facets if f.get('name') == 'seasons' and len(f.get('buckets', [])) > 1), None)
if facets:
seasons = next((f.get('buckets', []) for f in facets if f.get('name') == 'seasons' and len(f.get('buckets', [])) > 1), None)
else:
seasons = []

episodes = search_json.get('results', [{}])
show_seasons = bool(season != 'allseasons')
Expand Down
4 changes: 4 additions & 0 deletions resources/lib/playerinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ def onPlayBackStarted(self): # pylint: disable=invalid-name
# Get episode data
episode = self.apihelper.get_single_episode_data(video_id=ep_id.get('video_id'), whatson_id=ep_id.get('whatson_id'), video_url=ep_id.get('video_url'))

# This may be a live stream?
if episode is None:
return

self.asset_id = self.resumepoints.assetpath_to_id(episode.get('assetPath'))
self.title = episode.get('program')
self.url = url_to_episode(episode.get('url', ''))
Expand Down
2 changes: 2 additions & 0 deletions resources/lib/streamservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ def _get_stream_json(self, api_data, roaming=False):
api_url = api_data.media_api_url + '/videos/' + api_data.publication_id + \
api_data.video_id + '?vrtPlayerToken=' + playertoken + '&client=' + api_data.client
json_data = get_url_json(url=api_url)
if not json_data:
return None
return json_data

@staticmethod
Expand Down
1 change: 1 addition & 0 deletions resources/lib/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ def get_url_json(url, cache=None, headers=None, data=None):
''' Return HTTP data '''
if headers is None:
headers = dict()
from json import load, loads
log(2, 'URL get: {url}', url=unquote(url))
req = Request(url, headers=headers)
if data is not None:
Expand Down

0 comments on commit 76dffc7

Please sign in to comment.