mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-08-20 13:23:24 -07:00
Added basic notification controls.
This commit is contained in:
parent
69c8441c1c
commit
e83c9321d4
5 changed files with 180 additions and 10 deletions
|
@ -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"
|
|
@ -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'),
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
# You should have received a copy of the GNU General Public License
|
||||
# along with PlexPy. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
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.")
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue