mirror of
https://github.com/rembo10/headphones.git
synced 2026-05-16 08:35:32 +01:00
@@ -1104,6 +1104,39 @@
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<h3>Email</h3>
|
||||
<div class="row checkbox">
|
||||
<input type="checkbox" name="email_enabled" id="email" value="1" ${config['email_enabled']} /><label>Enable Email Notifications</label>
|
||||
</div>
|
||||
<div id="email_options">
|
||||
<div class="row">
|
||||
<label>From</label><input type="text" name="email_from" value="${config['email_from']}" size="254">
|
||||
</div>
|
||||
<div class="row">
|
||||
<label>To</label><input type="text" name="email_to" value="${config['email_to']}" size="254">
|
||||
</div>
|
||||
<div class="row">
|
||||
<label>SMTP Server</label><input type="text" name="email_smtp_server" value="${config['email_smtp_server']}" size="254">
|
||||
</div>
|
||||
<div class="row">
|
||||
<label>SMTP User</label><input type="text" name="email_smtp_user" value="${config['email_smtp_user']}" size="254">
|
||||
</div>
|
||||
<div class="row">
|
||||
<label>SMTP Password</label><input type="password" name="email_smtp_password" value="${config['email_smtp_password']}" size="50">
|
||||
</div>
|
||||
<div class="row checkbox">
|
||||
<input type="text" class="override-float" name="email_smtp_port" value="${config['email_smtp_port']}" size="4"><label>SMTP Port</label>
|
||||
</div>
|
||||
<div class="row checkbox">
|
||||
<input type="checkbox" name="email_tls" value="1" ${config['email_tls']} /><label>TLS</label>
|
||||
</div>
|
||||
<div class="row checkbox">
|
||||
<input type="checkbox" name="email_onsnatch" value="1" ${config['email_onsnatch']} /><label>Notify on snatch?</label>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -1866,6 +1899,26 @@
|
||||
}
|
||||
});
|
||||
|
||||
if ($("#email").is(":checked"))
|
||||
{
|
||||
$("#email_options").show();
|
||||
}
|
||||
else
|
||||
{
|
||||
$("#email_options").hide();
|
||||
}
|
||||
|
||||
$("#email").click(function(){
|
||||
if ($("#email").is(":checked"))
|
||||
{
|
||||
$("#email_options").slideDown();
|
||||
}
|
||||
else
|
||||
{
|
||||
$("#email_options").slideUp();
|
||||
}
|
||||
});
|
||||
|
||||
if ($("#songkick").is(":checked"))
|
||||
{
|
||||
$("#songkickoptions").show();
|
||||
|
||||
@@ -54,6 +54,15 @@ _CONFIG_DEFINITIONS = {
|
||||
'DOWNLOAD_SCAN_INTERVAL': (int, 'General', 5),
|
||||
'DOWNLOAD_TORRENT_DIR': (str, 'General', ''),
|
||||
'DO_NOT_OVERRIDE_GIT_BRANCH': (int, 'General', 0),
|
||||
'EMAIL_ENABLED': (int, 'Email', 0),
|
||||
'EMAIL_FROM': (str, 'Email', ''),
|
||||
'EMAIL_TO': (str, 'Email', ''),
|
||||
'EMAIL_SMTP_SERVER': (str, 'Email', ''),
|
||||
'EMAIL_SMTP_USER': (str, 'Email', ''),
|
||||
'EMAIL_SMTP_PASSWORD': (str, 'Email', ''),
|
||||
'EMAIL_SMTP_PORT': (int, 'Email', 25),
|
||||
'EMAIL_TLS': (int, 'Email', 0),
|
||||
'EMAIL_ONSNATCH': (int, 'Email', 0),
|
||||
'EMBED_ALBUM_ART': (int, 'General', 0),
|
||||
'EMBED_LYRICS': (int, 'General', 0),
|
||||
'ENABLE_HTTPS': (int, 'General', 0),
|
||||
|
||||
@@ -34,6 +34,11 @@ import json
|
||||
import oauth2 as oauth
|
||||
import pythontwitter as twitter
|
||||
|
||||
from email.mime.text import MIMEText
|
||||
import smtplib
|
||||
import email.utils
|
||||
|
||||
|
||||
class GROWL(object):
|
||||
"""
|
||||
Growl notifications, for OS X.
|
||||
@@ -827,3 +832,31 @@ class SubSonicNotifier(object):
|
||||
# Invoke request
|
||||
request.request_response(self.host + "musicFolderSettings.view?scanNow",
|
||||
auth=(self.username, self.password))
|
||||
|
||||
class Email(object):
|
||||
|
||||
def notify(self, subject, message):
|
||||
|
||||
message = MIMEText(message, 'plain', "utf-8")
|
||||
message['Subject'] = subject
|
||||
message['From'] = email.utils.formataddr(('Headphones', headphones.CONFIG.EMAIL_FROM))
|
||||
message['To'] = headphones.CONFIG.EMAIL_TO
|
||||
|
||||
try:
|
||||
mailserver = smtplib.SMTP(headphones.CONFIG.EMAIL_SMTP_SERVER, headphones.CONFIG.EMAIL_SMTP_PORT)
|
||||
|
||||
if (headphones.CONFIG.EMAIL_TLS):
|
||||
mailserver.starttls()
|
||||
|
||||
mailserver.ehlo()
|
||||
|
||||
if headphones.CONFIG.EMAIL_SMTP_USER:
|
||||
mailserver.login(headphones.CONFIG.EMAIL_SMTP_USER, headphones.CONFIG.EMAIL_SMTP_PASSWORD)
|
||||
|
||||
mailserver.sendmail(headphones.CONFIG.EMAIL_FROM, headphones.CONFIG.EMAIL_TO, message.as_string())
|
||||
mailserver.quit()
|
||||
return True
|
||||
|
||||
except Exception, e:
|
||||
logger.warn('Error sending Email: %s' % e)
|
||||
return False
|
||||
@@ -513,6 +513,12 @@ def doPostProcessing(albumid, albumpath, release, tracks, downloaded_track_list,
|
||||
mpc = notifiers.MPC()
|
||||
mpc.notify()
|
||||
|
||||
if headphones.CONFIG.EMAIL_ENABLED:
|
||||
logger.info(u"Sending Email notification")
|
||||
email = notifiers.Email()
|
||||
subject = release['ArtistName'] + ' - ' + release['AlbumTitle']
|
||||
email.notify(subject, "Download and Postprocessing completed")
|
||||
|
||||
|
||||
def embedAlbumArt(artwork, downloaded_track_list):
|
||||
logger.info('Embedding album art')
|
||||
|
||||
@@ -946,7 +946,12 @@ def send_to_downloader(data, bestqual, album):
|
||||
b2msg = 'From ' + provider + '<br></br>' + name
|
||||
boxcar = notifiers.BOXCAR()
|
||||
boxcar.notify('Headphones snatched: ' + title, b2msg, rgid)
|
||||
|
||||
if headphones.CONFIG.EMAIL_ENABLED and headphones.CONFIG.EMAIL_ONSNATCH:
|
||||
logger.info(u"Sending Email notification")
|
||||
email = notifiers.Email()
|
||||
subject = artist + ' - ' + albumname
|
||||
message = 'Snatched from ' + provider + '. ' + title
|
||||
email.notify(subject, message)
|
||||
|
||||
def verifyresult(title, artistterm, term, lossless):
|
||||
|
||||
|
||||
@@ -1151,7 +1151,16 @@ class WebInterface(object):
|
||||
"cache_sizemb": headphones.CONFIG.CACHE_SIZEMB,
|
||||
"file_permissions": headphones.CONFIG.FILE_PERMISSIONS,
|
||||
"folder_permissions": headphones.CONFIG.FOLDER_PERMISSIONS,
|
||||
"mpc_enabled": checked(headphones.CONFIG.MPC_ENABLED)
|
||||
"mpc_enabled": checked(headphones.CONFIG.MPC_ENABLED),
|
||||
"email_enabled": checked(headphones.CONFIG.EMAIL_ENABLED),
|
||||
"email_from": headphones.CONFIG.EMAIL_FROM,
|
||||
"email_to": headphones.CONFIG.EMAIL_TO,
|
||||
"email_smtp_server": headphones.CONFIG.EMAIL_SMTP_SERVER,
|
||||
"email_smtp_user": headphones.CONFIG.EMAIL_SMTP_USER,
|
||||
"email_smtp_password": headphones.CONFIG.EMAIL_SMTP_PASSWORD,
|
||||
"email_smtp_port": int(headphones.CONFIG.EMAIL_SMTP_PORT),
|
||||
"email_tls": checked(headphones.CONFIG.EMAIL_TLS),
|
||||
"email_onsnatch": checked(headphones.CONFIG.EMAIL_ONSNATCH)
|
||||
}
|
||||
|
||||
# Need to convert EXTRAS to a dictionary we can pass to the config:
|
||||
@@ -1196,7 +1205,7 @@ class WebInterface(object):
|
||||
"nma_enabled", "nma_onsnatch", "pushalot_enabled", "pushalot_onsnatch", "synoindex_enabled", "pushover_enabled",
|
||||
"pushover_onsnatch", "pushbullet_enabled", "pushbullet_onsnatch", "subsonic_enabled", "twitter_enabled", "twitter_onsnatch",
|
||||
"osx_notify_enabled", "osx_notify_onsnatch", "boxcar_enabled", "boxcar_onsnatch", "songkick_enabled", "songkick_filter_enabled",
|
||||
"mpc_enabled"
|
||||
"mpc_enabled", "email_enabled", "email_tls", "email_onsnatch"
|
||||
]
|
||||
for checked_config in checked_configs:
|
||||
if checked_config not in kwargs:
|
||||
|
||||
Reference in New Issue
Block a user