From 5322058652fd218ba1bdacf735cbba24f6bb9b37 Mon Sep 17 00:00:00 2001 From: Shaun Date: Sat, 6 May 2017 10:08:04 +1000 Subject: [PATCH] add api_key to streaming urls --- addon.xml | 2 +- resources/lib/downloadutils.py | 5 +++++ resources/lib/playutils.py | 9 +++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/addon.xml b/addon.xml index 6e568a0d..f9208396 100644 --- a/addon.xml +++ b/addon.xml @@ -1,7 +1,7 @@ diff --git a/resources/lib/downloadutils.py b/resources/lib/downloadutils.py index 247006e7..8f55df83 100644 --- a/resources/lib/downloadutils.py +++ b/resources/lib/downloadutils.py @@ -53,6 +53,11 @@ 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 + def add_server(self, server, ssl): # Reserved for userclient only server_id = server['Id'] diff --git a/resources/lib/playutils.py b/resources/lib/playutils.py index 1f480fcb..a07e4ca2 100644 --- a/resources/lib/playutils.py +++ b/resources/lib/playutils.py @@ -72,12 +72,14 @@ class PlayUtils(): log.info("Could not get file path for embyfilename window prop") playurl = None + user_token = downloadutils.DownloadUtils().get_token() if (self.item.get('Type') in ("Recording", "TvChannel") and self.item.get('MediaSources') and self.item['MediaSources'][0]['Protocol'] == "Http"): # Play LiveTV or recordings log.info("File protocol is http (livetv).") playurl = "%s/emby/Videos/%s/stream.ts?audioCodec=copy&videoCodec=copy" % (self.server, self.item['Id']) + playurl += "&api_key=" + str(user_token) window('emby_%s.playmethod' % playurl, value="DirectPlay") @@ -123,6 +125,8 @@ class PlayUtils(): else: playurl = "%s/emby/Videos/%s/stream?static=true" % (self.server, itemid) + user_token = downloadutils.DownloadUtils().get_token() + playurl += "&api_key=" + str(user_token) return playurl def isDirectPlay(self): @@ -273,6 +277,8 @@ class PlayUtils(): else: playurl = "%s/emby/Videos/%s/stream?static=true" % (self.server, self.item['Id']) + user_token = downloadutils.DownloadUtils().get_token() + playurl += "&api_key=" + str(user_token) return playurl def isNetworkSufficient(self): @@ -319,6 +325,9 @@ class PlayUtils(): if transcodeHi10P == "true": playurl = "%s&MaxVideoBitDepth=8" % playurl + user_token = downloadutils.DownloadUtils().get_token() + playurl += "&api_key=" + str(user_token) + return playurl def getBitrate(self):