@@ -1024,6 +1087,66 @@
}
});
+ if ($("#tv_notify_enable").is(":checked"))
+ {
+ $("#tv_notify_options").show();
+ }
+ else
+ {
+ $("#tv_notify_options").hide();
+ }
+
+ $("#tv_notify_enable").click(function(){
+ if ($("#tv_notify_enable").is(":checked"))
+ {
+ $("#tv_notify_options").slideDown();
+ }
+ else
+ {
+ $("#tv_notify_options").slideUp();
+ }
+ });
+
+ if ($("#movie_notify_enable").is(":checked"))
+ {
+ $("#movie_notify_options").show();
+ }
+ else
+ {
+ $("#movie_notify_options").hide();
+ }
+
+ $("#movie_notify_enable").click(function(){
+ if ($("#movie_notify_enable").is(":checked"))
+ {
+ $("#movie_notify_options").slideDown();
+ }
+ else
+ {
+ $("#movie_notify_options").slideUp();
+ }
+ });
+
+ if ($("#music_notify_enable").is(":checked"))
+ {
+ $("#music_notify_options").show();
+ }
+ else
+ {
+ $("#music_notify_options").hide();
+ }
+
+ $("#music_notify_enable").click(function(){
+ if ($("#music_notify_enable").is(":checked"))
+ {
+ $("#music_notify_options").slideDown();
+ }
+ else
+ {
+ $("#music_notify_options").slideUp();
+ }
+ });
+
initConfigCheckbox("#api_enabled");
initConfigCheckbox("#enable_https");
diff --git a/plexpy/common.py b/plexpy/common.py
index eb701edb..848f5ef9 100644
--- a/plexpy/common.py
+++ b/plexpy/common.py
@@ -29,12 +29,12 @@ from plexpy import version
USER_AGENT = 'PlexPy/-' + version.PLEXPY_VERSION + ' (' + platform.system() + ' ' + platform.release() + ')'
# Notification Types
-NOTIFY_SNATCH = 1
-NOTIFY_DOWNLOAD = 2
+NOTIFY_STARTED = 1
+NOTIFY_STOPPED = 2
-notifyStrings = {}
-notifyStrings[NOTIFY_SNATCH] = "Started Download"
-notifyStrings[NOTIFY_DOWNLOAD] = "Download Finished"
+notify_strings = {}
+notify_strings[NOTIFY_STARTED] = "Playback started"
+notify_strings[NOTIFY_STOPPED] = "Playback stopped"
DEFAULT_USER_THUMB = "interfaces/default/images/gravatar-default-80x80.png"
DEFAULT_POSTER_THUMB = "interfaces/default/images/poster.png"
\ No newline at end of file
diff --git a/plexpy/config.py b/plexpy/config.py
index 68eb2bd7..b04834ba 100644
--- a/plexpy/config.py
+++ b/plexpy/config.py
@@ -72,6 +72,10 @@ _CONFIG_DEFINITIONS = {
'JOURNAL_MODE': (str, 'Advanced', 'wal'),
'LAUNCH_BROWSER': (int, 'General', 1),
'LOG_DIR': (str, 'General', ''),
+ 'MOVIE_NOTIFY_ENABLE': (int, 'Monitoring', 0),
+ 'MOVIE_NOTIFY_ON_START': (int, 'Monitoring', 1),
+ 'MUSIC_NOTIFY_ENABLE': (int, 'Monitoring', 0),
+ 'MUSIC_NOTIFY_ON_START': (int, 'Monitoring', 1),
'NMA_APIKEY': (str, 'NMA', ''),
'NMA_ENABLED': (int, 'NMA', 0),
'NMA_PRIORITY': (int, 'NMA', 0),
@@ -93,6 +97,8 @@ _CONFIG_DEFINITIONS = {
'PUSHOVER_ENABLED': (int, 'Pushover', 0),
'PUSHOVER_KEYS': (str, 'Pushover', ''),
'PUSHOVER_PRIORITY': (int, 'Pushover', 0),
+ 'TV_NOTIFY_ENABLE': (int, 'Monitoring', 0),
+ 'TV_NOTIFY_ON_START': (int, 'Monitoring', 1),
'TWITTER_ENABLED': (int, 'Twitter', 0),
'TWITTER_PASSWORD': (str, 'Twitter', ''),
'TWITTER_PREFIX': (str, 'Twitter', 'Headphones'),
diff --git a/plexpy/monitor.py b/plexpy/monitor.py
index d5f7aac4..c2e36e14 100644
--- a/plexpy/monitor.py
+++ b/plexpy/monitor.py
@@ -13,7 +13,7 @@
# You should have received a copy of the GNU General Public License
# along with PlexPy. If not, see .
-from plexpy import logger, helpers, plexwatch, pmsconnect, notification_handler, config, log_reader
+from plexpy import logger, helpers, plexwatch, pmsconnect, notification_handler, config, log_reader, common
from xml.dom import minidom
from httplib import HTTPSConnection
@@ -50,6 +50,7 @@ def check_active_sessions():
parent_title = session['parent_title']
grandparent_title = session['grandparent_title']
machine_id = session['machine_id']
+ user = session['user']
write_session = monitor_db.write_session_key(session_key, rating_key, media_type)
if write_session == 'insert':
@@ -62,7 +63,10 @@ def check_active_sessions():
item_title = title
logger.info('%s (%s) starting playing %s' % (friendly_name, platform, item_title))
pushmessage = '%s (%s) starting playing %s' % (friendly_name, platform, item_title)
- notification_handler.push_nofitications(pushmessage, 'PlexPy Playback started', 'Playback Started')
+
+ # Push any notifications
+ monitor_notifications = MonitorNotifications(media_type=media_type, user=user)
+ monitor_notifications.notify(pushmessage)
# Try and grab IP address from logs
if plexpy.CONFIG.PMS_LOGS_FOLDER:
@@ -247,3 +251,32 @@ class MonitorProcessing(object):
logger.debug(u"Unable to find IP address on fallback search. Not logging IP address.")
return None
+
+
+class MonitorNotifications(object):
+
+ def __init__(self, media_type, user=None):
+ self.media_type = media_type
+ self.user = user
+ self.tv_notify_enabled = plexpy.CONFIG.TV_NOTIFY_ENABLE
+ self.movie_notify_enabled = plexpy.CONFIG.MOVIE_NOTIFY_ENABLE
+ self.music_notify_enabled = plexpy.CONFIG.MUSIC_NOTIFY_ENABLE
+
+ def notify(self, message=None):
+ if message:
+ if self.media_type == 'movie':
+ if self.movie_notify_enabled:
+ notification_handler.push_nofitications(message, 'PlexPy', common.notify_strings[1])
+ elif self.media_type == 'episode':
+ if self.tv_notify_enabled:
+ notification_handler.push_nofitications(message, 'PlexPy', common.notify_strings[1])
+ elif self.media_type == 'track':
+ if self.music_notify_enabled:
+ notification_handler.push_nofitications(message, 'PlexPy', common.notify_strings[1])
+ elif self.media_type == 'clip':
+ pass
+ else:
+ logger.debug(u"Notify called with unsupported media type.")
+ pass
+ else:
+ logger.debug(u"Notify called without a message.")
diff --git a/plexpy/webserve.py b/plexpy/webserve.py
index 6e095ba3..2e32e819 100644
--- a/plexpy/webserve.py
+++ b/plexpy/webserve.py
@@ -329,7 +329,13 @@ class WebInterface(object):
"time_format": plexpy.CONFIG.TIME_FORMAT,
"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)
+ "grouping_charts": checked(plexpy.CONFIG.GROUPING_CHARTS),
+ "tv_notify_enable": checked(plexpy.CONFIG.TV_NOTIFY_ENABLE),
+ "movie_notify_enable": checked(plexpy.CONFIG.MOVIE_NOTIFY_ENABLE),
+ "music_notify_enable": checked(plexpy.CONFIG.MUSIC_NOTIFY_ENABLE),
+ "tv_notify_on_start": checked(plexpy.CONFIG.TV_NOTIFY_ON_START),
+ "movie_notify_on_start": checked(plexpy.CONFIG.MOVIE_NOTIFY_ON_START),
+ "music_notify_on_start": checked(plexpy.CONFIG.MUSIC_NOTIFY_ON_START)
}
return serve_template(templatename="config.html", title="Settings", config=config)
@@ -345,7 +351,9 @@ class WebInterface(object):
"pushover_enabled", "pushbullet_enabled",
"twitter_enabled", "osx_notify_enabled",
"boxcar_enabled", "email_enabled", "email_tls",
- "grouping_global_history", "grouping_user_history", "grouping_charts", "pms_use_bif"
+ "grouping_global_history", "grouping_user_history", "grouping_charts", "pms_use_bif",
+ "tv_notify_enable", "movie_notify_enable", "music_notify_enable",
+ "tv_notify_on_start", "movie_notify_on_start", "music_notify_on_start"
]
for checked_config in checked_configs:
if checked_config not in kwargs: