From 1ec3b329191eecba26fdedc4794499a3b3d6ab03 Mon Sep 17 00:00:00 2001 From: angelblue05 Date: Tue, 9 Jan 2018 19:31:14 -0600 Subject: [PATCH] Update theme media --- resources/lib/downloadutils.py | 4 +--- resources/lib/entrypoint.py | 11 ++++++----- resources/lib/playbackutils.py | 3 ++- resources/lib/playutils.py | 9 ++++++--- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/resources/lib/downloadutils.py b/resources/lib/downloadutils.py index 0f86065e..4294123b 100644 --- a/resources/lib/downloadutils.py +++ b/resources/lib/downloadutils.py @@ -54,9 +54,7 @@ class DownloadUtils(object): log.debug("Set info for server %s: %s", self.session['ServerId'], self.session) def get_token(self): - user = self._get_session_info() - token = user['Token'] - return token + return self._get_session_info()['Token'] def add_server(self, server, ssl): # Reserved for userclient only diff --git a/resources/lib/entrypoint.py b/resources/lib/entrypoint.py index 56a4b549..a42d2626 100644 --- a/resources/lib/entrypoint.py +++ b/resources/lib/entrypoint.py @@ -548,6 +548,7 @@ def getThemeMedia(): doUtils = downloadutils.DownloadUtils() dialog = xbmcgui.Dialog() + dummy_listitem = xbmcgui.ListItem() playback = None # Choose playback method @@ -613,11 +614,11 @@ def getThemeMedia(): pathstowrite = "" # May be more than one theme for theme in result['Items']: - putils = playutils.PlayUtils(theme) + putils = playutils.PlayUtils(theme, dummy_listitem) if playback == "DirectPlay": - playurl = putils.directPlay() + playurl = api.API(theme).get_file_path() else: - playurl = putils.directStream() + playurl = putils.get_direct_url(theme['MediaSources'][0]) pathstowrite += ('%s' % playurl.encode('utf-8')) # Check if the item has theme songs and add them @@ -629,7 +630,7 @@ def getThemeMedia(): if playback == "DirectPlay": playurl = api.API(theme).get_file_path() else: - playurl = playutils.PlayUtils(theme).directStream() + playurl = playutils.PlayUtils(theme, dummy_listitem).get_direct_url(theme['MediaSources'][0]) pathstowrite += ('%s' % playurl.encode('utf-8')) nfo_file.write( @@ -676,7 +677,7 @@ def getThemeMedia(): if playback == "DirectPlay": playurl = api.API(theme).get_file_path() else: - playurl = playutils.PlayUtils(theme).directStream() + playurl = playutils.PlayUtils(theme, dummy_listitem).get_direct_url(theme['MediaSources'][0]) pathstowrite += ('%s' % playurl.encode('utf-8')) nfo_file.write( diff --git a/resources/lib/playbackutils.py b/resources/lib/playbackutils.py index 9ba0d833..ca434dde 100644 --- a/resources/lib/playbackutils.py +++ b/resources/lib/playbackutils.py @@ -88,7 +88,8 @@ class PlaybackUtils(object): # Stack: [(url, listitem), (url, ...), ...] self.stack[0][1].setPath(self.stack[0][0]) try: - if not xbmc.getCondVisibility('Window.IsVisible(MyVideoNav.xml)') and not xbmc.getCondVisibility('Window.IsVisible(VideoFullScreen.xml)'): + if (not xbmc.getCondVisibility('Window.IsVisible(MyVideoNav.xml)') and + not xbmc.getCondVisibility('Window.IsVisible(VideoFullScreen.xml)')): # widgets do not fill artwork correctly log.info("Detected widget.") raise IndexError diff --git a/resources/lib/playutils.py b/resources/lib/playutils.py index ff33c14b..ea344d73 100644 --- a/resources/lib/playutils.py +++ b/resources/lib/playutils.py @@ -209,9 +209,6 @@ class PlayUtils(): play_url = self.get_transcode_url(source) if transcode else self.get_direct_url(source) - user_token = downloadutils.DownloadUtils().get_token() - play_url += "&api_key=" + user_token - return play_url def get_direct_url(self, source): @@ -227,6 +224,9 @@ class PlayUtils(): if settings('enableExternalSubs') == "true": self.set_external_subs(source, play_url) + user_token = downloadutils.DownloadUtils().get_token() + play_url += "&api_key=" + user_token + return play_url def get_transcode_url(self, source): @@ -252,6 +252,9 @@ class PlayUtils(): # Select audio and subtitles play_url += self.get_audio_subs(source) + user_token = downloadutils.DownloadUtils().get_token() + play_url += "&api_key=" + user_token + return play_url def set_external_subs(self, source, play_url):