2014-03-10 05:18:05 +00:00
|
|
|
# Author: Nic Wolfe <nic@wolfeden.ca>
|
|
|
|
# URL: http://code.google.com/p/sickbeard/
|
|
|
|
#
|
2014-11-12 16:43:14 +00:00
|
|
|
# This file is part of SickGear.
|
2014-03-10 05:18:05 +00:00
|
|
|
#
|
2014-11-12 16:43:14 +00:00
|
|
|
# SickGear is free software: you can redistribute it and/or modify
|
2014-03-10 05:18:05 +00:00
|
|
|
# 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.
|
|
|
|
#
|
2014-11-12 16:43:14 +00:00
|
|
|
# SickGear is distributed in the hope that it will be useful,
|
2014-03-10 05:18:05 +00:00
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2014-07-03 21:25:30 +00:00
|
|
|
# GNU General Public License for more details.
|
2014-03-10 05:18:05 +00:00
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
2014-11-12 16:43:14 +00:00
|
|
|
# along with SickGear. If not, see <http://www.gnu.org/licenses/>.
|
2014-03-10 05:18:05 +00:00
|
|
|
|
2016-02-19 17:38:38 +00:00
|
|
|
import emby
|
2015-02-25 12:33:40 +00:00
|
|
|
import kodi
|
2014-03-10 05:18:05 +00:00
|
|
|
import plex
|
2017-10-17 15:43:28 +00:00
|
|
|
import xbmc
|
2014-03-10 05:18:05 +00:00
|
|
|
import nmj
|
|
|
|
import nmjv2
|
|
|
|
import synoindex
|
|
|
|
import synologynotifier
|
|
|
|
import pytivo
|
|
|
|
|
2017-10-17 15:43:28 +00:00
|
|
|
import boxcar2
|
|
|
|
# import pushalot
|
|
|
|
import pushbullet
|
|
|
|
import pushover
|
2014-03-10 05:18:05 +00:00
|
|
|
import growl
|
|
|
|
import prowl
|
|
|
|
import nma
|
2017-10-17 15:43:28 +00:00
|
|
|
from . import libnotify
|
2014-03-10 05:18:05 +00:00
|
|
|
|
2017-10-17 15:43:28 +00:00
|
|
|
from lib import libtrakt
|
|
|
|
import trakt
|
2017-09-14 03:39:54 +00:00
|
|
|
import slack
|
2017-10-17 15:43:28 +00:00
|
|
|
import discordapp
|
|
|
|
import gitter
|
2014-03-10 05:18:05 +00:00
|
|
|
import tweet
|
|
|
|
import emailnotify
|
|
|
|
|
2017-10-17 15:43:28 +00:00
|
|
|
import sickbeard
|
|
|
|
|
|
|
|
|
|
|
|
class NotifierFactory(object):
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
self.notifiers = dict(
|
|
|
|
# home theater / nas
|
|
|
|
EMBY=emby.EmbyNotifier,
|
|
|
|
KODI=kodi.KodiNotifier,
|
|
|
|
PLEX=plex.PLEXNotifier,
|
|
|
|
# ### XBMC=xbmc.XBMCNotifier,
|
|
|
|
NMJ=nmj.NMJNotifier,
|
|
|
|
NMJV2=nmjv2.NMJv2Notifier,
|
|
|
|
SYNOINDEX=synoindex.SynoIndexNotifier,
|
|
|
|
SYNOLOGY=synologynotifier.SynologyNotifier,
|
|
|
|
PYTIVO=pytivo.PyTivoNotifier,
|
|
|
|
|
|
|
|
# devices,
|
|
|
|
BOXCAR2=boxcar2.Boxcar2Notifier,
|
|
|
|
# PUSHALOT=pushalot.PushalotNotifier,
|
|
|
|
PUSHBULLET=pushbullet.PushbulletNotifier,
|
|
|
|
PUSHOVER=pushover.PushoverNotifier,
|
|
|
|
GROWL=growl.GrowlNotifier,
|
|
|
|
PROWL=prowl.ProwlNotifier,
|
|
|
|
NMA=nma.NMANotifier,
|
|
|
|
LIBNOTIFY=libnotify.LibnotifyNotifier,
|
|
|
|
|
|
|
|
# social
|
|
|
|
TRAKT=trakt.TraktNotifier,
|
|
|
|
SLACK=slack.SlackNotifier,
|
|
|
|
DISCORDAPP=discordapp.DiscordappNotifier,
|
|
|
|
GITTER=gitter.GitterNotifier,
|
|
|
|
TWITTER=tweet.TwitterNotifier,
|
|
|
|
EMAIL=emailnotify.EmailNotifier,
|
|
|
|
)
|
|
|
|
|
|
|
|
@property
|
|
|
|
def enabled(self):
|
|
|
|
"""
|
|
|
|
Generator to yield iterable IDs for enabled notifiers
|
|
|
|
:return: ID String
|
|
|
|
:rtype: String
|
|
|
|
"""
|
|
|
|
for n in filter(lambda v: v.is_enabled(), self.notifiers.values()):
|
|
|
|
yield n.id()
|
|
|
|
|
|
|
|
@property
|
|
|
|
def enabled_onsnatch(self):
|
|
|
|
for n in filter(lambda v: v.is_enabled() and v.is_enabled_onsnatch(), self.notifiers.values()):
|
|
|
|
yield n.id()
|
|
|
|
|
|
|
|
@property
|
|
|
|
def enabled_ondownload(self):
|
|
|
|
for n in filter(lambda v: v.is_enabled() and v.is_enabled_ondownload(), self.notifiers.values()):
|
|
|
|
yield n.id()
|
|
|
|
|
|
|
|
@property
|
|
|
|
def enabled_onsubtitledownload(self):
|
|
|
|
for n in filter(lambda v: v.is_enabled() and v.is_enabled_onsubtitledownload(), self.notifiers.values()):
|
|
|
|
yield n.id()
|
|
|
|
|
|
|
|
@property
|
|
|
|
def enabled_library(self):
|
|
|
|
for n in filter(lambda v: v.is_enabled() and v.is_enabled_library(), self.notifiers.values()):
|
|
|
|
yield n.id()
|
|
|
|
|
|
|
|
def get(self, nid):
|
|
|
|
"""
|
|
|
|
Get a notifier instance
|
|
|
|
:param nid: Notified ID
|
|
|
|
:type nid: String
|
|
|
|
:return: Notifier instance
|
|
|
|
:rtype: Notifier
|
|
|
|
"""
|
|
|
|
return self.notifiers[nid]()
|
|
|
|
|
|
|
|
def get_enabled(self, kind=None):
|
|
|
|
"""
|
|
|
|
Generator to yield iterable notifier instance(s) that are either enabled or enabled for requested actions
|
|
|
|
:param kind: Action
|
|
|
|
:type kind: String
|
|
|
|
:return: Notifier instance
|
|
|
|
:rtype: Notifier
|
|
|
|
"""
|
|
|
|
for n in getattr(self, 'enabled' + ('' if None is kind else ('_' + kind))):
|
|
|
|
yield self.get(n)
|
|
|
|
|
|
|
|
|
|
|
|
def notify_snatch(ep_name):
|
|
|
|
for n in NotifierFactory().get_enabled('onsnatch'):
|
|
|
|
n.notify_snatch(ep_name)
|
2014-03-10 05:18:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
def notify_download(ep_name):
|
2017-10-17 15:43:28 +00:00
|
|
|
for n in NotifierFactory().get_enabled('ondownload'):
|
2014-03-10 05:18:05 +00:00
|
|
|
n.notify_download(ep_name)
|
|
|
|
|
2014-03-25 05:57:24 +00:00
|
|
|
|
2014-03-10 05:18:05 +00:00
|
|
|
def notify_subtitle_download(ep_name, lang):
|
2017-12-02 19:44:51 +00:00
|
|
|
for n in NotifierFactory().get_enabled('onsubtitledownload'):
|
2014-03-10 05:18:05 +00:00
|
|
|
n.notify_subtitle_download(ep_name, lang)
|
|
|
|
|
2014-03-25 05:57:24 +00:00
|
|
|
|
2017-10-17 15:43:28 +00:00
|
|
|
def notify_git_update(new_version=''):
|
|
|
|
if sickbeard.NOTIFY_ON_UPDATE:
|
|
|
|
for n in NotifierFactory().get_enabled():
|
|
|
|
n.notify_git_update(new_version)
|
2014-07-03 21:25:30 +00:00
|
|
|
|
|
|
|
|
2017-10-17 15:43:28 +00:00
|
|
|
def notify_update_library(ep_obj):
|
|
|
|
for n in NotifierFactory().get_enabled('library'):
|
|
|
|
n.update_library(show=ep_obj.show, show_name=ep_obj.show.name, ep_obj=ep_obj)
|