diff --git a/data/interfaces/default/index.html b/data/interfaces/default/index.html index ca10ce39..1eb26c1d 100644 --- a/data/interfaces/default/index.html +++ b/data/interfaces/default/index.html @@ -33,7 +33,7 @@
-

Library Statistics

+

Library Statistics ${config['pms_name']}

Loading stats...
@@ -98,19 +98,6 @@ }); } - function getLibraryStatsHeader() { - $.ajax({ - url: 'get_server_friendly_name', - cache: false, - async: true, - data: { }, - complete: function (xhr, status) { - server_name = xhr.responseText; - $('#library-statistics-header h3').append(' ' + server_name + '') - } - }); - } - function getLibraryStats() { $.ajax({ url: 'library_stats', @@ -162,7 +149,6 @@ }); getHomeStats(); - getLibraryStatsHeader(); getLibraryStats(); diff --git a/plexpy/__init__.py b/plexpy/__init__.py index 0c277473..3cf7d2a9 100644 --- a/plexpy/__init__.py +++ b/plexpy/__init__.py @@ -31,7 +31,7 @@ except ImportError: from apscheduler.schedulers.background import BackgroundScheduler from apscheduler.triggers.interval import IntervalTrigger -from plexpy import versioncheck, logger, activity_pinger, plextv +from plexpy import versioncheck, logger, activity_pinger, plextv, pmsconnect import plexpy.config PROG_DIR = None @@ -169,6 +169,7 @@ def initialize(config_file): # Get the real PMS urls for SSL and remote access if CONFIG.PMS_TOKEN and CONFIG.PMS_IP and CONFIG.PMS_PORT: plextv.get_real_pms_url() + pmsconnect.PmsConnect().get_server_friendly_name() # Refresh the users list on startup if CONFIG.PMS_TOKEN and CONFIG.REFRESH_USERS_ON_STARTUP: @@ -280,7 +281,10 @@ def initialize_scheduler(): seconds = 0 if CONFIG.PMS_IP and CONFIG.PMS_TOKEN: - schedule_job(plextv.get_real_pms_url, 'Refresh Plex Server URLs', hours=12, minutes=0, seconds=0) + schedule_job(plextv.get_real_pms_url, 'Refresh Plex Server URLs', + hours=12, minutes=0, seconds=0) + schedule_job(pmsconnect.PmsConnect().get_server_friendly_name, 'Refresh Plex Server Name', + hours=12, minutes=0, seconds=0) # If we're not using websockets then fall back to polling if not CONFIG.MONITORING_USE_WEBSOCKET or POLLING_FAILOVER: diff --git a/plexpy/config.py b/plexpy/config.py index 88346b9a..dc274e00 100644 --- a/plexpy/config.py +++ b/plexpy/config.py @@ -26,6 +26,7 @@ _CONFIG_DEFINITIONS = { 'PMS_IP': (str, 'PMS', '127.0.0.1'), 'PMS_IS_REMOTE': (int, 'PMS', 0), 'PMS_LOGS_FOLDER': (str, 'PMS', ''), + 'PMS_NAME': (str, 'PMS', ''), 'PMS_PORT': (int, 'PMS', 32400), 'PMS_TOKEN': (str, 'PMS', ''), 'PMS_SSL': (int, 'General', 0), diff --git a/plexpy/pmsconnect.py b/plexpy/pmsconnect.py index 12807983..5fcee3af 100644 --- a/plexpy/pmsconnect.py +++ b/plexpy/pmsconnect.py @@ -1645,4 +1645,8 @@ class PmsConnect(object): server_name = server['name'] break + if server_name != plexpy.CONFIG.PMS_NAME: + plexpy.CONFIG.__setattr__('PMS_NAME', server_name) + plexpy.CONFIG.write() + return server_name \ No newline at end of file diff --git a/plexpy/webserve.py b/plexpy/webserve.py index aae99de3..7baa4cbf 100644 --- a/plexpy/webserve.py +++ b/plexpy/webserve.py @@ -46,9 +46,7 @@ def serve_template(templatename, **kwargs): _hplookup = TemplateLookup(directories=[template_dir]) - # Get the server name - pms_connect = pmsconnect.PmsConnect() - server_name = pms_connect.get_server_friendly_name() + server_name = plexpy.CONFIG.PMS_NAME try: template = _hplookup.get_template(templatename) @@ -75,7 +73,8 @@ class WebInterface(object): "home_stats_length": plexpy.CONFIG.HOME_STATS_LENGTH, "home_stats_cards": plexpy.CONFIG.HOME_STATS_CARDS, "home_library_cards": plexpy.CONFIG.HOME_LIBRARY_CARDS, - "pms_identifier": plexpy.CONFIG.PMS_IDENTIFIER + "pms_identifier": plexpy.CONFIG.PMS_IDENTIFIER, + "pms_name": plexpy.CONFIG.PMS_NAME } return serve_template(templatename="index.html", title="Home", config=config)