mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-12 16:22:57 -07:00
Add dynamic anonymous redirect service setting
This commit is contained in:
parent
c13b1a67f2
commit
ecb66f39c9
4 changed files with 48 additions and 9 deletions
|
@ -76,7 +76,8 @@ _CONFIG_DEFINITIONS = {
|
|||
'PMS_UPDATE_CHECK_INTERVAL': (int, 'Advanced', 24),
|
||||
'PMS_WEB_URL': (str, 'PMS', 'https://app.plex.tv/desktop'),
|
||||
'TIME_FORMAT': (str, 'General', 'HH:mm'),
|
||||
'ANON_REDIRECT': (str, 'General', 'https://www.nullrefer.com/?'),
|
||||
'ANON_REDIRECT': (str, 'General', ''),
|
||||
'ANON_REDIRECT_DYNAMIC': (int, 'General', 1),
|
||||
'API_ENABLED': (int, 'General', 1),
|
||||
'API_KEY': (str, 'General', ''),
|
||||
'API_SQL': (int, 'General', 0),
|
||||
|
|
|
@ -775,7 +775,31 @@ def anon_url(*url):
|
|||
"""
|
||||
Return a URL string consisting of the Anonymous redirect URL and an arbitrary number of values appended.
|
||||
"""
|
||||
return '' if None in url else '%s%s' % (plexpy.CONFIG.ANON_REDIRECT, ''.join(str(s) for s in url))
|
||||
if plexpy.CONFIG.ANON_REDIRECT_DYNAMIC:
|
||||
cache_time = timestamp()
|
||||
cache_filepath = os.path.join(plexpy.CONFIG.CACHE_DIR, 'anonymizer.json')
|
||||
try:
|
||||
with open(cache_filepath, 'r', encoding='utf-8') as cache_file:
|
||||
cache_data = json.load(cache_file)
|
||||
if cache_time - cache_data['_cache_time'] < 86400: # 24 hours
|
||||
anon_redirect = cache_data['anon_redirect']
|
||||
else:
|
||||
raise
|
||||
except:
|
||||
try:
|
||||
anon_redirect = request.request_content('https://tautulli.com/anonymizer.txt').decode('utf-8')
|
||||
cache_data = {
|
||||
'anon_redirect': anon_redirect,
|
||||
'_cache_time': cache_time
|
||||
}
|
||||
with open(cache_filepath, 'w', encoding='utf-8') as cache_file:
|
||||
json.dump(cache_data, cache_file)
|
||||
except:
|
||||
anon_redirect = plexpy.CONFIG.ANON_REDIRECT
|
||||
else:
|
||||
anon_redirect = plexpy.CONFIG.ANON_REDIRECT
|
||||
|
||||
return '' if None in url else '%s%s' % (anon_redirect, ''.join(str(s) for s in url))
|
||||
|
||||
|
||||
def get_img_service(include_self=False):
|
||||
|
|
|
@ -3143,6 +3143,7 @@ class WebInterface(object):
|
|||
"https_ip": plexpy.CONFIG.HTTPS_IP,
|
||||
"http_base_url": plexpy.CONFIG.HTTP_BASE_URL,
|
||||
"anon_redirect": plexpy.CONFIG.ANON_REDIRECT,
|
||||
"anon_redirect_dynamic": checked(plexpy.CONFIG.ANON_REDIRECT_DYNAMIC),
|
||||
"api_enabled": checked(plexpy.CONFIG.API_ENABLED),
|
||||
"api_key": plexpy.CONFIG.API_KEY,
|
||||
"update_db_interval": plexpy.CONFIG.UPDATE_DB_INTERVAL,
|
||||
|
@ -3265,7 +3266,8 @@ class WebInterface(object):
|
|||
"allow_guest_access", "cache_images", "http_proxy", "notify_concurrent_by_ip",
|
||||
"history_table_activity", "plexpy_auto_update",
|
||||
"themoviedb_lookup", "tvmaze_lookup", "musicbrainz_lookup", "http_plex_admin",
|
||||
"newsletter_self_hosted", "newsletter_inline_styles", "sys_tray_icon"
|
||||
"newsletter_self_hosted", "newsletter_inline_styles", "sys_tray_icon",
|
||||
"anon_redirect_dynamic"
|
||||
]
|
||||
for checked_config in checked_configs:
|
||||
if checked_config not in kwargs:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue