diff --git a/data/interfaces/default/settings.html b/data/interfaces/default/settings.html index 6997e170..98a4d64f 100644 --- a/data/interfaces/default/settings.html +++ b/data/interfaces/default/settings.html @@ -591,6 +591,12 @@

If you have secure connections enabled on your Plex Server, communicate with it securely.

+
+ +

Use the user defined connection details. Do not retrieve the server connection URL automatically.

+
diff --git a/plexpy/__init__.py b/plexpy/__init__.py index 2efdbc95..4f261142 100644 --- a/plexpy/__init__.py +++ b/plexpy/__init__.py @@ -323,7 +323,7 @@ def initialize_scheduler(): #schedule_job(activity_pinger.check_recently_added, 'Check for recently added items', # hours=0, minutes=0, seconds=monitor_seconds * bool(CONFIG.NOTIFY_RECENTLY_ADDED)) schedule_job(plextv.get_real_pms_url, 'Refresh Plex server URLs', - hours=12, minutes=0, seconds=0) + hours=12 * (not bool(CONFIG.PMS_URL_MANUAL)), minutes=0, seconds=0) schedule_job(pmsconnect.get_server_friendly_name, 'Refresh Plex server name', hours=12, minutes=0, seconds=0) diff --git a/plexpy/config.py b/plexpy/config.py index 3db61425..d2a28d56 100644 --- a/plexpy/config.py +++ b/plexpy/config.py @@ -53,6 +53,7 @@ _CONFIG_DEFINITIONS = { 'PMS_TOKEN': (str, 'PMS', ''), 'PMS_SSL': (int, 'PMS', 0), 'PMS_URL': (str, 'PMS', ''), + 'PMS_URL_MANUAL': (int, 'PMS', 0), 'PMS_USE_BIF': (int, 'PMS', 0), 'PMS_UUID': (str, 'PMS', ''), 'PMS_TIMEOUT': (int, 'Advanced', 15), diff --git a/plexpy/plextv.py b/plexpy/plextv.py index 26cdcc77..2fc1b89d 100644 --- a/plexpy/plextv.py +++ b/plexpy/plextv.py @@ -95,7 +95,7 @@ def get_real_pms_url(): plexpy.CONFIG.__setattr__('PMS_URL', '') plexpy.CONFIG.write() - fallback_url = 'http://' + plexpy.CONFIG.PMS_IP + ':' + str(plexpy.CONFIG.PMS_PORT) + fallback_url = 'http://{}:{}'.format(plexpy.CONFIG.PMS_IP, plexpy.CONFIG.PMS_PORT) plex_tv = PlexTV() result = plex_tv.get_server_urls(include_https=plexpy.CONFIG.PMS_SSL) @@ -109,7 +109,7 @@ def get_real_pms_url(): connections = result['connections'] # Only need to retrieve PMS_URL if using SSL - if plexpy.CONFIG.PMS_SSL: + if not plexpy.CONFIG.PMS_URL_MANUAL and plexpy.CONFIG.PMS_SSL: if connections: if plexpy.CONFIG.PMS_IS_REMOTE: # Get all remote connections @@ -134,6 +134,9 @@ def get_real_pms_url(): # Not using SSL, remote has no effect else: + if plexpy.CONFIG.PMS_URL_MANUAL and plexpy.CONFIG.PMS_SSL: + fallback_url = fallback_url.replace('http://', 'https://') + plexpy.CONFIG.__setattr__('PMS_URL', fallback_url) plexpy.CONFIG.write() logger.info(u"PlexPy PlexTV :: Using user-defined URL.") diff --git a/plexpy/webserve.py b/plexpy/webserve.py index e1f8a837..65fc333f 100644 --- a/plexpy/webserve.py +++ b/plexpy/webserve.py @@ -2621,6 +2621,7 @@ class WebInterface(object): "pms_port": plexpy.CONFIG.PMS_PORT, "pms_token": plexpy.CONFIG.PMS_TOKEN, "pms_ssl": checked(plexpy.CONFIG.PMS_SSL), + "pms_url_manual": checked(plexpy.CONFIG.PMS_URL_MANUAL), "pms_use_bif": checked(plexpy.CONFIG.PMS_USE_BIF), "pms_uuid": plexpy.CONFIG.PMS_UUID, "date_format": plexpy.CONFIG.DATE_FORMAT, @@ -2679,7 +2680,7 @@ class WebInterface(object): checked_configs = [ "launch_browser", "enable_https", "https_create_cert", "api_enabled", "freeze_db", "check_github", "grouping_global_history", "grouping_user_history", "grouping_charts", "group_history_tables", - "pms_use_bif", "pms_ssl", "pms_is_remote", "home_stats_type", "week_start_monday", + "pms_use_bif", "pms_ssl", "pms_is_remote", "pms_url_manual", "home_stats_type", "week_start_monday", "refresh_libraries_on_startup", "refresh_users_on_startup", "notify_consecutive", "notify_upload_posters", "notify_recently_added_upgrade", "notify_group_recently_added_grandparent", "notify_group_recently_added_parent", @@ -2730,14 +2731,15 @@ class WebInterface(object): kwargs.get('monitoring_interval') != str(plexpy.CONFIG.MONITORING_INTERVAL) or \ kwargs.get('refresh_libraries_interval') != str(plexpy.CONFIG.REFRESH_LIBRARIES_INTERVAL) or \ kwargs.get('refresh_users_interval') != str(plexpy.CONFIG.REFRESH_USERS_INTERVAL) or \ - kwargs.get('notify_recently_added') != plexpy.CONFIG.NOTIFY_RECENTLY_ADDED or \ kwargs.get('monitor_pms_updates') != plexpy.CONFIG.MONITOR_PMS_UPDATES or \ - kwargs.get('monitor_remote_access') != plexpy.CONFIG.MONITOR_REMOTE_ACCESS: + kwargs.get('monitor_remote_access') != plexpy.CONFIG.MONITOR_REMOTE_ACCESS or \ + kwargs.get('pms_url_manual') != plexpy.CONFIG.PMS_URL_MANUAL: reschedule = True # If we change the SSL setting for PMS or PMS remote setting, make sure we grab the new url. if kwargs.get('pms_ssl') != plexpy.CONFIG.PMS_SSL or \ - kwargs.get('pms_is_remote') != plexpy.CONFIG.PMS_IS_REMOTE: + kwargs.get('pms_is_remote') != plexpy.CONFIG.PMS_IS_REMOTE or \ + kwargs.get('pms_url_manual') != plexpy.CONFIG.PMS_URL_MANUAL: server_changed = True # If we change the HTTPS setting, make sure we generate a new certificate.