Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Issue 2035: Add email notifier with per show notification lists #428

Open
wants to merge 1 commit into from

4 participants

Derek Battams xombiemp thezoggy Nyghto
Derek Battams

This patch provides email notifications, with support for TLS and SMTP AUTH. It provides the regular notifications on snatch and download. It provides the ability to give a list of "global" emails, which receive notifications for all shows and it also allows configuration of email notification lists on a per show basis. This addresses Google Code issue 2035. Screenshot attached to that issue.

Tested using Gmail's SMTP server (TLS + SMTP AUTH) and my ISP's SMTP server (no TLS, no AUTH). Both worked as expected.

Tested on my (relatively old) Linux VM (Ubuntu) using python 2.6.5 and Cheetah 2.0.1. Also tested on WinXP using python 2.7.3 and Cheetah 2.4.4.

Changes are pretty standard except I added a new column to the tv_shows table, which stores the list of email addresses configured for each show.

xombiemp

I just tested this with my gmail account and it works great! Please merge this!

thezoggy

new code needs to be based off the development branch, not master

Derek Battams
Nyghto

Is email notification going to be implemented? really needing this:)

xombiemp xombiemp referenced this pull request
Open

Email Notifications #569

xombiemp

I created a new pull request for this against the development branch. #569

Nyghto

Much thanks, looking forward to it. couch potato also finally has email notification.

thezoggy

why not just use sab's email notification ability?

xombiemp

I don't use sab. I use rutorrent.

Nyghto

i am using sabs mail notifications, but things are changing.. So want couch (it is possible with couch) and sickbeard only send mail upon complete download.

Jean-Michel GARCIA jmichelgarcia referenced this pull request in xombiemp/Sick-Beard
Closed

Email Notifications #1

bricky bricky referenced this pull request from a commit
xombiemp xombiemp Email Notifications
"This patch provides email notifications, with support for TLS and SMTP
AUTH. It provides the regular notifications on snatch and download. It
provides the ability to give a list of "global" emails, which receive
notifications for all shows and it also allows configuration of email
notification lists on a per show basis."

This is Sluggers pull request from
#428

I made the changes in the Development branch and changed a few things
to get it to work with the current version of SickBeard.  I've tested
it and it seems to be working great.
ee34671
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 4, 2012
  1. Derek Battams
This page is out of date. Refresh to see the latest.
BIN  data/images/notifiers/email.jpg
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
123 data/interfaces/default/config_notifications.tmpl
View
@@ -730,6 +730,129 @@
<h1>Online</h1>
<br />
+ <div class="component-group clearfix">
+ <div class="component-group-desc">
+ <h3><img src="$sbRoot/images/notifiers/email.jpg" title="Email" width="16" height="11" />Email</h3>
+ <p>Allows configuration of email notifications on a per show basis.</p>
+ </div>
+ <fieldset class="component-group-list">
+ <div class="field-pair">
+ <input type="checkbox" class="enabler" name="use_email" id="use_email" #if $sickbeard.USE_EMAIL then "checked=\"checked\"" else ""# />
+ <label class="clearfix" for="use_email">
+ <span class="component-title">Enable</span>
+ <span class="component-desc">Should Sick Beard send email notifications?</span>
+ </label>
+ </div>
+
+ <div id="content_use_email">
+ <div class="field-pair">
+ <input type="checkbox" name="email_notify_onsnatch" id="email_notify_onsnatch" #if $sickbeard.EMAIL_NOTIFY_ONSNATCH then "checked=\"checked\"" else ""# />
+ <label class="clearfix" for="email_notify_onsnatch">
+ <span class="component-title">Notify on Snatch</span>
+ <span class="component-desc">Send notification when we start a download?</span>
+ </label>
+ </div>
+ <div class="field-pair">
+ <input type="checkbox" name="email_notify_ondownload" id="email_notify_ondownload" #if $sickbeard.EMAIL_NOTIFY_ONDOWNLOAD then "checked=\"checked\"" else ""# />
+ <label class="clearfix" for="email_notify_ondownload">
+ <span class="component-title">Notify on Download</span>
+ <span class="component-desc">Send notification when we finish a download?</span>
+ </label>
+ </div>
+ <div class="field-pair">
+ <label class="nocheck clearfix">
+ <span class="component-title">SMTP Host</span>
+ <input type="text" name="email_host" id="email_host" value="$sickbeard.EMAIL_HOST" size="35" />
+ </label>
+ <label class="nocheck clearfix">
+ <span class="component-title">&nbsp;</span>
+ <span class="component-desc">Hostname of your SMTP email server.</span>
+ </label>
+ </div>
+ <div class="field-pair">
+ <label class="nocheck clearfix">
+ <span class="component-title">SMTP Port</span>
+ <input type="text" name="email_port" id="email_port" value="$sickbeard.EMAIL_PORT" size="35" />
+ </label>
+ <label class="nocheck clearfix">
+ <span class="component-title">&nbsp;</span>
+ <span class="component-desc">The port number used to connect to your SMTP host.</span>
+ </label>
+ </div>
+ <div class="field-pair">
+ <label class="nocheck clearfix">
+ <span class="component-title">SMTP From</span>
+ <input type="text" name="email_from" id="email_from" value="$sickbeard.EMAIL_FROM" size="35" />
+ </label>
+ <label class="nocheck clearfix">
+ <span class="component-title">&nbsp;</span>
+ <span class="component-desc">Sender email address; some hosts require a real address.</span>
+ </label>
+ </div>
+ <div class="field-pair">
+ <label class="nocheck clearfix">
+ <span class="component-title">Use TLS</span>
+ <input type="checkbox" name="email_tls" id="email_tls" #if $sickbeard.EMAIL_TLS then "checked=\"checked\"" else ""# size="35" />
+ </label>
+ <label class="nocheck clearfix">
+ <span class="component-title">&nbsp;</span>
+ <span class="component-desc">Check to use TLS encryption.</span>
+ </label>
+ </div>
+ <div class="field-pair">
+ <label class="nocheck clearfix">
+ <span class="component-title">SMTP User</span>
+ <input type="text" name="email_user" id="email_user" value="$sickbeard.EMAIL_USER" size="35" />
+ </label>
+ <label class="nocheck clearfix">
+ <span class="component-title">&nbsp;</span>
+ <span class="component-desc">(Optional) Your SMTP server username.</span>
+ </label>
+ </div>
+ <div class="field-pair">
+ <label class="nocheck clearfix">
+ <span class="component-title">SMTP Password</span>
+ <input type="password" name="email_password" id="email_password" value="$sickbeard.EMAIL_PASSWORD" size="35" />
+ </label>
+ <label class="nocheck clearfix">
+ <span class="component-title">&nbsp;</span>
+ <span class="component-desc">(Optional) Your SMTP server password.</span>
+ </label>
+ </div>
+ <div class="field-pair">
+ <label class="nocheck clearfix">
+ <span class="component-title">Global Email List</span>
+ <input type="text" name="email_list" id="email_list" value="$sickbeard.EMAIL_LIST" size="35" />
+ </label>
+ <label class="nocheck clearfix">
+ <span class="component-title">&nbsp;</span>
+ <span class="component-desc">All emails here receive notifications for ALL shows.</span>
+ </label>
+ </div>
+ <div class="field-pair">
+ <label class="nocheck clearfix">
+ <span class="component-title">Show Notification Lists</span>
+ <select name="email_show" id="email_show">
+ <option value="-1">-- Select a Show --</option>
+ </select>
+ </label>
+ <label class="nocheck clearfix">
+ <span class="component-title">&nbsp;</span>
+ <input style="margin-top: 3px;" type="text" name="email_show_list" id="email_show_list" size="35" />
+ </label>
+
+ <label class="nocheck clearfix">
+ <span class="component-title">&nbsp;</span>
+ <span class="component-desc">Configure per show notifications here.</span>
+ </label>
+ </div>
+
+ <div class="testNotification" id="testEmail-result">Click below to test.</div>
+ <input type="button" value="Test Email" id="testEmail" />
+ <input type="submit" class="config_submitter" value="Save Changes" />
+ </div><!-- /content_use_email //-->
+ </fieldset>
+ </div>
<div class="component-group clearfix">
<div class="component-group-desc">
3  data/js/config.js
View
@@ -45,4 +45,5 @@ function config_success(){
$(this).next().remove();
$(this).show();
});
-}
+ $('#email_show').trigger('notify');
+}
65 data/js/configNotifications.js
View
@@ -1,5 +1,6 @@
$(document).ready(function(){
var loading = '<img src="'+sbRoot+'/images/loading16.gif" height="16" width="16" />';
+ var notify_data = null;
$('#testGrowl').click(function(){
$('#testGrowl-result').html(loading);
@@ -64,7 +65,41 @@ $(document).ready(function(){
$.get(sbRoot+"/home/testLibnotify",
function(message){ $('#testLibnotify-result').html(message); });
});
-
+
+ $('#testEmail').click(function(){
+ var status = $('#testEmail-result');
+ status.html(loading);
+ var host = $("#email_host").val();
+ host = host.length > 0 ? host : null;
+ var port = $("#email_port").val();
+ port = port.length > 0 ? port : null;
+ var tls = $("#email_tls").attr('checked') != undefined ? 1 : 0;
+ var from = $("#email_from").val();
+ from = from.length > 0 ? from : 'root@localhost';
+ var user = $("#email_user").val().trim();
+ var pwd = $("#email_password").val();
+
+ var err = '';
+ if(host == null)
+ err += '<li style="color: red;">You must specify an SMTP hostname!</li>';
+ if(port == null)
+ err += '<li style="color: red;">You must specify an SMTP port!</li>';
+ else if(port.match(/^\d+$/) == null || parseInt(port) > 65535)
+ err += '<li style="color: red;">SMTP port must be between 0 and 65535!</li>';
+ if(err.length > 0) {
+ err = '<ol>' + err + '</ol>';
+ status.html(err);
+ } else {
+ var to = prompt('Enter an email address to send the test to:', null);
+ if(to == null || to.length == 0 || to.match(/.*@.*/) == null)
+ status.html('<p style="color: red;">You must provide a recipient email address!</p>');
+ else {
+ $.get(sbRoot+"/home/testEmail", {host: host, port: port, smtp_from: from, use_tls: tls, user: user, pwd: pwd, to: to},
+ function(msg){ $('#testEmail-result').html(msg); });
+ }
+ }
+ });
+
$('#twitterStep1').click(function(){
$('#testTwitter-result').html(loading);
var twitter1_result = $.get(sbRoot+"/home/twitterStep1", function (data){window.open(data)})
@@ -142,4 +177,32 @@ $(document).ready(function(){
var nma_result = $.get(sbRoot+"/home/testNMA", {'nma_api': nma_api, 'nma_priority': nma_priority},
function (data){ $('#testNMA-result').html(data); });
});
+
+ $('#email_show').change(function(){
+ var key = parseInt($('#email_show').val());
+ $('#email_show_list').val(key >= 0 ? notify_data[key.toString()].list : '');
+ });
+
+ // Update the internal data struct anytime settings are saved to the server
+ $('#email_show').bind('notify', function(){ load_show_notify_lists(); });
+
+ function load_show_notify_lists() {
+ $.get(sbRoot+"/home/loadShowNotifyLists", function(data) {
+ var list = $.parseJSON(data);
+ notify_data = list;
+ if(list['_size'] == 0)
+ return;
+ var html = '<option value="-1">-- Select --</option>';
+ for(var s in list) {
+ if(s.charAt(0) == '_')
+ continue;
+ html += '<option value="' + list[s].id + '">' + $('<div/>').text(list[s].name).html() + '</option>';
+ }
+ $('#email_show').html(html);
+ $('#email_show_list').val('');
+ });
+ }
+ // Load the per show notify lists everytime this page is loaded
+ load_show_notify_lists();
});
+
35 sickbeard/__init__.py
View
@@ -227,6 +227,17 @@
PROWL_API = None
PROWL_PRIORITY = 0
+USE_EMAIL = False
+EMAIL_NOTIFY_ONSNATCH = False
+EMAIL_NOTIFY_ONDOWNLOAD = False
+EMAIL_HOST = None
+EMAIL_PORT = 25
+EMAIL_TLS = False
+EMAIL_USER = None
+EMAIL_PASSWORD = None
+EMAIL_FROM = None
+EMAIL_LIST = None
+
USE_TWITTER = False
TWITTER_NOTIFY_ONSNATCH = False
TWITTER_NOTIFY_ONDOWNLOAD = False
@@ -406,6 +417,7 @@ def initialize(consoleLogging=True):
RENAME_EPISODES, properFinderScheduler, PROVIDER_ORDER, autoPostProcesserScheduler, \
NAMING_EP_NAME, NAMING_SEP_TYPE, NAMING_USE_PERIODS, WOMBLE, \
NZBSRUS, NZBSRUS_UID, NZBSRUS_HASH, NAMING_QUALITY, providerList, newznabProviderList, \
+ USE_EMAIL, EMAIL_HOST, EMAIL_PORT, EMAIL_TLS, EMAIL_USER, EMAIL_PASSWORD, EMAIL_FROM, EMAIL_NOTIFY_ONSNATCH, EMAIL_NOTIFY_ONDOWNLOAD, EMAIL_LIST, \
NAMING_DATES, EXTRA_SCRIPTS, USE_TWITTER, TWITTER_USERNAME, TWITTER_PASSWORD, TWITTER_PREFIX, \
USE_NOTIFO, NOTIFO_USERNAME, NOTIFO_APISECRET, NOTIFO_NOTIFY_ONDOWNLOAD, NOTIFO_NOTIFY_ONSNATCH, \
USE_BOXCAR, BOXCAR_USERNAME, BOXCAR_PASSWORD, BOXCAR_NOTIFY_ONDOWNLOAD, BOXCAR_NOTIFY_ONSNATCH, \
@@ -615,6 +627,17 @@ def initialize(consoleLogging=True):
PROWL_API = check_setting_str(CFG, 'Prowl', 'prowl_api', '')
PROWL_PRIORITY = check_setting_str(CFG, 'Prowl', 'prowl_priority', "0")
+ USE_EMAIL = bool(check_setting_int(CFG, 'Email', 'use_email', 0))
+ EMAIL_NOTIFY_ONSNATCH = bool(check_setting_int(CFG, 'Email', 'email_notify_onsnatch', 0))
+ EMAIL_NOTIFY_ONDOWNLOAD = bool(check_setting_int(CFG, 'Email', 'email_notify_ondownload', 0))
+ EMAIL_HOST = check_setting_str(CFG, 'Email', 'email_host', '')
+ EMAIL_PORT = check_setting_int(CFG, 'Email', 'email_port', 25)
+ EMAIL_TLS = bool(check_setting_int(CFG, 'Email', 'email_tls', 0))
+ EMAIL_USER = check_setting_str(CFG, 'Email', 'email_user', '')
+ EMAIL_PASSWORD = check_setting_str(CFG, 'Email', 'email_password', '')
+ EMAIL_FROM = check_setting_str(CFG, 'Email', 'email_from', '')
+ EMAIL_LIST = check_setting_str(CFG, 'Email', 'email_list', '')
+
USE_TWITTER = bool(check_setting_int(CFG, 'Twitter', 'use_twitter', 0))
TWITTER_NOTIFY_ONSNATCH = bool(check_setting_int(CFG, 'Twitter', 'twitter_notify_onsnatch', 0))
TWITTER_NOTIFY_ONDOWNLOAD = bool(check_setting_int(CFG, 'Twitter', 'twitter_notify_ondownload', 0))
@@ -1151,6 +1174,18 @@ def save_config():
new_config['Prowl']['prowl_api'] = PROWL_API
new_config['Prowl']['prowl_priority'] = PROWL_PRIORITY
+ new_config['Email'] = {}
+ new_config['Email']['use_email'] = int(USE_EMAIL)
+ new_config['Email']['email_notify_onsnatch'] = int(EMAIL_NOTIFY_ONSNATCH)
+ new_config['Email']['email_notify_ondownload'] = int(EMAIL_NOTIFY_ONDOWNLOAD)
+ new_config['Email']['email_host'] = EMAIL_HOST
+ new_config['Email']['email_port'] = int(EMAIL_PORT)
+ new_config['Email']['email_tls'] = int(EMAIL_TLS)
+ new_config['Email']['email_user'] = EMAIL_USER
+ new_config['Email']['email_password'] = EMAIL_PASSWORD
+ new_config['Email']['email_from'] = EMAIL_FROM
+ new_config['Email']['email_list'] = EMAIL_LIST
+
new_config['Twitter'] = {}
new_config['Twitter']['use_twitter'] = int(USE_TWITTER)
new_config['Twitter']['twitter_notify_onsnatch'] = int(TWITTER_NOTIFY_ONSNATCH)
9 sickbeard/databases/mainDB.py
View
@@ -398,3 +398,12 @@ def execute(self):
self.connection.action("UPDATE tv_shows SET air_by_date = ? WHERE tvdb_id = ?", [1, cur_show["tvdb_id"]])
self.incDBVersion()
+
+class AddEmailSubscriptionTable(FixAirByDateSetting):
+ def test(self):
+ return self.hasColumn("tv_shows", "notify_list")
+
+ def execute(self):
+ self.addColumn('tv_shows', 'notify_list', 'TEXT', None)
+ self.incDBVersion()
+
3  sickbeard/notifiers/__init__.py
View
@@ -32,6 +32,7 @@
import trakt
import pytivo
import nma
+import emailnotify
from sickbeard.common import *
@@ -49,6 +50,7 @@
trakt_notifier = trakt.TraktNotifier()
pytivo_notifier = pytivo.pyTivoNotifier()
nma_notifier = nma.NMA_Notifier()
+email_notifier = emailnotify.EmailNotifier()
notifiers = [
# Libnotify notifier goes first because it doesn't involve blocking on
@@ -66,6 +68,7 @@
trakt_notifier,
pytivo_notifier,
nma_notifier,
+ email_notifier,
]
def notify_download(ep_name):
133 sickbeard/notifiers/emailnotify.py
View
@@ -0,0 +1,133 @@
+# Author: Derek Battams <derek@battams.ca>
+# URL: http://code.google.com/p/sickbeard/
+#
+# This file is part of Sick Beard.
+#
+# Sick Beard is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Sick Beard is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Sick Beard. If not, see <http://www.gnu.org/licenses/>.
+
+import smtplib
+from email.mime.text import MIMEText
+
+import sickbeard
+
+from sickbeard import logger
+from sickbeard import db
+from sickbeard.exceptions import ex
+from sickbeard import config
+
+class EmailNotifier:
+ def __init__(self):
+ self.last_err = None
+
+ def test_notify(self, host, port, smtp_from, use_tls, user, pwd, to):
+ msg = MIMEText('This is a test message from Sick Beard. If you\'re reading this, the test succeeded!')
+ msg['Subject'] = 'Test Message from Sick Beard'
+ msg['From'] = smtp_from
+ msg['To'] = to
+ return self._sendmail(host, port, smtp_from, use_tls, user, pwd, [to], msg, True)
+
+ def notify_snatch(self, ep_name, title="Snatched:"):
+ """
+ Send a notification that an episode was snatched
+
+ ep_name: The name of the episode that was snatched
+ title: The title of the notification (optional)
+ """
+ if sickbeard.EMAIL_NOTIFY_ONSNATCH:
+ show = self._parseEp(ep_name)
+ to = self._generate_recepients(show)
+ if len(to) == 0:
+ logger.log('Skipping email notify because there are no configured recepients!', logger.WARN)
+ else:
+ msg = MIMEText("'%s' snatched!" % ep_name)
+ msg['Subject'] = 'Sick Beard has snatched a new episode!'
+ msg['From'] = sickbeard.EMAIL_FROM
+ msg['To'] = ','.join(to)
+ if self._sendmail(sickbeard.EMAIL_HOST, sickbeard.EMAIL_PORT, sickbeard.EMAIL_FROM, sickbeard.EMAIL_TLS, sickbeard.EMAIL_USER, sickbeard.EMAIL_PASSWORD, to, msg):
+ logger.log("Snatch notification sent to [%s] for '%s'" % (to, ep_name), logger.DEBUG)
+ else:
+ logger.log("Snatch notification ERROR: %s" % self.last_err, logger.ERROR)
+
+ def notify_download(self, ep_name, title="Completed:"):
+ """
+ Send a notification that an episode was downloaded
+
+ ep_name: The name of the episode that was downloaded
+ title: The title of the notification (optional)
+ """
+ if sickbeard.EMAIL_NOTIFY_ONDOWNLOAD:
+ show = self._parseEp(ep_name)
+ to = self._generate_recepients(show)
+ if len(to) == 0:
+ logger.log('Skipping email notify because there are no configured recepients!', logger.WARN)
+ else:
+ msg = MIMEText("'%s' downloaded!" % ep_name)
+ msg['Subject'] = 'Sick Beard has downloaded a new episode!'
+ msg['From'] = sickbeard.EMAIL_FROM
+ msg['To'] = ','.join(to)
+ if self._sendmail(sickbeard.EMAIL_HOST, sickbeard.EMAIL_PORT, sickbeard.EMAIL_FROM, sickbeard.EMAIL_TLS, sickbeard.EMAIL_USER, sickbeard.EMAIL_PASSWORD, to, msg):
+ logger.log("Download notification sent to [%s] for '%s'" % (to, ep_name), logger.DEBUG)
+ else:
+ logger.log("Download notification ERROR: %s" % self.last_err, logger.ERROR)
+
+ def _generate_recepients(self, show):
+ addrs = []
+
+ # Grab the global recipients
+ for addr in sickbeard.EMAIL_LIST.split(','):
+ if(len(addr.strip()) > 0):
+ addrs.append(addr)
+
+ # Grab the recipients for the show
+ mydb = db.DBConnection()
+ for s in show:
+ for subs in mydb.select("SELECT notify_list FROM tv_shows WHERE show_name = ?", (s,)):
+ for addr in subs['notify_list'].split(','):
+ if(len(addr.strip()) > 0):
+ addrs.append(addr)
+
+ addrs = set(addrs)
+ logger.log('Notification recepients: %s' % addrs, logger.DEBUG)
+ return addrs
+
+ def _sendmail(self, host, port, smtp_from, use_tls, user, pwd, to, msg, smtpDebug=False):
+ logger.log('HOST: %s; PORT: %s; FROM: %s, TLS: %s, USER: %s, PWD: %s, TO: %s' % (host, port, smtp_from, use_tls, user, pwd, to), logger.DEBUG)
+ srv = smtplib.SMTP(host, int(port))
+ if smtpDebug:
+ srv.set_debuglevel(1)
+ try:
+ if (use_tls == '1' or use_tls == True) or (len(user) > 0 and len(pwd) > 0):
+ srv.ehlo()
+ logger.log('Sent initial EHLO command!', logger.DEBUG)
+ if use_tls == '1' or use_tls == True:
+ srv.starttls()
+ logger.log('Sent STARTTLS command!', logger.DEBUG)
+ if len(user) > 0 and len(pwd) > 0:
+ srv.login(user, pwd)
+ logger.log('Sent LOGIN command!', logger.DEBUG)
+ srv.sendmail(smtp_from, to, msg.as_string())
+ srv.quit()
+ return True
+ except Exception as e:
+ self.last_err = '%s' % e
+ return False
+
+ def _parseEp(self, ep_name):
+ sep = config.naming_sep_type[sickbeard.NAMING_SEP_TYPE]
+ titles = ep_name.split(sep)
+ titles.sort(key=len, reverse=True)
+ logger.log("TITLES: %s" % titles, logger.DEBUG)
+ return titles
+
+notifier = EmailNotifier
71 sickbeard/webserve.py
View
@@ -910,6 +910,12 @@ def savePostProcessing(self, season_folders_format=None, naming_show_name=None,
sickbeard.metadata_provider_dict['XBMC'].set_config(xbmc_data)
sickbeard.metadata_provider_dict['MediaBrowser'].set_config(mediabrowser_data)
+
+
+
+
+
+
sickbeard.metadata_provider_dict['Synology'].set_config(synology_data)
sickbeard.metadata_provider_dict['Sony PS3'].set_config(sony_ps3_data)
sickbeard.metadata_provider_dict['WDTV'].set_config(wdtv_data)
@@ -1214,7 +1220,9 @@ def saveNotifications(self, use_xbmc=None, xbmc_notify_onsnatch=None, xbmc_notif
use_trakt=None, trakt_username=None, trakt_password=None, trakt_api=None,
use_pytivo=None, pytivo_notify_onsnatch=None, pytivo_notify_ondownload=None, pytivo_update_library=None,
pytivo_host=None, pytivo_share_name=None, pytivo_tivo_name=None,
- use_nma=None, nma_notify_onsnatch=None, nma_notify_ondownload=None, nma_api=None, nma_priority=0 ):
+ use_nma=None, nma_notify_onsnatch=None, nma_notify_ondownload=None, nma_api=None, nma_priority=0, use_email=None,
+ email_notify_onsnatch=None, email_notify_ondownload=None, email_host=None, email_port=25, email_from=None,
+ email_tls=None, email_user=None, email_password=None, email_list=None, email_show_list=None, email_show=None ):
results = []
@@ -1292,6 +1300,31 @@ def saveNotifications(self, use_xbmc=None, xbmc_notify_onsnatch=None, xbmc_notif
else:
use_prowl = 0
+ if email_notify_onsnatch == "on":
+ email_notify_onsnatch = 1
+ else:
+ email_notify_onsnatch = 0
+
+ if email_notify_ondownload == "on":
+ email_notify_ondownload = 1
+ else:
+ email_notify_ondownload = 0
+
+ if use_email == "on":
+ use_email = 1
+ else:
+ use_email = 0
+
+ if email_tls == "on":
+ email_tls = 1
+ else:
+ email_tls = 0
+
+ # Update per show notifications, if provided
+ if int(email_show) >= 0:
+ mydb = db.DBConnection()
+ mydb.action("UPDATE tv_shows SET notify_list = ? WHERE show_id = ?", (email_show_list, int(email_show)))
+
if twitter_notify_onsnatch == "on":
twitter_notify_onsnatch = 1
else:
@@ -1339,6 +1372,7 @@ def saveNotifications(self, use_xbmc=None, xbmc_notify_onsnatch=None, xbmc_notif
else:
pushover_notify_onsnatch = 0
+
if pushover_notify_ondownload == "on":
pushover_notify_ondownload = 1
else:
@@ -1428,6 +1462,17 @@ def saveNotifications(self, use_xbmc=None, xbmc_notify_onsnatch=None, xbmc_notif
sickbeard.PROWL_API = prowl_api
sickbeard.PROWL_PRIORITY = prowl_priority
+ sickbeard.USE_EMAIL = use_email
+ sickbeard.EMAIL_NOTIFY_ONSNATCH = email_notify_onsnatch
+ sickbeard.EMAIL_NOTIFY_ONDOWNLOAD = email_notify_ondownload
+ sickbeard.EMAIL_HOST = email_host
+ sickbeard.EMAIL_PORT = email_port
+ sickbeard.EMAIL_FROM = email_from
+ sickbeard.EMAIL_TLS = email_tls
+ sickbeard.EMAIL_USER = email_user
+ sickbeard.EMAIL_PASSWORD = email_password
+ sickbeard.EMAIL_LIST = email_list
+
sickbeard.USE_TWITTER = use_twitter
sickbeard.TWITTER_NOTIFY_ONSNATCH = twitter_notify_onsnatch
sickbeard.TWITTER_NOTIFY_ONDOWNLOAD = twitter_notify_ondownload
@@ -1783,6 +1828,7 @@ def finishAddShow():
# blanket policy - if the dir exists you should have used "add existing show" numbnuts
if ek.ek(os.path.isdir, show_dir) and not fullShowPath:
+
ui.notifications.error("Unable to add show", "Folder "+show_dir+" exists already")
redirect('/home/addShows/existingShows')
@@ -2079,6 +2125,29 @@ def testPushover(self, userKey=None):
return "Error sending Pushover notification"
@cherrypy.expose
+ def loadShowNotifyLists(self):
+ cherrypy.response.headers['Cache-Control'] = "max-age=0,no-cache,no-store"
+
+ mydb = db.DBConnection()
+ rows = mydb.select("SELECT show_id, show_name, notify_list FROM tv_shows")
+ data = {}
+ size = 0
+ for r in rows:
+ data[r['show_id']] = {'id': r['show_id'], 'name': r['show_name'], 'list': r['notify_list']}
+ size += 1
+ data['_size'] = size
+ return json.dumps(data)
+
+ @cherrypy.expose
+ def testEmail(self, host=None, port=None, smtp_from=None, use_tls=None, user=None, pwd=None, to=None):
+ cherrypy.response.headers['Cache-Control'] = "max-age=0,no-cache,no-store"
+
+ if notifiers.email_notifier.test_notify(host, port, smtp_from, use_tls, user, pwd, to):
+ return 'Test email sent successfully! Check inbox.'
+ else:
+ return 'ERROR: %s' % notifiers.email_notifier.last_err
+
+ @cherrypy.expose
def twitterStep1(self):
cherrypy.response.headers['Cache-Control'] = "max-age=0,no-cache,no-store"
Something went wrong with that request. Please try again.