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
def notify(self, subject=None, message=None): title = 'PlexPy' api = plexpy.CONFIG.NMA_APIKEY nma_priority = plexpy.CONFIG.NMA_PRIORITY logger.debug(u"NMA title: " + title) logger.debug(u"NMA API: " + api) logger.debug(u"NMA Priority: " + str(nma_priority)) event = subject 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
def _sendNMA(self, nma_api=None, nma_priority=None, event=None, message=None, force=False): title = 'SickRage' if not sickbeard.USE_NMA and not force: return False if nma_api is None: nma_api = sickbeard.NMA_API if nma_priority is 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=\"{0}\", message=\"{1}\", priority={2}, batch={3}".format(event, message, nma_priority, batch), logger.DEBUG) response = p.push(application=title, event=event, description=message, priority=nma_priority, batch_mode=batch) if not response[nma_api]['code'] == '200': logger.log('Could not send notification to NotifyMyAndroid', logger.ERROR) return False else: logger.log("NMA: Notification sent to NotifyMyAndroid", logger.INFO) return True
def notify_pynma(channel, video_name): api_key = config["pynma_key"] #Workaround for the fact PyNMA doesnt support unicode API Keys api_key = api_key.encode('ascii', 'ignore') p = pynma.PyNMA(api_key) result = p.push("TwitchTV VOD Catchup", "A new VOD from %s has been downloaded" % (channel), "VOD %s has been downloaded" % (video_name))
def _sendNMA(self, nma_api=None, nma_priority=None, event=None, message=None, force=False): title = 'Medusa' if not app.USE_NMA and not force: return False if nma_api is None: nma_api = app.NMA_API elif isinstance(nma_api, text_type): nma_api = [nma_api] if nma_priority is None: nma_priority = app.NMA_PRIORITY batch = False p = pynma.PyNMA() keys = nma_api p.addkey(keys) if len(keys) > 1: batch = True log.debug( u'NMA: Sending notice with details: event="{0}, message="{1}", priority={2}, batch={3}', event, message, nma_priority, batch) response = p.push(application=title, event=event, description=message, priority=nma_priority, batch_mode=batch) response_status_code = response[','.join(nma_api)][u'code'] log_message = u'NMA: Could not send notification to NotifyMyAndroid.' if response_status_code == u'200': log.info(u'NMA: Notification sent to NotifyMyAndroid') return True elif response_status_code == u'402': log.info(u'{0} Maximum number of API calls per hour exceeded', log_message) elif response_status_code == u'401': log.warning(u'{0} The apikey provided is not valid', log_message) elif response_status_code == u'400': log.error( u'{0} Data supplied is in the wrong format, invalid length or null', log_message) else: log.warning(u'{0} Error: {1}', log_message, http_code_description(response_status_code)) return False
def _sendNMA(self, nma_api=None, nma_priority=None, event=None, message=None, force=False): title = 'Medusa' if not app.USE_NMA and not force: return False if nma_api is None: nma_api = app.NMA_API elif isinstance(nma_api, text_type): nma_api = [nma_api] if nma_priority is None: nma_priority = app.NMA_PRIORITY batch = False p = pynma.PyNMA() keys = nma_api p.addkey(keys) if len(keys) > 1: batch = True log.debug( u'NMA: Sending notice with details: event="{0}, message="{1}", priority={2}, batch={3}', event, message, nma_priority, batch) response = p.push(application=title, event=event, description=message, priority=nma_priority, batch_mode=batch) if not response[','.join(nma_api)][u'code'] == u'200': log.error(u'Could not send notification to NotifyMyAndroid') return False else: log.info(u'NMA: Notification sent to NotifyMyAndroid') return True
def _sendNMA(self, nma_api=None, nma_priority=None, event=None, message=None, force=False): title = 'SiCKRAGE' 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 logging.debug( "NMA: Sending notice with details: event=\"%s\", message=\"%s\", priority=%s, batch=%s" % (event, message, nma_priority, batch)) response = p.push(application=title, event=event, description=message, priority=nma_priority, batch_mode=batch) if not response[nma_api][b'code'] == '200': logging.error('Could not send notification to NotifyMyAndroid') return False else: logging.info("NMA: Notification sent to NotifyMyAndroid") return True
def notify(self,event, message): if not self.enabled: return batch = False p = pynma.PyNMA() keys = self.apikey.split(',') p.addkey(keys) p.developerkey(str(self.devkey)) if len(keys) > 1: batch = True response = p.push(self.app_name, event, message, priority=self.priority, batch_mode=batch) for key in keys: if not response[str(key)]['code'] == u'200': log.error('Could not send notification to NotifyMyAndroid (%s). %s' % (key,response[key]['message'])) return response