From 32cf1ada8beef74fd371642a48a64a9c39cc9e7a Mon Sep 17 00:00:00 2001
From: Jonathan Wong
Date: Tue, 20 Oct 2015 22:39:57 -0700
Subject: [PATCH] Add config settings for on_created
* Note: on_created is recently added
---
.../default/notification_triggers_modal.html | 11 ++++++
data/interfaces/default/settings.html | 26 +++++++++++--
plexpy/config.py | 17 +++++++-
plexpy/notifiers.py | 39 ++++++++++++-------
4 files changed, 76 insertions(+), 17 deletions(-)
diff --git a/data/interfaces/default/notification_triggers_modal.html b/data/interfaces/default/notification_triggers_modal.html
index 666f008d..bbe798fc 100644
--- a/data/interfaces/default/notification_triggers_modal.html
+++ b/data/interfaces/default/notification_triggers_modal.html
@@ -57,6 +57,13 @@ from plexpy import helpers
Trigger notification when a media item triggers the defined buffer threshold.
+
+
+
Trigger notification when a media item is added to the Plex Media Server.
+
@@ -81,6 +88,7 @@ from plexpy import helpers
console.log('success');
}
});
+ $('.toggle-notification-triggers-modal[data-id=' + configToggle + ']').addClass('active');
} else {
var data = {};
data[$(this).data('config-name')] = 0;
@@ -92,6 +100,9 @@ from plexpy import helpers
console.log('success');
}
});
+ if (!($('.toggle-switches').is(":checked"))) {
+ $('.toggle-notification-triggers-modal[data-id=' + configToggle + ']').removeClass('active');
+ }
}
});
diff --git a/data/interfaces/default/settings.html b/data/interfaces/default/settings.html
index 75873d0b..c15be036 100644
--- a/data/interfaces/default/settings.html
+++ b/data/interfaces/default/settings.html
@@ -515,7 +515,7 @@ available_notification_agents = notifiers.available_notification_agents()
here to view usage information.
-
+
+
@@ -635,7 +654,7 @@ available_notification_agents = notifiers.available_notification_agents()
% for agent in available_notification_agents:
-
- % if agent['on_play'] or agent['on_stop'] or agent['on_pause'] or agent['on_resume'] or agent['on_buffer'] or agent['on_watched']:
+ % if agent['on_play'] or agent['on_stop'] or agent['on_pause'] or agent['on_resume'] or agent['on_buffer'] or agent['on_watched'] or agent['on_created']:
% else:
@@ -1292,7 +1311,8 @@ $(document).ready(function() {
}
}
- var accordion = new Accordion($('#accordion'), false);
+ var accordion_session = new Accordion($('#accordion-session'), false);
+ var accordion_timeline = new Accordion($('#accordion-timeline'), false);
var cards = "${config['home_stats_cards']}".split(/[\s,]+/);
cards.forEach(function (item) {
diff --git a/plexpy/config.py b/plexpy/config.py
index b2cca63c..ad6f9445 100644
--- a/plexpy/config.py
+++ b/plexpy/config.py
@@ -44,6 +44,7 @@ _CONFIG_DEFINITIONS = {
'BOXCAR_ON_RESUME': (int, 'Boxcar', 0),
'BOXCAR_ON_BUFFER': (int, 'Boxcar', 0),
'BOXCAR_ON_WATCHED': (int, 'Boxcar', 0),
+ 'BOXCAR_ON_CREATED': (int, 'Boxcar', 0),
'BUFFER_THRESHOLD': (int, 'Monitoring', 3),
'BUFFER_WAIT': (int, 'Monitoring', 900),
'CACHE_DIR': (str, 'General', ''),
@@ -68,6 +69,7 @@ _CONFIG_DEFINITIONS = {
'EMAIL_ON_RESUME': (int, 'Email', 0),
'EMAIL_ON_BUFFER': (int, 'Email', 0),
'EMAIL_ON_WATCHED': (int, 'Email', 0),
+ 'EMAIL_ON_CREATED': (int, 'Email', 0),
'ENABLE_HTTPS': (int, 'General', 0),
'FIRST_RUN_COMPLETE': (int, 'General', 0),
'FREEZE_DB': (int, 'General', 0),
@@ -84,6 +86,7 @@ _CONFIG_DEFINITIONS = {
'GROWL_ON_RESUME': (int, 'Growl', 0),
'GROWL_ON_BUFFER': (int, 'Growl', 0),
'GROWL_ON_WATCHED': (int, 'Growl', 0),
+ 'GROWL_ON_CREATED': (int, 'Growl', 0),
'HOME_LIBRARY_CARDS': (str, 'General', 'library_statistics_first'),
'HOME_STATS_LENGTH': (int, 'General', 30),
'HOME_STATS_TYPE': (int, 'General', 0),
@@ -108,6 +111,7 @@ _CONFIG_DEFINITIONS = {
'IFTTT_ON_RESUME': (int, 'IFTTT', 0),
'IFTTT_ON_BUFFER': (int, 'IFTTT', 0),
'IFTTT_ON_WATCHED': (int, 'IFTTT', 0),
+ 'IFTTT_ON_CREATED': (int, 'IFTTT', 0),
'JOURNAL_MODE': (str, 'Advanced', 'wal'),
'LAUNCH_BROWSER': (int, 'General', 1),
'LOG_DIR': (str, 'General', ''),
@@ -132,6 +136,7 @@ _CONFIG_DEFINITIONS = {
'NMA_ON_RESUME': (int, 'NMA', 0),
'NMA_ON_BUFFER': (int, 'NMA', 0),
'NMA_ON_WATCHED': (int, 'NMA', 0),
+ 'NMA_ON_CREATED': (int, 'NMA', 0),
'NOTIFY_CONSECUTIVE': (int, 'Monitoring', 1),
'NOTIFY_WATCHED_PERCENT': (int, 'Monitoring', 85),
'NOTIFY_ON_START_SUBJECT_TEXT': (str, 'Monitoring', 'PlexPy ({server_name})'),
@@ -146,6 +151,8 @@ _CONFIG_DEFINITIONS = {
'NOTIFY_ON_BUFFER_BODY_TEXT': (str, 'Monitoring', '{user} ({player}) is buffering {title}.'),
'NOTIFY_ON_WATCHED_SUBJECT_TEXT': (str, 'Monitoring', 'PlexPy ({server_name})'),
'NOTIFY_ON_WATCHED_BODY_TEXT': (str, 'Monitoring', '{user} ({player}) has watched {title}.'),
+ 'NOTIFY_ON_CREATED_SUBJECT_TEXT': (str, 'Monitoring', 'PlexPy ({server_name})'),
+ 'NOTIFY_ON_CREATED_BODY_TEXT': (str, 'Monitoring', '{title} was recently added to Plex.'),
'OSX_NOTIFY_APP': (str, 'OSX_Notify', '/Applications/PlexPy'),
'OSX_NOTIFY_ENABLED': (int, 'OSX_Notify', 0),
'OSX_NOTIFY_ON_PLAY': (int, 'OSX_Notify', 0),
@@ -154,6 +161,7 @@ _CONFIG_DEFINITIONS = {
'OSX_NOTIFY_ON_RESUME': (int, 'OSX_Notify', 0),
'OSX_NOTIFY_ON_BUFFER': (int, 'OSX_Notify', 0),
'OSX_NOTIFY_ON_WATCHED': (int, 'OSX_Notify', 0),
+ 'OSX_NOTIFY_ON_CREATED': (int, 'OSX_Notify', 0),
'PLEX_CLIENT_HOST': (str, 'Plex', ''),
'PLEX_ENABLED': (int, 'Plex', 0),
'PLEX_PASSWORD': (str, 'Plex', ''),
@@ -164,6 +172,7 @@ _CONFIG_DEFINITIONS = {
'PLEX_ON_RESUME': (int, 'Plex', 0),
'PLEX_ON_BUFFER': (int, 'Plex', 0),
'PLEX_ON_WATCHED': (int, 'Plex', 0),
+ 'PLEX_ON_CREATED': (int, 'Plex', 0),
'PROWL_ENABLED': (int, 'Prowl', 0),
'PROWL_KEYS': (str, 'Prowl', ''),
'PROWL_PRIORITY': (int, 'Prowl', 0),
@@ -173,6 +182,7 @@ _CONFIG_DEFINITIONS = {
'PROWL_ON_RESUME': (int, 'Prowl', 0),
'PROWL_ON_BUFFER': (int, 'Prowl', 0),
'PROWL_ON_WATCHED': (int, 'Prowl', 0),
+ 'PROWL_ON_CREATED': (int, 'Prowl', 0),
'PUSHALOT_APIKEY': (str, 'Pushalot', ''),
'PUSHALOT_ENABLED': (int, 'Pushalot', 0),
'PUSHALOT_ON_PLAY': (int, 'Pushalot', 0),
@@ -181,6 +191,7 @@ _CONFIG_DEFINITIONS = {
'PUSHALOT_ON_RESUME': (int, 'Pushalot', 0),
'PUSHALOT_ON_BUFFER': (int, 'Pushalot', 0),
'PUSHALOT_ON_WATCHED': (int, 'Pushalot', 0),
+ 'PUSHALOT_ON_CREATED': (int, 'Pushalot', 0),
'PUSHBULLET_APIKEY': (str, 'PushBullet', ''),
'PUSHBULLET_DEVICEID': (str, 'PushBullet', ''),
'PUSHBULLET_CHANNEL_TAG': (str, 'PushBullet', ''),
@@ -191,6 +202,7 @@ _CONFIG_DEFINITIONS = {
'PUSHBULLET_ON_RESUME': (int, 'PushBullet', 0),
'PUSHBULLET_ON_BUFFER': (int, 'PushBullet', 0),
'PUSHBULLET_ON_WATCHED': (int, 'PushBullet', 0),
+ 'PUSHBULLET_ON_CREATED': (int, 'PushBullet', 0),
'PUSHOVER_APITOKEN': (str, 'Pushover', ''),
'PUSHOVER_ENABLED': (int, 'Pushover', 0),
'PUSHOVER_KEYS': (str, 'Pushover', ''),
@@ -202,6 +214,7 @@ _CONFIG_DEFINITIONS = {
'PUSHOVER_ON_RESUME': (int, 'Pushover', 0),
'PUSHOVER_ON_BUFFER': (int, 'Pushover', 0),
'PUSHOVER_ON_WATCHED': (int, 'Pushover', 0),
+ 'PUSHOVER_ON_CREATED': (int, 'Pushover', 0),
'REFRESH_USERS_INTERVAL': (int, 'Monitoring', 12),
'REFRESH_USERS_ON_STARTUP': (int, 'Monitoring', 1),
'TV_NOTIFY_ENABLE': (int, 'Monitoring', 0),
@@ -218,6 +231,7 @@ _CONFIG_DEFINITIONS = {
'TWITTER_ON_RESUME': (int, 'Twitter', 0),
'TWITTER_ON_BUFFER': (int, 'Twitter', 0),
'TWITTER_ON_WATCHED': (int, 'Twitter', 0),
+ 'TWITTER_ON_CREATED': (int, 'Twitter', 0),
'UPDATE_DB_INTERVAL': (int, 'General', 24),
'VERIFY_SSL_CERT': (bool_int, 'Advanced', 1),
'VIDEO_LOGGING_ENABLE': (int, 'Monitoring', 1),
@@ -230,7 +244,8 @@ _CONFIG_DEFINITIONS = {
'XBMC_ON_PAUSE': (int, 'XBMC', 0),
'XBMC_ON_RESUME': (int, 'XBMC', 0),
'XBMC_ON_BUFFER': (int, 'XBMC', 0),
- 'XBMC_ON_WATCHED': (int, 'XBMC', 0)
+ 'XBMC_ON_WATCHED': (int, 'XBMC', 0),
+ 'XBMC_ON_CREATED': (int, 'XBMC', 0)
}
# pylint:disable=R0902
# it might be nice to refactor for fewer instance variables
diff --git a/plexpy/notifiers.py b/plexpy/notifiers.py
index cbbe8401..475ce2bc 100644
--- a/plexpy/notifiers.py
+++ b/plexpy/notifiers.py
@@ -64,7 +64,8 @@ def available_notification_agents():
'on_pause': plexpy.CONFIG.GROWL_ON_PAUSE,
'on_resume': plexpy.CONFIG.GROWL_ON_RESUME,
'on_buffer': plexpy.CONFIG.GROWL_ON_BUFFER,
- 'on_watched': plexpy.CONFIG.GROWL_ON_WATCHED
+ 'on_watched': plexpy.CONFIG.GROWL_ON_WATCHED,
+ 'on_created': plexpy.CONFIG.GROWL_ON_CREATED
},
{'name': 'Prowl',
'id': AGENT_IDS['Prowl'],
@@ -76,7 +77,8 @@ def available_notification_agents():
'on_pause': plexpy.CONFIG.PROWL_ON_PAUSE,
'on_resume': plexpy.CONFIG.PROWL_ON_RESUME,
'on_buffer': plexpy.CONFIG.PROWL_ON_BUFFER,
- 'on_watched': plexpy.CONFIG.PROWL_ON_WATCHED
+ 'on_watched': plexpy.CONFIG.PROWL_ON_WATCHED,
+ 'on_created': plexpy.CONFIG.PROWL_ON_CREATED
},
{'name': 'XBMC',
'id': AGENT_IDS['XBMC'],
@@ -88,7 +90,8 @@ def available_notification_agents():
'on_pause': plexpy.CONFIG.XBMC_ON_PAUSE,
'on_resume': plexpy.CONFIG.XBMC_ON_RESUME,
'on_buffer': plexpy.CONFIG.XBMC_ON_BUFFER,
- 'on_watched': plexpy.CONFIG.XBMC_ON_WATCHED
+ 'on_watched': plexpy.CONFIG.XBMC_ON_WATCHED,
+ 'on_created': plexpy.CONFIG.XBMC_ON_CREATED
},
{'name': 'Plex',
'id': AGENT_IDS['Plex'],
@@ -100,7 +103,8 @@ def available_notification_agents():
'on_pause': plexpy.CONFIG.PLEX_ON_PAUSE,
'on_resume': plexpy.CONFIG.PLEX_ON_RESUME,
'on_buffer': plexpy.CONFIG.PLEX_ON_BUFFER,
- 'on_watched': plexpy.CONFIG.PLEX_ON_WATCHED
+ 'on_watched': plexpy.CONFIG.PLEX_ON_WATCHED,
+ 'on_created': plexpy.CONFIG.PLEX_ON_CREATED
},
{'name': 'NotifyMyAndroid',
'id': AGENT_IDS['NMA'],
@@ -112,7 +116,8 @@ def available_notification_agents():
'on_pause': plexpy.CONFIG.NMA_ON_PAUSE,
'on_resume': plexpy.CONFIG.NMA_ON_RESUME,
'on_buffer': plexpy.CONFIG.NMA_ON_BUFFER,
- 'on_watched': plexpy.CONFIG.NMA_ON_WATCHED
+ 'on_watched': plexpy.CONFIG.NMA_ON_WATCHED,
+ 'on_created': plexpy.CONFIG.NMA_ON_CREATED
},
{'name': 'Pushalot',
'id': AGENT_IDS['Pushalot'],
@@ -124,7 +129,8 @@ def available_notification_agents():
'on_pause': plexpy.CONFIG.PUSHALOT_ON_PAUSE,
'on_resume': plexpy.CONFIG.PUSHALOT_ON_RESUME,
'on_buffer': plexpy.CONFIG.PUSHALOT_ON_BUFFER,
- 'on_watched': plexpy.CONFIG.PUSHALOT_ON_WATCHED
+ 'on_watched': plexpy.CONFIG.PUSHALOT_ON_WATCHED,
+ 'on_created': plexpy.CONFIG.PUSHALOT_ON_CREATED
},
{'name': 'Pushbullet',
'id': AGENT_IDS['Pushbullet'],
@@ -136,7 +142,8 @@ def available_notification_agents():
'on_pause': plexpy.CONFIG.PUSHBULLET_ON_PAUSE,
'on_resume': plexpy.CONFIG.PUSHBULLET_ON_RESUME,
'on_buffer': plexpy.CONFIG.PUSHBULLET_ON_BUFFER,
- 'on_watched': plexpy.CONFIG.PUSHBULLET_ON_WATCHED
+ 'on_watched': plexpy.CONFIG.PUSHBULLET_ON_WATCHED,
+ 'on_created': plexpy.CONFIG.PUSHBULLET_ON_CREATED
},
{'name': 'Pushover',
'id': AGENT_IDS['Pushover'],
@@ -148,7 +155,8 @@ def available_notification_agents():
'on_pause': plexpy.CONFIG.PUSHOVER_ON_PAUSE,
'on_resume': plexpy.CONFIG.PUSHOVER_ON_RESUME,
'on_buffer': plexpy.CONFIG.PUSHOVER_ON_BUFFER,
- 'on_watched': plexpy.CONFIG.PUSHOVER_ON_WATCHED
+ 'on_watched': plexpy.CONFIG.PUSHOVER_ON_WATCHED,
+ 'on_created': plexpy.CONFIG.PUSHOVER_ON_CREATED
},
{'name': 'Boxcar2',
'id': AGENT_IDS['Boxcar2'],
@@ -160,7 +168,8 @@ def available_notification_agents():
'on_pause': plexpy.CONFIG.BOXCAR_ON_PAUSE,
'on_resume': plexpy.CONFIG.BOXCAR_ON_RESUME,
'on_buffer': plexpy.CONFIG.BOXCAR_ON_BUFFER,
- 'on_watched': plexpy.CONFIG.BOXCAR_ON_WATCHED
+ 'on_watched': plexpy.CONFIG.BOXCAR_ON_WATCHED,
+ 'on_created': plexpy.CONFIG.BOXCAR_ON_CREATED
},
{'name': 'E-mail',
'id': AGENT_IDS['Email'],
@@ -172,7 +181,8 @@ def available_notification_agents():
'on_pause': plexpy.CONFIG.EMAIL_ON_PAUSE,
'on_resume': plexpy.CONFIG.EMAIL_ON_RESUME,
'on_buffer': plexpy.CONFIG.EMAIL_ON_BUFFER,
- 'on_watched': plexpy.CONFIG.EMAIL_ON_WATCHED
+ 'on_watched': plexpy.CONFIG.EMAIL_ON_WATCHED,
+ 'on_created': plexpy.CONFIG.EMAIL_ON_CREATED
},
{'name': 'Twitter',
'id': AGENT_IDS['Twitter'],
@@ -184,7 +194,8 @@ def available_notification_agents():
'on_pause': plexpy.CONFIG.TWITTER_ON_PAUSE,
'on_resume': plexpy.CONFIG.TWITTER_ON_RESUME,
'on_buffer': plexpy.CONFIG.TWITTER_ON_BUFFER,
- 'on_watched': plexpy.CONFIG.TWITTER_ON_WATCHED
+ 'on_watched': plexpy.CONFIG.TWITTER_ON_WATCHED,
+ 'on_created': plexpy.CONFIG.TWITTER_ON_CREATED
},
{'name': 'IFTTT',
'id': AGENT_IDS['IFTTT'],
@@ -196,7 +207,8 @@ def available_notification_agents():
'on_pause': plexpy.CONFIG.IFTTT_ON_PAUSE,
'on_resume': plexpy.CONFIG.IFTTT_ON_RESUME,
'on_buffer': plexpy.CONFIG.IFTTT_ON_BUFFER,
- 'on_watched': plexpy.CONFIG.IFTTT_ON_WATCHED
+ 'on_watched': plexpy.CONFIG.IFTTT_ON_WATCHED,
+ 'on_created': plexpy.CONFIG.IFTTT_ON_CREATED
}
]
@@ -213,7 +225,8 @@ def available_notification_agents():
'on_pause': plexpy.CONFIG.OSX_NOTIFY_ON_PAUSE,
'on_resume': plexpy.CONFIG.OSX_NOTIFY_ON_RESUME,
'on_buffer': plexpy.CONFIG.OSX_NOTIFY_ON_BUFFER,
- 'on_watched': plexpy.CONFIG.OSX_NOTIFY_ON_WATCHED
+ 'on_watched': plexpy.CONFIG.OSX_NOTIFY_ON_WATCHED,
+ 'on_created': plexpy.CONFIG.OSX_NOTIFY_ON_CREATED
})
return agents