From 4911cc76a3968c11e132a77cda8715219714b2c8 Mon Sep 17 00:00:00 2001 From: JonnyWong16 Date: Fri, 15 Jul 2016 09:44:06 -0700 Subject: [PATCH 1/8] Substitute {update_version} in fallback notification --- plexpy/notification_handler.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plexpy/notification_handler.py b/plexpy/notification_handler.py index 7d86b4df..fe9759fd 100644 --- a/plexpy/notification_handler.py +++ b/plexpy/notification_handler.py @@ -1249,7 +1249,7 @@ def build_server_notify_text(notify_action=None, agent_id=None): elif notify_action == 'pmsupdate': # Default body text - body_text = 'An update is available for the Plex Media Server (version {update_version}).' + body_text = 'An update is available for the Plex Media Server (version %s).' % available_params['update_version'] if on_pmsupdate_subject and on_pmsupdate_body: try: @@ -1300,4 +1300,4 @@ def strip_tag(data, agent_id=None): else: whitelist = {} - return bleach.clean(data, tags=whitelist.keys(), attributes=whitelist, strip=True) \ No newline at end of file + return bleach.clean(data, tags=whitelist.keys(), attributes=whitelist, strip=True) From 28bb164e8eeb215034eddd61aaa941565fac5a4d Mon Sep 17 00:00:00 2001 From: JonnyWong16 Date: Fri, 15 Jul 2016 18:16:36 -0700 Subject: [PATCH 2/8] Auto log IP message in settings --- data/interfaces/default/settings.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/interfaces/default/settings.html b/data/interfaces/default/settings.html index d1b8a8e9..f6d6f2b7 100644 --- a/data/interfaces/default/settings.html +++ b/data/interfaces/default/settings.html @@ -2438,7 +2438,7 @@ $(document).ready(function() { // Checks to see if PMS server version is >= 0.9.14 with automaatically logged IP addresses var version = "${config['pms_version']}".split('.'); - if (version && parseInt(version[0]) >= 0 && parseInt(version[1]) >= 9 && parseInt(version[2]) >= 14) { + if (version && (parseInt(version[0]) >= 0 || parseInt(version[0]) == 0 && parseInt(version[1]) >= 9 && parseInt(version[2]) >= 14)) { $("#debugLogCheck").html("IP address is automatically logged for PMS version 0.9.14 and above."); $("#ip_logging_enable").attr("disabled", true); $("#ip_logging_enable").attr("checked", true); From 93b8f32f6876637309b860a450bf89898b5f3c1a Mon Sep 17 00:00:00 2001 From: JonnyWong16 Date: Fri, 15 Jul 2016 18:17:11 -0700 Subject: [PATCH 3/8] Use library refresh interval --- plexpy/__init__.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/plexpy/__init__.py b/plexpy/__init__.py index afb6150a..0b529abf 100644 --- a/plexpy/__init__.py +++ b/plexpy/__init__.py @@ -332,19 +332,16 @@ def initialize_scheduler(): hours=0, minutes=0, seconds=seconds) # Refresh the users list - if CONFIG.REFRESH_USERS_INTERVAL: - hours = CONFIG.REFRESH_USERS_INTERVAL - else: - hours = 0 - + user_refresh_hours = CONFIG.REFRESH_USERS_INTERVAL or 0 + library_refresh_hours = CONFIG.REFRESH_LIBRARIES_INTERVAL or 0 if CONFIG.PMS_TOKEN: schedule_job(plextv.refresh_users, 'Refresh users list', - hours=hours, minutes=0, seconds=0) + hours=user_refresh_hours, minutes=0, seconds=0) if CONFIG.PMS_IP and CONFIG.PMS_TOKEN: schedule_job(pmsconnect.refresh_libraries, 'Refresh libraries list', - hours=hours, minutes=0, seconds=0) + hours=library_refresh_hours, minutes=0, seconds=0) schedule_job(database.make_backup, 'Backup PlexPy database', hours=6, minutes=0, seconds=0, args=(True, True)) schedule_job(config.make_backup, 'Backup PlexPy config', hours=6, minutes=0, seconds=0, args=(True, True)) From 65b3d0c0de4ace10e162024eef934f43aa704faf Mon Sep 17 00:00:00 2001 From: JonnyWong16 Date: Fri, 15 Jul 2016 22:43:36 -0700 Subject: [PATCH 4/8] Better version comparisons --- data/interfaces/default/settings.html | 4 ++-- plexpy/plextv.py | 19 +++++-------------- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/data/interfaces/default/settings.html b/data/interfaces/default/settings.html index f6d6f2b7..b0d2cb12 100644 --- a/data/interfaces/default/settings.html +++ b/data/interfaces/default/settings.html @@ -2437,8 +2437,8 @@ $(document).ready(function() { pms_logs = false; // Checks to see if PMS server version is >= 0.9.14 with automaatically logged IP addresses - var version = "${config['pms_version']}".split('.'); - if (version && (parseInt(version[0]) >= 0 || parseInt(version[0]) == 0 && parseInt(version[1]) >= 9 && parseInt(version[2]) >= 14)) { + var version = parseInt($.map("${config['pms_version']}".split('-')[0].split('.').slice(0,4), function(v) { return ('0000'+v).substring(v.length); }).join("")); + if (version > 900140000) { $("#debugLogCheck").html("IP address is automatically logged for PMS version 0.9.14 and above."); $("#ip_logging_enable").attr("disabled", true); $("#ip_logging_enable").attr("checked", true); diff --git a/plexpy/plextv.py b/plexpy/plextv.py index f39c6b10..22106351 100644 --- a/plexpy/plextv.py +++ b/plexpy/plextv.py @@ -633,32 +633,23 @@ class PlexTV(object): % plexpy.CONFIG.PMS_PLATFORM) return {} - v_old = plexpy.CONFIG.PMS_VERSION.split('-')[0].split('.') - v_new = platform_downloads.get('version', '').split('-')[0].split('.') + v_old = helpers.cast_to_int("".join(v.zfill(4) for v in plexpy.CONFIG.PMS_VERSION.split('-')[0].split('.')[:4])) + v_new = helpers.cast_to_int("".join(v.zfill(4) for v in platform_downloads.get('version', '').split('-')[0].split('.')[:4])) - if len(v_old) < 4: + if not v_old: logger.error(u"PlexPy PlexTV :: Unable to retrieve Plex updates: Invalid current server version: %s." % plexpy.CONFIG.PMS_VERSION) return {} - if len(v_new) < 4: + if not v_new: logger.error(u"PlexPy PlexTV :: Unable to retrieve Plex updates: Invalid new server version: %s." % platform_downloads.get('version')) return {} - # Compare versions - if v_new[0] > v_old[0] or \ - v_new[0] == v_old[0] and v_new[1] > v_old[1] or \ - v_new[0] == v_old[0] and v_new[1] == v_old[1] and v_new[2] > v_old[2] or \ - v_new[0] == v_old[0] and v_new[1] == v_old[1] and v_new[2] == v_old[2] and v_new[3] > v_old[3]: - update_available = True - else: - update_available = False - # Get proper download releases = platform_downloads.get('releases', [{}]) release = next((r for r in releases if r['build'] == plexpy.CONFIG.PMS_UPDATE_DISTRO_BUILD), releases[0]) - download_info = {'update_available': update_available, + download_info = {'update_available': v_new > v_old, 'platform': platform_downloads.get('name'), 'release_date': platform_downloads.get('release_date'), 'version': platform_downloads.get('version'), From b9bbf8bbca7b9d4b0bea952aa7ced9e5e6c710e3 Mon Sep 17 00:00:00 2001 From: JonnyWong16 Date: Fri, 15 Jul 2016 22:51:11 -0700 Subject: [PATCH 5/8] Option to specify backup interval --- data/interfaces/default/settings.html | 18 ++++++++++++++++-- plexpy/__init__.py | 14 +++++++++----- plexpy/config.py | 1 + plexpy/webserve.py | 1 + 4 files changed, 27 insertions(+), 7 deletions(-) diff --git a/data/interfaces/default/settings.html b/data/interfaces/default/settings.html index b0d2cb12..15798dad 100644 --- a/data/interfaces/default/settings.html +++ b/data/interfaces/default/settings.html @@ -124,6 +124,20 @@

Group successive play history by the same user as a single entry in the tables and watch statistics.

+
+

Backup

+
+
+ +
+
+ +
+ +
+

The interval (in hours) PlexPy will backup the database and configuration file. Minimum 1, maximum 24, default 6.

+
+

Directories

@@ -640,7 +654,7 @@ -

The interval (in hours) PlexPy will request an updated friends list from Plex.tv. 1 minimum, 24 maximum.

+

The interval (in hours) PlexPy will request an updated friends list from Plex.tv. Minimum 1, maximum 24, default 12.

-

The interval (in hours) PlexPy will request an updated libraries list from your Plex Media Server. 1 minimum, 24 maximum.

+

The interval (in hours) PlexPy will request an updated libraries list from your Plex Media Server. Minimum 1, maximum 24, default 12.