diff --git a/couchpotato/core/media/_base/providers/base.py b/couchpotato/core/media/_base/providers/base.py index 587545c8..1062a1a8 100644 --- a/couchpotato/core/media/_base/providers/base.py +++ b/couchpotato/core/media/_base/providers/base.py @@ -94,6 +94,8 @@ class Provider(Plugin): try: data = XMLTree.fromstring(ss(data)) return self.getElements(data, item_path) + except XMLTree.ParseError: + log.error('Invalid XML returned, check "%s" manually for issues', url) except: log.error('Failed to parsing %s: %s', (self.getName(), traceback.format_exc())) diff --git a/couchpotato/core/media/_base/providers/nzb/omgwtfnzbs.py b/couchpotato/core/media/_base/providers/nzb/omgwtfnzbs.py index bac0614d..ea5f90f7 100644 --- a/couchpotato/core/media/_base/providers/nzb/omgwtfnzbs.py +++ b/couchpotato/core/media/_base/providers/nzb/omgwtfnzbs.py @@ -1,13 +1,9 @@ -from urlparse import urlparse, parse_qs -import time - from couchpotato.core.event import fireEvent from couchpotato.core.helpers.encoding import toUnicode, tryUrlencode from couchpotato.core.helpers.rss import RSS from couchpotato.core.helpers.variable import tryInt from couchpotato.core.logger import CPLog from couchpotato.core.media._base.providers.nzb.base import NZBProvider -from dateutil.parser import parse log = CPLog(__name__) @@ -16,8 +12,7 @@ log = CPLog(__name__) class Base(NZBProvider, RSS): urls = { - 'search': 'https://rss.omgwtfnzbs.org/rss-search.php?%s', - 'detail_url': 'https://omgwtfnzbs.org/details.php?id=%s', + 'search': 'https://api.omgwtfnzbs.org/json/?%s', } http_time_between_calls = 1 # Seconds @@ -47,22 +42,20 @@ class Base(NZBProvider, RSS): 'api': self.conf('api_key', default = ''), }) - nzbs = self.getRSSData(self.urls['search'] % params) + nzbs = self.getJsonData(self.urls['search'] % params) - for nzb in nzbs: + if isinstance(nzbs, list): + for nzb in nzbs: - enclosure = self.getElement(nzb, 'enclosure').attrib - nzb_id = parse_qs(urlparse(self.getTextElement(nzb, 'link')).query).get('id')[0] - - results.append({ - 'id': nzb_id, - 'name': toUnicode(self.getTextElement(nzb, 'title')), - 'age': self.calculateAge(int(time.mktime(parse(self.getTextElement(nzb, 'pubDate')).timetuple()))), - 'size': tryInt(enclosure['length']) / 1024 / 1024, - 'url': enclosure['url'], - 'detail_url': self.urls['detail_url'] % nzb_id, - 'description': self.getTextElement(nzb, 'description') - }) + results.append({ + 'id': nzb.get('nzbid'), + 'name': toUnicode(nzb.get('release')), + 'age': self.calculateAge(tryInt(nzb.get('usenetage'))), + 'size': tryInt(nzb.get('sizebytes')) / 1024 / 1024, + 'url': nzb.get('getnzb'), + 'detail_url': nzb.get('details'), + 'description': nzb.get('weblink') + }) config = [{ diff --git a/couchpotato/core/media/_base/providers/torrent/torrentbytes.py b/couchpotato/core/media/_base/providers/torrent/torrentbytes.py index 8e2becb2..fadd2ea0 100644 --- a/couchpotato/core/media/_base/providers/torrent/torrentbytes.py +++ b/couchpotato/core/media/_base/providers/torrent/torrentbytes.py @@ -56,7 +56,7 @@ class Base(TorrentProvider): full_id = link['href'].replace('details.php?id=', '') torrent_id = full_id[:6] - name = toUnicode(link.contents[0]) + name = toUnicode(link.contents[0].encode('ISO-8859-1')).strip() results.append({ 'id': torrent_id, diff --git a/couchpotato/core/media/movie/charts/static/charts.js b/couchpotato/core/media/movie/charts/static/charts.js index 3d70f7f8..d70a1c64 100644 --- a/couchpotato/core/media/movie/charts/static/charts.js +++ b/couchpotato/core/media/movie/charts/static/charts.js @@ -44,11 +44,12 @@ var Charts = new Class({ if( Cookie.read('suggestions_charts_menu_selected') === 'charts'){ self.show(); - self.fireEvent.delay(0, self, 'created'); } else self.el.hide(); + self.fireEvent.delay(0, self, 'created'); + }, fill: function(json){ diff --git a/couchpotato/core/media/movie/suggestion/static/suggest.js b/couchpotato/core/media/movie/suggestion/static/suggest.js index ca4b07c2..ace7f387 100644 --- a/couchpotato/core/media/movie/suggestion/static/suggest.js +++ b/couchpotato/core/media/movie/suggestion/static/suggest.js @@ -51,8 +51,8 @@ var SuggestList = new Class({ self.show(); else self.hide(); - - self.fireEvent('created'); + + self.fireEvent.delay(0, self, 'created'); }, diff --git a/couchpotato/core/notifications/core/main.py b/couchpotato/core/notifications/core/main.py index 771d9696..4c39fb77 100644 --- a/couchpotato/core/notifications/core/main.py +++ b/couchpotato/core/notifications/core/main.py @@ -149,16 +149,15 @@ class CoreNotifier(Notification): def notify(self, message = '', data = None, listener = None): if not data: data = {} + n = { + '_t': 'notification', + 'time': int(time.time()), + } + try: db = get_db() - data['notification_type'] = listener if listener else 'unknown' - - n = { - '_t': 'notification', - 'time': int(time.time()), - 'message': toUnicode(message) - } + n['message'] = toUnicode(message) if data.get('sticky'): n['sticky'] = True @@ -171,7 +170,7 @@ class CoreNotifier(Notification): return True except: - log.error('Failed notify: %s', traceback.format_exc()) + log.error('Failed notify "%s": %s', (n, traceback.format_exc())) def frontend(self, type = 'notification', data = None, message = None): if not data: data = {}