mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-08-14 02:26:58 -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
|
||||
|
||||
def run_script(self, script):
|
||||
def run_script(self, script, user_id):
|
||||
# Common environment variables
|
||||
env = os.environ.copy()
|
||||
env.update({
|
||||
'PLEX_URL': plexpy.CONFIG.PMS_URL,
|
||||
'PLEX_TOKEN': plexpy.CONFIG.PMS_TOKEN,
|
||||
'PLEX_USER_TOKEN': '',
|
||||
'TAUTULLI_URL': helpers.get_plexpy_url(hostname='localhost'),
|
||||
'TAUTULLI_PUBLIC_URL': plexpy.CONFIG.HTTP_BASE_URL + plexpy.HTTP_ROOT,
|
||||
'TAUTULLI_APIKEY': plexpy.CONFIG.API_KEY,
|
||||
'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:
|
||||
env['PYTHONPATH'] = os.pathsep.join([p for p in sys.path if p])
|
||||
|
||||
|
@ -3106,6 +3112,7 @@ class SCRIPTS(Notifier):
|
|||
% (action, script_args))
|
||||
|
||||
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
|
||||
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 :: 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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue