Merge branch 'master' of github.com:CouchPotato/CouchPotato

Conflicts:
	couchpotato/core/plugins/searcher/__init__.py
This commit is contained in:
Ruud
2011-08-19 16:15:51 +02:00
37 changed files with 1183 additions and 81 deletions
+30 -3
View File
@@ -1,20 +1,47 @@
from couchpotato.api import addApiView
from couchpotato.core.event import addEvent
from couchpotato.core.helpers.request import jsonified
from couchpotato.core.logger import CPLog
from couchpotato.core.plugins.base import Plugin
log = CPLog(__name__)
class Notification(Plugin):
default_title = 'CouchPotato'
test_message = 'ZOMG Lazors Pewpewpew!'
listen_to = []
dont_listen_to = []
def __init__(self):
addEvent('notify', self.notify)
addEvent('notify.%s' % self.getName().lower(), self.notify)
def notify(self, message = '', data = {}):
addApiView(self.testNotifyName(), self.test)
def notify(self, message = '', data = {}, type = ''):
pass
def test(self):
success = self.notify(message = self.test_message)
return jsonified({'success': success})
test_type = self.testNotifyName()
log.info('Sending test to %s' % test_type)
success = self.notify(
message = self.test_message,
data = {},
type = test_type
)
#return jsonified({'success': success})
def dontNotify(self, type = ''):
return (not type in self.listen_to and len(self.listen_to) == 0 and type != self.testNotifyName()) \
or type in self.dont_listen_to \
or self.isDisabled()
def testNotifyName(self):
return 'notify.%s.test' % self.getName().lower()
+3 -3
View File
@@ -2,13 +2,13 @@ from couchpotato.api import addApiView
from couchpotato.core.event import addEvent, fireEvent
from couchpotato.core.helpers.request import jsonified
from couchpotato.core.logger import CPLog
from couchpotato.core.plugins.base import Plugin
from couchpotato.core.notifications.base import Notification
import time
log = CPLog(__name__)
class CoreNotifier(Plugin):
class CoreNotifier(Notification):
messages = []
@@ -21,7 +21,7 @@ class CoreNotifier(Plugin):
self.registerStatic(__file__)
def notify(self, message = '', data = {}):
def notify(self, message = '', data = {}, type = None):
self.add(data = {
'message': message,
'raw': data,
+3 -9
View File
@@ -12,19 +12,13 @@ log = CPLog(__name__)
class Growl(Notification):
def __init__(self):
addEvent('notify', self.notify)
addEvent('notify.growl', self.notify)
addApiView('notify.growl.test', self.test)
listen_to = ['movie.downloaded', 'movie.snatched']
def conf(self, attr):
return Env.setting(attr, 'growl')
def notify(self, message = '', data = {}):
if self.isDisabled():
return
def notify(self, message = '', data = {}, type = None):
if self.dontNotify(type): return
hosts = [x.strip() for x in self.conf('host').split(",")]
password = self.conf('password')
@@ -0,0 +1,6 @@
from .main import History
def start():
return History()
config = []
@@ -0,0 +1,33 @@
from couchpotato import get_session
from couchpotato.core.event import addEvent
from couchpotato.core.logger import CPLog
from couchpotato.core.notifications.base import Notification
from couchpotato.core.settings.model import History as Hist
import time
log = CPLog(__name__)
class History(Notification):
listen_to = ['movie.downloaded', 'movie.snatched', 'movie.renaming.']
def __init__(self):
addEvent('notify', self.notify)
addEvent('app.load', self.test)
def notify(self, message = '', data = {}, type = None):
if self.dontNotify(type): return
db = get_session()
history = Hist(
added = int(time.time()),
message = message,
type = type,
release_id = data.get('id', 0)
)
db.add(history)
db.commit()
+6 -9
View File
@@ -1,5 +1,4 @@
from couchpotato.api import addApiView
from couchpotato.core.event import addEvent
from couchpotato.core.helpers.request import getParams, jsonified
from couchpotato.core.logger import CPLog
from couchpotato.core.notifications.base import Notification
@@ -19,11 +18,11 @@ log = CPLog(__name__)
class NMJ(Notification):
def __init__(self):
addEvent('notify', self.notify)
addEvent('notify.nmj', self.notify)
listen_to = ['movie.downloaded', 'movie.snatched']
def __init__(self):
super(NMJ, self).__init__()
addApiView('notify.nmj.test', self.test)
addApiView('notify.nmj.auto_config', self.autoConfig)
def conf(self, attr):
@@ -76,10 +75,8 @@ class NMJ(Notification):
'mount': mount,
})
def notify(self, message = '', data = {}):
if self.isDisabled():
return False
def notify(self, message = '', data = {}, type = None):
if self.dontNotify(type): return
host = self.conf('host')
mount = self.conf('mount')
@@ -16,19 +16,13 @@ class Notifo(Notification):
url = 'https://api.notifo.com/v1/send_notification'
def __init__(self):
addEvent('notify', self.notify)
addEvent('notify.notifo', self.notify)
addApiView('notify.notifo.test', self.test)
listen_to = ['movie.downloaded', 'movie.snatched']
def conf(self, attr):
return Env.setting(attr, 'notifo')
def notify(self, message = '', data = {}):
if self.isDisabled():
return False
def notify(self, message = '', data = {}, type = None):
if self.dontNotify(type): return
try:
data = urllib.urlencode({
+3 -9
View File
@@ -10,16 +10,10 @@ log = CPLog(__name__)
class Plex(Notification):
def __init__(self):
addEvent('notify', self.notify)
addEvent('notify.plex', self.notify)
listen_to = ['movie.downloaded', 'movie.snatched']
addApiView('notify.plex.test', self.test)
def notify(self, message = '', data = {}):
if self.isDisabled():
return
def notify(self, message = '', data = {}, type = None):
if self.dontNotify(type): return
log.info('Sending notification to Plex')
hosts = [x.strip() for x in self.conf('host').split(",")]
+3 -11
View File
@@ -1,5 +1,3 @@
from couchpotato.api import addApiView
from couchpotato.core.event import addEvent
from couchpotato.core.helpers.encoding import toUnicode
from couchpotato.core.logger import CPLog
from couchpotato.core.notifications.base import Notification
@@ -11,16 +9,10 @@ log = CPLog(__name__)
class Prowl(Notification):
def __init__(self):
addEvent('notify', self.notify)
addEvent('notify.prowl', self.notify)
listen_to = ['movie.downloaded', 'movie.snatched']
addApiView('notify.prowl.test', self.test)
def notify(self, message = '', data = {}):
if self.isDisabled():
return
def notify(self, message = '', data = {}, type = None):
if self.dontNotify(type): return
http_handler = HTTPSConnection('api.prowlapp.com')
+3 -11
View File
@@ -1,5 +1,3 @@
from couchpotato.api import addApiView
from couchpotato.core.event import addEvent
from couchpotato.core.logger import CPLog
from couchpotato.core.notifications.base import Notification
import base64
@@ -11,16 +9,10 @@ log = CPLog(__name__)
class XBMC(Notification):
def __init__(self):
addEvent('notify', self.notify)
addEvent('notify.xbmc', self.notify)
listen_to = ['movie.downloaded', 'movie.snatched']
addApiView('notify.xbmc.test', self.test)
def notify(self, message = '', data = {}):
if self.isDisabled():
return
def notify(self, message = '', data = {}, type = None):
if self.dontNotify(type): return
for host in [x.strip() for x in self.conf('host').split(",")]:
self.send({'command': 'ExecBuiltIn', 'parameter': 'Notification(CouchPotato, %s)' % message}, host)