From 1b34db1f5c50958480d8531049a1a0715a5ffe77 Mon Sep 17 00:00:00 2001 From: evilhero Date: Fri, 11 Jan 2013 16:25:51 -0500 Subject: [PATCH] Fix: Forgot to include nzbx.co file for searches --- mylar/prov_nzbx.py | 52 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 mylar/prov_nzbx.py diff --git a/mylar/prov_nzbx.py b/mylar/prov_nzbx.py new file mode 100644 index 00000000..0d6621eb --- /dev/null +++ b/mylar/prov_nzbx.py @@ -0,0 +1,52 @@ +import lib.simplejson as json +import mylar +from mylar import logger +import urllib2 + + +def searchit(cm): + entries = [] + mres = {} + + if mylar.NZBX: + provider = "nzbx" + #stringsearch = str(cm) + "%20" + str(issue) + "%20" + str(year) + searchURL = 'https://nzbx.co/api/search?cat=7030&q=' + str(cm) + + logger.info(u'Parsing results from nzbx.co' % searchURL) + + try: + data = urllib2.urlopen(searchURL, timeout=20).read() + except urllib2.URLError, e: + logger.warn('Error fetching data from nzbx.co: %s' % str(e)) + data = False + + if data: + + d = json.loads(data) + + if not len(d): + logger.info(u"No results found from nzbx.co.") + pass + + else: + for item in d: + try: + url = item['nzb'] + title = item['name'] + size = item['size'] + + entries.append({ + 'title': str(title), + 'link': str(url) + }) + #resultlist.append((title, size, url, provider)) + logger.info('Found %s. Size: %s' % (title, helpers.bytes_to_mb(size))) + + except Exception, e: + logger.error(u"An unknown error occurred trying to parse the feed: %s" % e) + + if len(entries) >= 1: + mres['entries'] = entries + return mres +