add api_key to streaming urls

This commit is contained in:
Shaun 2017-05-06 10:08:04 +10:00
parent 7a9bbcc708
commit 5322058652
3 changed files with 15 additions and 1 deletions

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="plugin.video.emby" <addon id="plugin.video.emby"
name="Emby" name="Emby"
version="2.3.47" version="2.3.48"
provider-name="Emby.media"> provider-name="Emby.media">
<requires> <requires>
<import addon="xbmc.python" version="2.19.0"/> <import addon="xbmc.python" version="2.19.0"/>

View file

@ -53,6 +53,11 @@ class DownloadUtils(object):
log.debug("Set info for server %s: %s", self.session['ServerId'], self.session) 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): def add_server(self, server, ssl):
# Reserved for userclient only # Reserved for userclient only
server_id = server['Id'] server_id = server['Id']

View file

@ -72,12 +72,14 @@ class PlayUtils():
log.info("Could not get file path for embyfilename window prop") log.info("Could not get file path for embyfilename window prop")
playurl = None playurl = None
user_token = downloadutils.DownloadUtils().get_token()
if (self.item.get('Type') in ("Recording", "TvChannel") and self.item.get('MediaSources') if (self.item.get('Type') in ("Recording", "TvChannel") and self.item.get('MediaSources')
and self.item['MediaSources'][0]['Protocol'] == "Http"): and self.item['MediaSources'][0]['Protocol'] == "Http"):
# Play LiveTV or recordings # Play LiveTV or recordings
log.info("File protocol is http (livetv).") log.info("File protocol is http (livetv).")
playurl = "%s/emby/Videos/%s/stream.ts?audioCodec=copy&videoCodec=copy" % (self.server, self.item['Id']) 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") window('emby_%s.playmethod' % playurl, value="DirectPlay")
@ -123,6 +125,8 @@ class PlayUtils():
else: else:
playurl = "%s/emby/Videos/%s/stream?static=true" % (self.server, itemid) 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 return playurl
def isDirectPlay(self): def isDirectPlay(self):
@ -273,6 +277,8 @@ class PlayUtils():
else: else:
playurl = "%s/emby/Videos/%s/stream?static=true" % (self.server, self.item['Id']) 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 return playurl
def isNetworkSufficient(self): def isNetworkSufficient(self):
@ -319,6 +325,9 @@ class PlayUtils():
if transcodeHi10P == "true": if transcodeHi10P == "true":
playurl = "%s&MaxVideoBitDepth=8" % playurl playurl = "%s&MaxVideoBitDepth=8" % playurl
user_token = downloadutils.DownloadUtils().get_token()
playurl += "&api_key=" + str(user_token)
return playurl return playurl
def getBitrate(self): def getBitrate(self):