mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-08-19 21:03:21 -07:00
Add PLEX_USER_TOKEN to script environment variables
This commit is contained in:
parent
7d11e1de2d
commit
32c05136bd
1 changed files with 9 additions and 2 deletions
|
@ -3029,18 +3029,24 @@ class SCRIPTS(Notifier):
|
||||||
|
|
||||||
return scripts
|
return scripts
|
||||||
|
|
||||||
def run_script(self, script):
|
def run_script(self, script, user_id):
|
||||||
# Common environment variables
|
# Common environment variables
|
||||||
env = os.environ.copy()
|
env = os.environ.copy()
|
||||||
env.update({
|
env.update({
|
||||||
'PLEX_URL': plexpy.CONFIG.PMS_URL,
|
'PLEX_URL': plexpy.CONFIG.PMS_URL,
|
||||||
'PLEX_TOKEN': plexpy.CONFIG.PMS_TOKEN,
|
'PLEX_TOKEN': plexpy.CONFIG.PMS_TOKEN,
|
||||||
|
'PLEX_USER_TOKEN': '',
|
||||||
'TAUTULLI_URL': helpers.get_plexpy_url(hostname='localhost'),
|
'TAUTULLI_URL': helpers.get_plexpy_url(hostname='localhost'),
|
||||||
'TAUTULLI_PUBLIC_URL': plexpy.CONFIG.HTTP_BASE_URL + plexpy.HTTP_ROOT,
|
'TAUTULLI_PUBLIC_URL': plexpy.CONFIG.HTTP_BASE_URL + plexpy.HTTP_ROOT,
|
||||||
'TAUTULLI_APIKEY': plexpy.CONFIG.API_KEY,
|
'TAUTULLI_APIKEY': plexpy.CONFIG.API_KEY,
|
||||||
'TAUTULLI_ENCODING': plexpy.SYS_ENCODING
|
'TAUTULLI_ENCODING': plexpy.SYS_ENCODING
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if user_id:
|
||||||
|
user_tokens = users.Users().get_tokens(user_id=user_id)
|
||||||
|
if user_tokens and user_tokens['server_token']:
|
||||||
|
env['PLEX_USER_TOKEN'] = str(user_tokens['server_token'])
|
||||||
|
|
||||||
if self.pythonpath:
|
if self.pythonpath:
|
||||||
env['PYTHONPATH'] = os.pathsep.join([p for p in sys.path if p])
|
env['PYTHONPATH'] = os.pathsep.join([p for p in sys.path if p])
|
||||||
|
|
||||||
|
@ -3106,6 +3112,7 @@ class SCRIPTS(Notifier):
|
||||||
% (action, script_args))
|
% (action, script_args))
|
||||||
|
|
||||||
script = kwargs.get('script', self.config.get('script', ''))
|
script = kwargs.get('script', self.config.get('script', ''))
|
||||||
|
user_id = kwargs.get('parameters', {}).get('user_id')
|
||||||
|
|
||||||
# Don't try to run the script if the action does not have one
|
# Don't try to run the script if the action does not have one
|
||||||
if action and not script:
|
if action and not script:
|
||||||
|
@ -3152,7 +3159,7 @@ class SCRIPTS(Notifier):
|
||||||
|
|
||||||
logger.debug(u"Tautulli Notifiers :: Full script is: %s" % script)
|
logger.debug(u"Tautulli Notifiers :: Full script is: %s" % script)
|
||||||
logger.debug(u"Tautulli Notifiers :: Executing script in a new thread.")
|
logger.debug(u"Tautulli Notifiers :: Executing script in a new thread.")
|
||||||
thread = threading.Thread(target=self.run_script, args=(script,)).start()
|
thread = threading.Thread(target=self.run_script, args=(script, user_id)).start()
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue