def _sendNMA(nma_api=None, nma_priority=None, event=None, message=None, force=False): title = "LazyLibrarian" # suppress notifications if the notifier is disabled but the notify options are checked if not lazylibrarian.CONFIG['USE_NMA'] and not force: return False if nma_api is None: nma_api = lazylibrarian.CONFIG['NMA_APIKEY'] if nma_priority is None: nma_priority = lazylibrarian.CONFIG['NMA_PRIORITY'] logger.debug(u"NMA: title: " + title) logger.debug(u"NMA: event: " + event) logger.debug(u"NMA: message: " + message) batch = False p = pynma.PyNMA() keys = nma_api.split(',') p.addkey(keys) if len(keys) > 1: batch = True response = p.push(title, event, message, priority=nma_priority, batch_mode=batch) if not response[nma_api][u'code'] == u'200': logger.error(u"NMA: Could not send notification to NotifyMyAndroid") return False else: logger.debug(u"NMA: Success. NotifyMyAndroid returned : %s" % response[nma_api][u'code']) return True
def _sendNMA(self, nma_api=None, nma_priority=None, event=None, message=None, force=False): title = 'Sick-Beard' if not sickbeard.USE_NMA and not force: return False if nma_api == None: nma_api = sickbeard.NMA_API if nma_priority == None: nma_priority = sickbeard.NMA_PRIORITY batch = False p = pynma.PyNMA() keys = nma_api.split(',') p.addkey(keys) if len(keys) > 1: batch = True logger.log("NMA: Sending notice with details: event=\"%s\", message=\"%s\", priority=%s, batch=%s" % (event, message, nma_priority, batch), logger.DEBUG) response = p.push(title, event, message, priority=nma_priority, batch_mode=batch) if not response[nma_api][u'code'] == u'200': logger.log(u'Could not send notification to NotifyMyAndroid', logger.ERROR) return False else: logger.log(u"NMA: Notification sent to NotifyMyAndroid", logger.MESSAGE) return True
def _sendNMA(self, nma_api=None, nma_priority=None, event=None, message=None, force=False): title = 'Sick-Beard' if not sickbeard.USE_NMA and not force: return False if nma_api == None: nma_api = sickbeard.NMA_API if nma_priority == None: nma_priority = sickbeard.NMA_PRIORITY logger.log(u"NMA title: " + title, logger.DEBUG) logger.log(u"NMA event: " + event, logger.DEBUG) logger.log(u"NMA message: " + message, logger.DEBUG) batch = False p = pynma.PyNMA() keys = nma_api.split(',') p.addkey(keys) if len(keys) > 1: batch = True response = p.push(title, event, message, priority=nma_priority, batch_mode=batch) if not response[nma_api][u'code'] == u'200': logger.log(u'Could not send notification to NotifyMyAndroid', logger.ERROR) return False else: return True
def _notify(self, title, body, nma_api=None, nma_priority=None, **kwargs): nma_api = self._choose(nma_api, sickbeard.NMA_API) nma_priority = self._choose(nma_priority, sickbeard.NMA_PRIORITY) batch = False p = pynma.PyNMA() keys = nma_api.split(',') p.addkey(keys) if 1 < len(keys): batch = True self._log_debug('Sending notice with priority=%s, batch=%s' % (nma_priority, batch)) response = p.push('SickGear', title, body, priority=nma_priority, batch_mode=batch) result = False try: if u'200' != response[nma_api][u'code']: self._log_error('Notification failed') else: result = True except (StandardError, Exception): pass return result
def _notify(self, event, message, nma_api=None, nma_priority=None, force=False): # suppress notifications if the notifier is disabled but the notify options are checked if not sickbeard.USE_NMA and not force: return False # fill in omitted parameters if not nma_api: nma_api = sickbeard.NMA_API if not nma_priority: nma_priority = sickbeard.NMA_PRIORITY batch = False p = pynma.PyNMA() keys = nma_api.split(',') p.addkey(keys) if len(keys) > 1: batch = True logger.log( u"NMA: Sending notice with details: event=\"%s\", message=\"%s\", priority=%s, batch=%s" % (event, message, nma_priority, batch), logger.DEBUG) response = p.push("Sick Beard", event, message, priority=nma_priority, batch_mode=batch) if not response[nma_api][u'code'] == u'200': logger.log(u"NMA: Could not send notification to NotifyMyAndroid", logger.ERROR) return False else: logger.log(u"NMA: Notification sent to NotifyMyAndroid", logger.MESSAGE) return True
def notify(self, artist=None, album=None, snatched=None): title = 'Headphones' api = headphones.NMA_APIKEY nma_priority = headphones.NMA_PRIORITY logger.debug(u"NMA title: " + title) logger.debug(u"NMA API: " + api) logger.debug(u"NMA Priority: " + str(nma_priority)) if snatched: event = snatched + " snatched!" message = "Headphones has snatched: " + snatched else: event = artist + ' - ' + album + ' complete!' message = "Headphones has downloaded and postprocessed: " + artist + ' [' + album + ']' logger.debug(u"NMA event: " + event) logger.debug(u"NMA message: " + message) batch = False p = pynma.PyNMA() keys = api.split(',') p.addkey(keys) if len(keys) > 1: batch = True response = p.push(title, event, message, priority=nma_priority, batch_mode=batch) if not response[api][u'code'] == u'200': logger.error(u'Could not send notification to NotifyMyAndroid') return False else: return True
"message": pushmsg, "title": pushtitle.encode('utf-8'), "device": config.push_device, "html": "1" }), {"Content-type": "application/x-www-form-urlencoded"}) r = conn.getresponse() r = json.loads(r.read()) if r["status"] == 1: logger.logging.info("Pushover notification sent succesfully") else: logger.logging.error("Pushover failed with following error" + str(r["errors"])) if config.use_nma == 1: logger.logging.info("Sending NMA notification...") from lib.pynma import pynma p = pynma.PyNMA(config.nma_api) res = p.push(config.app, pushtitle, pushmsg, 0, 1, config.nma_priority) if res[config.nma_api][u'code'] == u'200': logger.logging.info("NMA Notification succesfully send") else: error = res[config.nma_api]['message'].encode('ascii') logger.logging.error("NMA Notification failed: " + error) if config.use_pushbullet == 1: data = urllib.urlencode({ 'type': 'note', 'title': pushtitle, 'body': pushmsg, 'device_id': config.deviceid, 'channel_tag': config.channeltag }) auth = base64.encodestring('%s:' % config.ptoken).replace('\n', '')