Fix URL tokens

This commit is contained in:
tomkat83 2016-02-19 16:10:19 +01:00
parent 9b6cdbafc2
commit 70393b1b86
3 changed files with 15 additions and 3 deletions

View file

@ -1773,7 +1773,7 @@ class API():
episode = item['index']
return key, title, season, episode
def addPlexCredentialsToUrl(self, url, arguments={}):
def addPlexHeadersToUrl(self, url, arguments={}):
"""
Takes an URL and optional arguments (also to be URL-encoded); returns
an extended URL with e.g. the Plex token included.
@ -1788,6 +1788,18 @@ class API():
url = "%s&%s" % (url, urlencode(xargs))
return url
def addPlexCredentialsToUrl(self, url):
"""
Returns an extended URL with the Plex token included as 'X-Plex-Token='
url may or may not already contain a '?'
"""
if '?' not in url:
url = "%s?X-Plex-Token=%s" % (url, self.token)
else:
url = "%s&X-Plex-Token=%s" % (url, self.token)
return url
def GetPlayQueueItemID(self):
"""
Returns current playQueueItemID for the item.

View file

@ -1859,7 +1859,7 @@ class Music(Items):
paths = "%s%s" % (self.server, item[0][0].attrib.get('key'))
paths = paths.rsplit('/', 1)
path = paths[0] + '/'
filename = paths[1] + '?X-Plex-Token=ihfViFUqqJf1vWrchnA9'
filename = API.addPlexCredentialsToUrl(paths[1])
# else:
# path = "plugin://plugin.audio.plexkodiconnect.music/"
# filename = API.getKey()

View file

@ -391,7 +391,7 @@ class PlayUtils():
url = "%s/library/streams/%s" \
% (self.server, selectSubsIndex)
url = self.API.addPlexCredentialsToUrl(url)
url = self.API.addPlexHeadersToUrl(url)
self.logMsg("Downloadable sub: %s: %s" % (selectSubsIndex, url), 1)
listitem.setSubtitles([url])
else: