From 7c0c7eea308616d202fa743bf1b9e2bc5f75bb50 Mon Sep 17 00:00:00 2001 From: JonnyWong16 Date: Sat, 22 Apr 2017 12:44:46 -0700 Subject: [PATCH] Remove global logging toggles --- data/interfaces/default/settings.html | 16 ----------- plexpy/__init__.py | 2 ++ plexpy/activity_processor.py | 9 +------ plexpy/config.py | 1 + plexpy/libraries.py | 38 ++++++++++++++++++++++++++- plexpy/webserve.py | 4 --- 6 files changed, 41 insertions(+), 29 deletions(-) diff --git a/data/interfaces/default/settings.html b/data/interfaces/default/settings.html index 6e4422ea..7702cba9 100644 --- a/data/interfaces/default/settings.html +++ b/data/interfaces/default/settings.html @@ -715,22 +715,6 @@

History Logging

-

Keep records of all movie, TV show, or music items played from your Plex Media Server.

-
- -
-
- -
-
- -
diff --git a/plexpy/__init__.py b/plexpy/__init__.py index c7b0f7f6..d0654649 100644 --- a/plexpy/__init__.py +++ b/plexpy/__init__.py @@ -1079,6 +1079,8 @@ def dbcheck(): def upgrade(): if CONFIG.UPDATE_NOTIFIERS_DB: notifiers.upgrade_config_to_db() + if CONFIG.UPDATE_LIBRARIES_DB_NOTIFY: + libraries.update_libraries_db_notify() def shutdown(restart=False, update=False, checkout=False): cherrypy.engine.exit() diff --git a/plexpy/activity_processor.py b/plexpy/activity_processor.py index ac74e8b0..3822e83b 100644 --- a/plexpy/activity_processor.py +++ b/plexpy/activity_processor.py @@ -138,14 +138,7 @@ class ActivityProcessor(object): state='stopped', stopped=stopped) - if plexpy.CONFIG.MOVIE_LOGGING_ENABLE and str(session['rating_key']).isdigit() and \ - session['media_type'] == 'movie': - logging_enabled = True - elif plexpy.CONFIG.TV_LOGGING_ENABLE and str(session['rating_key']).isdigit() and \ - session['media_type'] == 'episode': - logging_enabled = True - elif plexpy.CONFIG.MUSIC_LOGGING_ENABLE and str(session['rating_key']).isdigit() and \ - session['media_type'] == 'track': + if str(session['rating_key']).isdigit() and session['media_type'] in ('movie', 'episode', 'track'): logging_enabled = True else: logger.debug(u"PlexPy ActivityProcessor :: ratingKey %s not logged. Does not meet logging criteria. " diff --git a/plexpy/config.py b/plexpy/config.py index ffe1e19e..119c0cca 100644 --- a/plexpy/config.py +++ b/plexpy/config.py @@ -574,6 +574,7 @@ _CONFIG_DEFINITIONS = { 'UPDATE_SECTION_IDS': (int, 'General', 1), 'UPDATE_SHOW_CHANGELOG': (int, 'General', 1), 'UPDATE_LABELS': (int, 'General', 1), + 'UPDATE_LIBRARIES_DB_NOTIFY': (int, 'General', 1), 'UPDATE_NOTIFIERS_DB': (int, 'General', 1), 'VERIFY_SSL_CERT': (bool_int, 'Advanced', 1), 'VIDEO_LOGGING_ENABLE': (int, 'Monitoring', 1), diff --git a/plexpy/libraries.py b/plexpy/libraries.py index edbc0d48..fd05fdb1 100644 --- a/plexpy/libraries.py +++ b/plexpy/libraries.py @@ -976,4 +976,40 @@ class Libraries(object): return 'Deleted duplicate libraries from the database.' except Exception as e: - logger.warn(u"PlexPy Libraries :: Unable to delete duplicate libraries: %s." % e) \ No newline at end of file + logger.warn(u"PlexPy Libraries :: Unable to delete duplicate libraries: %s." % e) + + +def update_libraries_db_notify(): + logger.info(u"PlexPy Libraries :: Upgrading library notification toggles...") + + # Set flag first in case something fails we don't want to keep re-adding the notifiers + plexpy.CONFIG.__setattr__('UPDATE_LIBRARIES_DB_NOTIFY', 0) + plexpy.CONFIG.write() + + libraries = Libraries() + sections = libraries.get_sections() + + for section in sections: + section_details = libraries.get_details(section['section_id']) + + if (section_details['do_notify'] == 1 and + (section_details['section_type'] == 'movie' and not plexpy.CONFIG.MOVIE_NOTIFY_ENABLE) or + (section_details['section_type'] == 'show' and not plexpy.CONFIG.TV_NOTIFY_ENABLE) or + (section_details['section_type'] == 'artist' and not plexpy.CONFIG.MUSIC_NOTIFY_ENABLE)): + do_notify = 0 + else: + do_notify = section_details['do_notify'] + + if (section_details['keep_history'] == 1 and + (section_details['section_type'] == 'movie' and not plexpy.CONFIG.MOVIE_LOGGING_ENABLE) or + (section_details['section_type'] == 'show' and not plexpy.CONFIG.TV_LOGGING_ENABLE) or + (section_details['section_type'] == 'artist' and not plexpy.CONFIG.MUSIC_LOGGING_ENABLE)): + keep_history = 0 + else: + keep_history = section_details['keep_history'] + + libraries.set_config(section_id=section_details['section_id'], + custom_thumb=section_details['library_thumb'], + do_notify=do_notify, + keep_history=keep_history, + do_notify_created=section_details['do_notify_created']) diff --git a/plexpy/webserve.py b/plexpy/webserve.py index d4339178..84616015 100644 --- a/plexpy/webserve.py +++ b/plexpy/webserve.py @@ -2591,9 +2591,6 @@ class WebInterface(object): "refresh_libraries_on_startup": checked(plexpy.CONFIG.REFRESH_LIBRARIES_ON_STARTUP), "refresh_users_interval": plexpy.CONFIG.REFRESH_USERS_INTERVAL, "refresh_users_on_startup": checked(plexpy.CONFIG.REFRESH_USERS_ON_STARTUP), - "movie_logging_enable": checked(plexpy.CONFIG.MOVIE_LOGGING_ENABLE), - "tv_logging_enable": checked(plexpy.CONFIG.TV_LOGGING_ENABLE), - "music_logging_enable": checked(plexpy.CONFIG.MUSIC_LOGGING_ENABLE), "logging_ignore_interval": plexpy.CONFIG.LOGGING_IGNORE_INTERVAL, "pms_is_remote": checked(plexpy.CONFIG.PMS_IS_REMOTE), "notify_consecutive": checked(plexpy.CONFIG.NOTIFY_CONSECUTIVE), @@ -2636,7 +2633,6 @@ class WebInterface(object): "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", "refresh_libraries_on_startup", "refresh_users_on_startup", - "movie_logging_enable", "tv_logging_enable", "music_logging_enable", "notify_consecutive", "notify_upload_posters", "notify_recently_added_upgrade", "notify_group_recently_added_grandparent", "notify_group_recently_added_parent", "monitor_pms_updates", "monitor_remote_access", "get_file_sizes", "log_blacklist", "http_hash_password",