diff --git a/data/interfaces/default/settings.html b/data/interfaces/default/settings.html index 166999cc..802c4192 100644 --- a/data/interfaces/default/settings.html +++ b/data/interfaces/default/settings.html @@ -779,27 +779,6 @@
- -
-
- -
-
- -
-
- -
- -
diff --git a/plexpy/__init__.py b/plexpy/__init__.py index 78d0436c..4b7b1a62 100644 --- a/plexpy/__init__.py +++ b/plexpy/__init__.py @@ -402,9 +402,7 @@ def start(): if _INITIALIZED: # Start background notification thread - if any([CONFIG.MOVIE_NOTIFY_ENABLE, CONFIG.TV_NOTIFY_ENABLE, - CONFIG.MUSIC_NOTIFY_ENABLE, CONFIG.NOTIFY_RECENTLY_ADDED]): - notification_handler.start_threads(num_threads=CONFIG.NOTIFICATION_THREADS) + notification_handler.start_threads(num_threads=CONFIG.NOTIFICATION_THREADS) _STARTED = True diff --git a/plexpy/notification_handler.py b/plexpy/notification_handler.py index 7da37d18..36ba9d8b 100644 --- a/plexpy/notification_handler.py +++ b/plexpy/notification_handler.py @@ -118,11 +118,9 @@ def add_notifier_each(notify_action=None, stream_data=None, timeline_data=None, def notify_conditions(notifier=None, notify_action=None, stream_data=None, timeline_data=None): + # Activity notifications if stream_data: - if stream_data['media_type'] == 'clip': - return False - # Check if notifications enabled for user and library user_data = users.Users() user_details = user_data.get_details(user_id=stream_data['user_id']) @@ -133,36 +131,45 @@ def notify_conditions(notifier=None, notify_action=None, stream_data=None, timel if not user_details['do_notify']: # logger.debug(u"PlexPy NotificationHandler :: Notifications for user '%s' is disabled." % user_details['username']) return False - elif not library_details['do_notify']: + + elif not library_details['do_notify'] and notify_action not in ('on_concurrent', 'on_newdevice'): # logger.debug(u"PlexPy NotificationHandler :: Notifications for library '%s' is disabled." % library_details['section_name']) return False - if (stream_data['media_type'] == 'movie' and plexpy.CONFIG.MOVIE_NOTIFY_ENABLE) \ - or (stream_data['media_type'] == 'episode' and plexpy.CONFIG.TV_NOTIFY_ENABLE): - - progress_percent = helpers.get_percent(stream_data['view_offset'], stream_data['duration']) - + if notify_action == 'on_concurrent': ap = activity_processor.ActivityProcessor() user_sessions = ap.get_sessions(user_id=stream_data['user_id'], ip_address=plexpy.CONFIG.NOTIFY_CONCURRENT_BY_IP) + return len(user_sessions) >= plexpy.CONFIG.NOTIFY_CONCURRENT_THRESHOLD + elif notify_action == 'on_newdevice': data_factory = datafactory.DataFactory() user_devices = data_factory.get_user_devices(user_id=stream_data['user_id']) + return stream_data['machine_id'] not in user_devices - conditions = \ - {'on_stop': plexpy.CONFIG.NOTIFY_CONSECUTIVE or progress_percent < plexpy.CONFIG.NOTIFY_WATCHED_PERCENT, - 'on_resume': plexpy.CONFIG.NOTIFY_CONSECUTIVE or progress_percent < 99, - 'on_concurrent': len(user_sessions) >= plexpy.CONFIG.NOTIFY_CONCURRENT_THRESHOLD, - 'on_newdevice': stream_data['machine_id'] not in user_devices - } + elif stream_data['media_type'] == 'movie' or stream_data['media_type'] == 'episode': + progress_percent = helpers.get_percent(stream_data['view_offset'], stream_data['duration']) + + if notify_action == 'on_stop': + return plexpy.CONFIG.NOTIFY_CONSECUTIVE or progress_percent < plexpy.CONFIG.NOTIFY_WATCHED_PERCENT + + elif notify_action == 'on_resume': + return plexpy.CONFIG.NOTIFY_CONSECUTIVE or progress_percent < 99 - return conditions.get(notify_action, True) + # All other activity notify actions + else: + return True - elif (stream_data['media_type'] == 'track' and plexpy.CONFIG.MUSIC_NOTIFY_ENABLE): + elif stream_data['media_type'] == 'track': return True + else: return False + + # Recently Added notifications elif timeline_data: + + # Check if notifications enabled for library library_data = libraries.Libraries() library_details = library_data.get_details(section_id=timeline_data['section_id']) @@ -171,6 +178,8 @@ def notify_conditions(notifier=None, notify_action=None, stream_data=None, timel return False return True + + # Server notifications else: return True diff --git a/plexpy/webserve.py b/plexpy/webserve.py index 5cd3379f..a6028af8 100644 --- a/plexpy/webserve.py +++ b/plexpy/webserve.py @@ -2584,9 +2584,6 @@ class WebInterface(object): "grouping_global_history": checked(plexpy.CONFIG.GROUPING_GLOBAL_HISTORY), "grouping_user_history": checked(plexpy.CONFIG.GROUPING_USER_HISTORY), "grouping_charts": checked(plexpy.CONFIG.GROUPING_CHARTS), - "movie_notify_enable": checked(plexpy.CONFIG.MOVIE_NOTIFY_ENABLE), - "tv_notify_enable": checked(plexpy.CONFIG.TV_NOTIFY_ENABLE), - "music_notify_enable": checked(plexpy.CONFIG.MUSIC_NOTIFY_ENABLE), "monitor_pms_updates": checked(plexpy.CONFIG.MONITOR_PMS_UPDATES), "monitor_remote_access": checked(plexpy.CONFIG.MONITOR_REMOTE_ACCESS), "monitoring_interval": plexpy.CONFIG.MONITORING_INTERVAL, @@ -2601,7 +2598,6 @@ class WebInterface(object): "pms_is_remote": checked(plexpy.CONFIG.PMS_IS_REMOTE), "notify_consecutive": checked(plexpy.CONFIG.NOTIFY_CONSECUTIVE), "notify_upload_posters": checked(plexpy.CONFIG.NOTIFY_UPLOAD_POSTERS), - "notify_recently_added": checked(plexpy.CONFIG.NOTIFY_RECENTLY_ADDED), "notify_recently_added_upgrade": checked(plexpy.CONFIG.NOTIFY_RECENTLY_ADDED_UPGRADE), "notify_group_recently_added_grandparent": checked(plexpy.CONFIG.NOTIFY_GROUP_RECENTLY_ADDED_GRANDPARENT), "notify_group_recently_added_parent": checked(plexpy.CONFIG.NOTIFY_GROUP_RECENTLY_ADDED_PARENT), @@ -2639,10 +2635,9 @@ class WebInterface(object): "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", - "movie_notify_enable", "tv_notify_enable", "music_notify_enable", "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", "notify_recently_added_upgrade", + "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", "allow_guest_access", "cache_images", "http_basic_auth", "notify_concurrent_by_ip",