67 changed files with 438 additions and 86 deletions
@ -0,0 +1,13 @@ |
|||
config = { |
|||
'name': 'download_providers', |
|||
'groups': [ |
|||
{ |
|||
'label': 'Downloaders', |
|||
'description': 'You can select different downloaders for each type (usenet / torrent)', |
|||
'type': 'list', |
|||
'name': 'download_providers', |
|||
'tab': 'downloaders', |
|||
'options': [], |
|||
}, |
|||
], |
|||
} |
@ -0,0 +1,13 @@ |
|||
config = { |
|||
'name': 'notification_providers', |
|||
'groups': [ |
|||
{ |
|||
'label': 'Notifications', |
|||
'description': 'Notify when movies are done or snatched', |
|||
'type': 'list', |
|||
'name': 'notification_providers', |
|||
'tab': 'notifications', |
|||
'options': [], |
|||
}, |
|||
], |
|||
} |
@ -0,0 +1,56 @@ |
|||
from .main import Email |
|||
|
|||
def start(): |
|||
return Email() |
|||
|
|||
config = [{ |
|||
'name': 'email', |
|||
'groups': [ |
|||
{ |
|||
'tab': 'notifications', |
|||
'list': 'notification_providers', |
|||
'name': 'email', |
|||
'options': [ |
|||
{ |
|||
'name': 'enabled', |
|||
'default': 0, |
|||
'type': 'enabler', |
|||
}, |
|||
{ |
|||
'name': 'from', |
|||
'label': 'Send e-mail from', |
|||
}, |
|||
{ |
|||
'name': 'to', |
|||
'label': 'Send e-mail to', |
|||
}, |
|||
{ |
|||
'name': 'smtp_server', |
|||
'label': 'SMTP server', |
|||
}, |
|||
{ |
|||
'name': 'ssl', |
|||
'label': 'Enable SSL', |
|||
'default': 0, |
|||
'type': 'bool', |
|||
}, |
|||
{ |
|||
'name': 'smtp_user', |
|||
'label': 'SMTP user', |
|||
}, |
|||
{ |
|||
'name': 'smtp_pass', |
|||
'label': 'SMTP password', |
|||
'type': 'password', |
|||
}, |
|||
{ |
|||
'name': 'on_snatch', |
|||
'default': 0, |
|||
'type': 'bool', |
|||
'advanced': True, |
|||
'description': 'Also send message when movie is snatched.', |
|||
}, |
|||
], |
|||
} |
|||
], |
|||
}] |
@ -0,0 +1,49 @@ |
|||
from couchpotato.core.helpers.encoding import toUnicode |
|||
from couchpotato.core.logger import CPLog |
|||
from couchpotato.core.notifications.base import Notification |
|||
from email.mime.text import MIMEText |
|||
import smtplib |
|||
import traceback |
|||
|
|||
log = CPLog(__name__) |
|||
|
|||
|
|||
class Email(Notification): |
|||
|
|||
def notify(self, message = '', data = {}, listener = None): |
|||
if self.isDisabled(): return |
|||
|
|||
# Extract all the settings from settings |
|||
from_address = self.conf('from') |
|||
to = self.conf('to') |
|||
smtp_server = self.conf('smtp_server') |
|||
ssl = self.conf('ssl') |
|||
smtp_user = self.conf('smtp_user') |
|||
smtp_pass = self.conf('smtp_pass') |
|||
|
|||
# Make the basic message |
|||
message = MIMEText(toUnicode(message)) |
|||
message['Subject'] = self.default_title |
|||
message['From'] = from_address |
|||
message['To'] = to |
|||
|
|||
try: |
|||
# Open the SMTP connection, via SSL if requested |
|||
mailserver = smtplib.SMTP_SSL(smtp_server) if ssl == 1 else smtplib.SMTP(smtp_server) |
|||
|
|||
# Check too see if an login attempt should be attempted |
|||
if len(smtp_user) > 0: |
|||
mailserver.login(smtp_user, smtp_pass) |
|||
|
|||
# Send the e-mail |
|||
mailserver.sendmail(from_address, to, message.as_string()) |
|||
|
|||
# Close the SMTP connection |
|||
mailserver.quit() |
|||
log.info('Email notifications sent.') |
|||
return True |
|||
except: |
|||
log.error('E-mail failed: %s', traceback.format_exc()) |
|||
return False |
|||
|
|||
return False |
@ -0,0 +1,21 @@ |
|||
config = { |
|||
'name': 'automation_providers', |
|||
'groups': [ |
|||
{ |
|||
'label': 'Watchlists', |
|||
'description': 'Check watchlists for new movies', |
|||
'type': 'list', |
|||
'name': 'watchlist_providers', |
|||
'tab': 'automation', |
|||
'options': [], |
|||
}, |
|||
{ |
|||
'label': 'Automated', |
|||
'description': 'Uses minimal requirements', |
|||
'type': 'list', |
|||
'name': 'automation_providers', |
|||
'tab': 'automation', |
|||
'options': [], |
|||
}, |
|||
], |
|||
} |
@ -0,0 +1,14 @@ |
|||
config = { |
|||
'name': 'nzb_providers', |
|||
'groups': [ |
|||
{ |
|||
'label': 'Usenet', |
|||
'description': 'Providers searching usenet for new releases', |
|||
'type': 'list', |
|||
'name': 'nzb_providers', |
|||
'tab': 'searcher', |
|||
'subtab': 'providers', |
|||
'options': [], |
|||
}, |
|||
], |
|||
} |
@ -0,0 +1,14 @@ |
|||
config = { |
|||
'name': 'torrent_providers', |
|||
'groups': [ |
|||
{ |
|||
'label': 'Torrent', |
|||
'description': 'Providers searching torrent sites for new releases', |
|||
'type': 'list', |
|||
'name': 'torrent_providers', |
|||
'tab': 'searcher', |
|||
'subtab': 'providers', |
|||
'options': [], |
|||
}, |
|||
], |
|||
} |
Loading…
Reference in new issue