mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-08 14:10:52 -07:00
Pass common environment variable to scripts
This commit is contained in:
parent
2479533d07
commit
ee041db63d
3 changed files with 47 additions and 34 deletions
|
@ -933,3 +933,36 @@ def eval_logic_groups_to_bool(logic_groups, eval_conds):
|
|||
result = result or eval_cond
|
||||
|
||||
return result
|
||||
|
||||
def get_plexpy_url(hostname=None):
|
||||
if plexpy.CONFIG.ENABLE_HTTPS:
|
||||
scheme = 'https'
|
||||
else:
|
||||
scheme = 'http'
|
||||
|
||||
if hostname is None and plexpy.CONFIG.HTTP_HOST == '0.0.0.0':
|
||||
import socket
|
||||
try:
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
s.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
|
||||
s.connect(('<broadcast>', 0))
|
||||
hostname = s.getsockname()[0]
|
||||
except socket.error:
|
||||
hostname = socket.gethostbyname(socket.gethostname())
|
||||
|
||||
if not hostname:
|
||||
hostname = 'localhost'
|
||||
else:
|
||||
hostname = hostname or plexpy.CONFIG.HTTP_HOST
|
||||
|
||||
if plexpy.CONFIG.HTTP_PORT not in (80, 443):
|
||||
port = ':' + str(plexpy.CONFIG.HTTP_PORT)
|
||||
else:
|
||||
port = ''
|
||||
|
||||
if plexpy.CONFIG.HTTP_ROOT.strip('/'):
|
||||
root = '/' + plexpy.CONFIG.HTTP_ROOT.strip('/')
|
||||
else:
|
||||
root = ''
|
||||
|
||||
return scheme + '://' + hostname + port + root
|
Loading…
Add table
Add a link
Reference in a new issue