Skip to content

Commit

Permalink
Clean up rapidpush plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
gazpachoking committed Sep 3, 2013
1 parent dc4bf4f commit a8bd46f
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions flexget/plugins/output/rapidpush.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import unicode_literals, division, absolute_import
import logging

from flexget.utils import json
from flexget.plugin import register_plugin, priority
from flexget.utils.template import RenderError
Expand All @@ -10,6 +11,7 @@
headers = {'User-Agent': "FlexGet RapidPush plugin/%s" % str(__version__)}
url = 'https://rapidpush.net/api'


class OutputRapidPush(object):
"""
Example::
Expand All @@ -20,7 +22,8 @@ class OutputRapidPush(object):
[title: title, default New release]
[group: device group, default no group]
[message: the message, default {{title}}]
[channel: the broadcast notification channel, if provided it will be send to the channel subscribers instead of your devices, default no channel]
[channel: the broadcast notification channel, if provided it will be send to the channel subscribers instead of
your devices, default no channel]
[priority: 0 - 6 (6 = highest), default 2 (normal)]
[notify_accepted: boolean true or false, default true]
[notify_rejected: boolean true or false, default false]
Expand Down Expand Up @@ -113,8 +116,6 @@ def process_notifications(self, task, entries, config):
except RenderError as e:
log.error('Error setting RapidPush category: %s' % e)



group = entry.get('group', config['group'])
try:
group = entry.render(group)
Expand All @@ -134,20 +135,19 @@ def process_notifications(self, task, entries, config):
try:
channel = entry.render(channel)
except RenderError as e:
log.error('Error setting RapidPush channel: %s' % e)
log.error('Error setting RapidPush channel: %s' % e)

# Send the broadcast request
data_string = json.dumps({
'title': title,
'message': message,
'channel': channel})
data = {'apikey': apikey, 'command': 'broadcast', 'data': data_string}
data = {'apikey': apikey, 'command': 'broadcast', 'data': data_string}


response = task.requests.post(url, headers=headers, data=data, raise_status=False)

json_data = response.json()
if json_data.has_key('code'):
if 'code' in json_data:
if json_data['code'] == 200:
log.debug("RapidPush message sent")
else:
Expand Down

0 comments on commit a8bd46f

Please sign in to comment.