Merge branch 'refs/heads/develop' into redesign
This commit is contained in:
@@ -15,6 +15,7 @@ class Notification(Provider):
|
||||
test_message = 'ZOMG Lazors Pewpewpew!'
|
||||
|
||||
listen_to = [
|
||||
'media.available',
|
||||
'renamer.after', 'movie.snatched',
|
||||
'updater.available', 'updater.updated',
|
||||
'core.message.important',
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
import time
|
||||
|
||||
from couchpotato.core.helpers.encoding import toUnicode
|
||||
from couchpotato.core.logger import CPLog
|
||||
from couchpotato.core.notifications.base import Notification
|
||||
|
||||
|
||||
log = CPLog(__name__)
|
||||
|
||||
autoload = 'Boxcar'
|
||||
|
||||
|
||||
class Boxcar(Notification):
|
||||
|
||||
url = 'https://boxcar.io/devices/providers/7MNNXY3UIzVBwvzkKwkC/notifications'
|
||||
|
||||
def notify(self, message = '', data = None, listener = None):
|
||||
if not data: data = {}
|
||||
|
||||
try:
|
||||
message = message.strip()
|
||||
|
||||
data = {
|
||||
'email': self.conf('email'),
|
||||
'notification[from_screen_name]': self.default_title,
|
||||
'notification[message]': toUnicode(message),
|
||||
'notification[from_remote_service_id]': int(time.time()),
|
||||
}
|
||||
|
||||
self.urlopen(self.url, data = data)
|
||||
except:
|
||||
log.error('Check your email and added services on boxcar.io')
|
||||
return False
|
||||
|
||||
log.info('Boxcar notification successful.')
|
||||
return True
|
||||
|
||||
def isEnabled(self):
|
||||
return super(Boxcar, self).isEnabled() and self.conf('email')
|
||||
|
||||
|
||||
config = [{
|
||||
'name': 'boxcar',
|
||||
'groups': [
|
||||
{
|
||||
'tab': 'notifications',
|
||||
'list': 'notification_providers',
|
||||
'name': 'boxcar',
|
||||
'options': [
|
||||
{
|
||||
'name': 'enabled',
|
||||
'default': 0,
|
||||
'type': 'enabler',
|
||||
},
|
||||
{
|
||||
'name': 'email',
|
||||
'description': 'Your Boxcar registration emailaddress.'
|
||||
},
|
||||
{
|
||||
'name': 'on_snatch',
|
||||
'default': 0,
|
||||
'type': 'bool',
|
||||
'advanced': True,
|
||||
'description': 'Also send message when movie is snatched.',
|
||||
},
|
||||
],
|
||||
}
|
||||
],
|
||||
}]
|
||||
@@ -28,6 +28,7 @@ class CoreNotifier(Notification):
|
||||
m_lock = None
|
||||
|
||||
listen_to = [
|
||||
'media.available',
|
||||
'renamer.after', 'movie.snatched',
|
||||
'updater.available', 'updater.updated',
|
||||
'core.message', 'core.message.important',
|
||||
@@ -258,14 +259,14 @@ class CoreNotifier(Notification):
|
||||
|
||||
messages = []
|
||||
|
||||
# Get unread
|
||||
# Get last message
|
||||
if init:
|
||||
db = get_db()
|
||||
|
||||
notifications = db.all('notification_unread', with_doc = True)
|
||||
notifications = db.all('notification', with_doc = True)
|
||||
|
||||
for n in notifications:
|
||||
if n['doc'].get('time') > (time.time() - 259200):
|
||||
if n['doc'].get('time') > (time.time() - 604800):
|
||||
messages.append(n['doc'])
|
||||
|
||||
return {
|
||||
|
||||
@@ -122,9 +122,12 @@ var NotificationBase = new Class({
|
||||
startPoll: function(){
|
||||
var self = this;
|
||||
|
||||
if(self.stopped || (self.request && self.request.isRunning()))
|
||||
if(self.stopped)
|
||||
return;
|
||||
|
||||
if(self.request && self.request.isRunning())
|
||||
self.request.cancel();
|
||||
|
||||
self.request = Api.request('nonblock/notification.listener', {
|
||||
'onSuccess': function(json){
|
||||
self.processData(json, false)
|
||||
@@ -149,7 +152,7 @@ var NotificationBase = new Class({
|
||||
var self = this;
|
||||
|
||||
// Process data
|
||||
if(json){
|
||||
if(json && json.result){
|
||||
Array.each(json.result, function(result){
|
||||
App.trigger(result._t || result.type, [result]);
|
||||
if(result.message && result.read === undefined && !init)
|
||||
|
||||
@@ -22,10 +22,11 @@ class NMJ(Notification):
|
||||
|
||||
# noinspection PyMissingConstructor
|
||||
def __init__(self):
|
||||
addEvent('renamer.after', self.addToLibrary)
|
||||
addApiView(self.testNotifyName(), self.test)
|
||||
addApiView('notify.nmj.auto_config', self.autoConfig)
|
||||
|
||||
addEvent('renamer.after', self.addToLibrary)
|
||||
|
||||
def autoConfig(self, host = 'localhost', **kwargs):
|
||||
|
||||
mount = ''
|
||||
|
||||
@@ -14,7 +14,7 @@ autoload = 'Pushbullet'
|
||||
|
||||
class Pushbullet(Notification):
|
||||
|
||||
url = 'https://api.pushbullet.com/api/%s'
|
||||
url = 'https://api.pushbullet.com/v2/%s'
|
||||
|
||||
def notify(self, message = '', data = None, listener = None):
|
||||
if not data: data = {}
|
||||
@@ -25,11 +25,7 @@ class Pushbullet(Notification):
|
||||
|
||||
# Get all the device IDs linked to this user
|
||||
if not len(devices):
|
||||
response = self.request('devices')
|
||||
if not response:
|
||||
return False
|
||||
|
||||
devices += [device.get('id') for device in response['devices']]
|
||||
devices = [None]
|
||||
|
||||
successful = 0
|
||||
for device in devices:
|
||||
@@ -88,7 +84,8 @@ config = [{
|
||||
},
|
||||
{
|
||||
'name': 'api_key',
|
||||
'label': 'User API Key'
|
||||
'label': 'Access Token',
|
||||
'description': 'Can be found on <a href="https://www.pushbullet.com/account" target="_blank">Account Settings</a>',
|
||||
},
|
||||
{
|
||||
'name': 'devices',
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from httplib import HTTPSConnection
|
||||
|
||||
from couchpotato.core.helpers.encoding import toUnicode, tryUrlencode
|
||||
from couchpotato.core.helpers.variable import getTitle
|
||||
from couchpotato.core.helpers.variable import getTitle, getIdentifier
|
||||
from couchpotato.core.logger import CPLog
|
||||
from couchpotato.core.notifications.base import Notification
|
||||
|
||||
@@ -13,7 +13,6 @@ autoload = 'Pushover'
|
||||
|
||||
class Pushover(Notification):
|
||||
|
||||
app_token = 'YkxHMYDZp285L265L3IwH3LmzkTaCy'
|
||||
|
||||
def notify(self, message = '', data = None, listener = None):
|
||||
if not data: data = {}
|
||||
@@ -22,15 +21,15 @@ class Pushover(Notification):
|
||||
|
||||
api_data = {
|
||||
'user': self.conf('user_key'),
|
||||
'token': self.app_token,
|
||||
'token': self.conf('api_token'),
|
||||
'message': toUnicode(message),
|
||||
'priority': self.conf('priority'),
|
||||
'sound': self.conf('sound'),
|
||||
}
|
||||
|
||||
if data and data.get('identifier'):
|
||||
if data and getIdentifier(data):
|
||||
api_data.update({
|
||||
'url': toUnicode('http://www.imdb.com/title/%s/' % data['identifier']),
|
||||
'url': toUnicode('http://www.imdb.com/title/%s/' % getIdentifier(data)),
|
||||
'url_title': toUnicode('%s on IMDb' % getTitle(data)),
|
||||
})
|
||||
|
||||
@@ -49,7 +48,7 @@ class Pushover(Notification):
|
||||
log.error('Pushover auth failed: %s', response.reason)
|
||||
return False
|
||||
else:
|
||||
log.error('Pushover notification failed.')
|
||||
log.error('Pushover notification failed: %s', request_status)
|
||||
return False
|
||||
|
||||
|
||||
@@ -70,6 +69,12 @@ config = [{
|
||||
'name': 'user_key',
|
||||
'description': 'Register on pushover.net to get one.'
|
||||
},
|
||||
{
|
||||
'name': 'api_token',
|
||||
'description': '<a href="https://pushover.net/apps/clone/couchpotato" target="_blank">Register on pushover.net</a> to get one.',
|
||||
'advanced': True,
|
||||
'default': 'YkxHMYDZp285L265L3IwH3LmzkTaCy',
|
||||
},
|
||||
{
|
||||
'name': 'priority',
|
||||
'default': 0,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
from couchpotato.api import addApiView
|
||||
from couchpotato.core.event import addEvent
|
||||
from couchpotato.core.logger import CPLog
|
||||
from couchpotato.core.notifications.base import Notification
|
||||
@@ -16,7 +17,8 @@ class Synoindex(Notification):
|
||||
index_path = '/usr/syno/bin/synoindex'
|
||||
|
||||
def __init__(self):
|
||||
super(Synoindex, self).__init__()
|
||||
addApiView(self.testNotifyName(), self.test)
|
||||
|
||||
addEvent('renamer.after', self.addToLibrary)
|
||||
|
||||
def addToLibrary(self, message = None, group = None):
|
||||
|
||||
@@ -8,7 +8,7 @@ from couchpotato.core.helpers.variable import splitString, getTitle
|
||||
from couchpotato.core.logger import CPLog
|
||||
from couchpotato.core.notifications.base import Notification
|
||||
import requests
|
||||
from requests.packages.urllib3.exceptions import MaxRetryError
|
||||
from requests.packages.urllib3.exceptions import MaxRetryError, ConnectionError
|
||||
|
||||
|
||||
log = CPLog(__name__)
|
||||
@@ -36,7 +36,7 @@ class XBMC(Notification):
|
||||
|
||||
if self.use_json_notifications.get(host):
|
||||
calls = [
|
||||
('GUI.ShowNotification', {'title': self.default_title, 'message': message, 'image': self.getNotificationImage('small')}),
|
||||
('GUI.ShowNotification', None, {'title': self.default_title, 'message': message, 'image': self.getNotificationImage('small')}),
|
||||
]
|
||||
|
||||
if data and data.get('destination_dir') and (not self.conf('only_first') or hosts.index(host) == 0):
|
||||
@@ -44,7 +44,7 @@ class XBMC(Notification):
|
||||
if not self.conf('force_full_scan') and (self.conf('remote_dir_scan') or socket.getfqdn('localhost') == socket.getfqdn(host.split(':')[0])):
|
||||
param = {'directory': data['destination_dir']}
|
||||
|
||||
calls.append(('VideoLibrary.Scan', param))
|
||||
calls.append(('VideoLibrary.Scan', None, param))
|
||||
|
||||
max_successful += len(calls)
|
||||
response = self.request(host, calls)
|
||||
@@ -52,7 +52,7 @@ class XBMC(Notification):
|
||||
response = self.notifyXBMCnoJSON(host, {'title': self.default_title, 'message': message})
|
||||
|
||||
if data and data.get('destination_dir') and (not self.conf('only_first') or hosts.index(host) == 0):
|
||||
response += self.request(host, [('VideoLibrary.Scan', {})])
|
||||
response += self.request(host, [('VideoLibrary.Scan', None, {})])
|
||||
max_successful += 1
|
||||
|
||||
max_successful += 1
|
||||
@@ -75,7 +75,7 @@ class XBMC(Notification):
|
||||
|
||||
# XBMC JSON-RPC version request
|
||||
response = self.request(host, [
|
||||
('JSONRPC.Version', {})
|
||||
('JSONRPC.Version', None, {})
|
||||
])
|
||||
for result in response:
|
||||
if result.get('result') and type(result['result']['version']).__name__ == 'int':
|
||||
@@ -112,7 +112,7 @@ class XBMC(Notification):
|
||||
self.use_json_notifications[host] = True
|
||||
|
||||
# send the text message
|
||||
resp = self.request(host, [('GUI.ShowNotification', {'title':self.default_title, 'message':message, 'image': self.getNotificationImage('small')})])
|
||||
resp = self.request(host, [('GUI.ShowNotification', None, {'title':self.default_title, 'message':message, 'image': self.getNotificationImage('small')})])
|
||||
for r in resp:
|
||||
if r.get('result') and r['result'] == 'OK':
|
||||
log.debug('Message delivered successfully!')
|
||||
@@ -172,7 +172,7 @@ class XBMC(Notification):
|
||||
# manually fake expected response array
|
||||
return [{'result': 'Error'}]
|
||||
|
||||
except (MaxRetryError, requests.exceptions.Timeout):
|
||||
except (MaxRetryError, requests.exceptions.Timeout, ConnectionError):
|
||||
log.info2('Couldn\'t send request to XBMC, assuming it\'s turned off')
|
||||
return [{'result': 'Error'}]
|
||||
except:
|
||||
@@ -184,12 +184,13 @@ class XBMC(Notification):
|
||||
|
||||
data = []
|
||||
for req in do_requests:
|
||||
method, kwargs = req
|
||||
method, id, kwargs = req
|
||||
|
||||
data.append({
|
||||
'method': method,
|
||||
'params': kwargs,
|
||||
'jsonrpc': '2.0',
|
||||
'id': method,
|
||||
'id': id if id else method,
|
||||
})
|
||||
data = json.dumps(data)
|
||||
|
||||
@@ -223,7 +224,7 @@ config = [{
|
||||
'list': 'notification_providers',
|
||||
'name': 'xbmc',
|
||||
'label': 'XBMC',
|
||||
'description': 'v11 (Eden) and v12 (Frodo)',
|
||||
'description': 'v11 (Eden), v12 (Frodo), v13 (Gotham)',
|
||||
'options': [
|
||||
{
|
||||
'name': 'enabled',
|
||||
@@ -256,7 +257,7 @@ config = [{
|
||||
'default': 0,
|
||||
'type': 'bool',
|
||||
'advanced': True,
|
||||
'description': 'Only scan new movie folder at remote XBMC servers. Works if movie location is the same.',
|
||||
'description': ('Only scan new movie folder at remote XBMC servers.', 'Useful if the XBMC path is different from the path CPS uses.'),
|
||||
},
|
||||
{
|
||||
'name': 'force_full_scan',
|
||||
@@ -264,11 +265,11 @@ config = [{
|
||||
'default': 0,
|
||||
'type': 'bool',
|
||||
'advanced': True,
|
||||
'description': 'Do a full scan instead of only the new movie. Useful if the XBMC path is different from the path CPS uses.',
|
||||
'description': ('Do a full scan instead of only the new movie.', 'Useful if the XBMC path is different from the path CPS uses.'),
|
||||
},
|
||||
{
|
||||
'name': 'on_snatch',
|
||||
'default': 0,
|
||||
'default': False,
|
||||
'type': 'bool',
|
||||
'advanced': True,
|
||||
'description': 'Also send message when movie is snatched.',
|
||||
|
||||
Reference in New Issue
Block a user