Companion: send transient token
This commit is contained in:
parent
befee05043
commit
20cf51432f
4 changed files with 24 additions and 7 deletions
|
@ -14,6 +14,7 @@ from PlexFunctions import ParseContainerKey, GetPlexMetadata
|
|||
from PlexAPI import API
|
||||
import player
|
||||
import variables as v
|
||||
import state
|
||||
|
||||
###############################################################################
|
||||
|
||||
|
@ -76,6 +77,8 @@ class PlexCompanion(Thread):
|
|||
log.debug('Processing: %s' % task)
|
||||
data = task['data']
|
||||
|
||||
# Get the token of the user flinging media (might be different one)
|
||||
state.PLEX_TRANSIENT_TOKEN = data.get('token')
|
||||
if task['action'] == 'alexa':
|
||||
# e.g. Alexa
|
||||
xml = GetPlexMetadata(data['key'])
|
||||
|
|
|
@ -13,6 +13,7 @@ import downloadutils
|
|||
import plexdb_functions as plexdb
|
||||
import kodidb_functions as kodidb
|
||||
import variables as v
|
||||
import state
|
||||
|
||||
###############################################################################
|
||||
|
||||
|
@ -308,6 +309,9 @@ class Player(xbmc.Player):
|
|||
'plex_playbackProps',
|
||||
'plex_forcetranscode'):
|
||||
window(item, clear=True)
|
||||
# We might have saved a transient token from a user flinging media via
|
||||
# Companion
|
||||
state.PLEX_TRANSIENT_TOKEN = None
|
||||
log.debug("Cleared playlist properties.")
|
||||
|
||||
def onPlayBackEnded(self):
|
||||
|
|
|
@ -5,6 +5,7 @@ import threading
|
|||
import downloadutils
|
||||
from utils import window
|
||||
import PlexFunctions as pf
|
||||
import state
|
||||
from functions import *
|
||||
|
||||
###############################################################################
|
||||
|
@ -68,12 +69,12 @@ class SubscriptionManager:
|
|||
info = self.getPlayerProperties(playerid)
|
||||
# save this info off so the server update can use it too
|
||||
self.playerprops[playerid] = info;
|
||||
state = info['state']
|
||||
status = info['state']
|
||||
time = info['time']
|
||||
else:
|
||||
state = "stopped"
|
||||
status = "stopped"
|
||||
time = 0
|
||||
ret = "\n"+' <Timeline state="%s" time="%s" type="%s"' % (state, time, ptype)
|
||||
ret = "\n"+' <Timeline state="%s" time="%s" type="%s"' % (status, time, ptype)
|
||||
if playerid is None:
|
||||
ret += ' />'
|
||||
return ret
|
||||
|
@ -119,6 +120,8 @@ class SubscriptionManager:
|
|||
ret += ' mute="%s"' % self.mute
|
||||
ret += ' repeat="%s"' % info['repeat']
|
||||
ret += ' itemType="%s"' % info['itemType']
|
||||
if state.PLEX_TRANSIENT_TOKEN:
|
||||
ret += ' token="%s"' % state.PLEX_TRANSIENT_TOKEN
|
||||
# Might need an update in the future
|
||||
if ptype == 'video':
|
||||
ret += ' subtitleStreamID="-1"'
|
||||
|
@ -153,7 +156,7 @@ class SubscriptionManager:
|
|||
def notifyServer(self, players):
|
||||
for typus, p in players.iteritems():
|
||||
info = self.playerprops[p.get('playerid')]
|
||||
self._sendNotification(info)
|
||||
# self._sendNotification(info)
|
||||
self.lastinfo[typus] = info
|
||||
# Cross the one of the list
|
||||
try:
|
||||
|
@ -163,7 +166,7 @@ class SubscriptionManager:
|
|||
# Process the players we have left (to signal a stop)
|
||||
for typus, p in self.lastplayers.iteritems():
|
||||
self.lastinfo[typus]['state'] = 'stopped'
|
||||
self._sendNotification(self.lastinfo[typus])
|
||||
# self._sendNotification(self.lastinfo[typus])
|
||||
|
||||
def _sendNotification(self, info):
|
||||
params = {
|
||||
|
@ -174,6 +177,8 @@ class SubscriptionManager:
|
|||
'time': info['time'],
|
||||
'duration': info['duration']
|
||||
}
|
||||
if state.PLEX_TRANSIENT_TOKEN:
|
||||
params['token'] = state.PLEX_TRANSIENT_TOKEN
|
||||
if info.get('playQueueID'):
|
||||
params['containerKey'] = '/playQueues/%s' % info['playQueueID']
|
||||
params['playQueueVersion'] = info['playQueueVersion']
|
||||
|
|
|
@ -25,7 +25,12 @@ DIRECT_PATHS = False
|
|||
|
||||
# Along with window('plex_authenticated')
|
||||
AUTHENTICATED = False
|
||||
PLEX_TOKEN = None
|
||||
# Plex ID of the current user (e.g. for plex.tv) as a STRING
|
||||
# plex.tv username
|
||||
PLEX_USERNAME = None
|
||||
# Token for that user for plex.tv
|
||||
PLEX_TOKEN = None
|
||||
# Plex ID of that user (e.g. for plex.tv) as a STRING
|
||||
PLEX_USER_ID = None
|
||||
# Token passed along, e.g. if playback initiated by Plex Companion. Might be
|
||||
# another user playing something! Token identifies user
|
||||
PLEX_TRANSIENT_TOKEN = None
|
||||
|
|
Loading…
Reference in a new issue