diff --git a/couchpotato/core/downloaders/base.py b/couchpotato/core/downloaders/base.py index a3095983..98ab73bb 100644 --- a/couchpotato/core/downloaders/base.py +++ b/couchpotato/core/downloaders/base.py @@ -14,7 +14,6 @@ class Downloader(Plugin): torrent_sources = [ 'http://torrage.com/torrent/%s.torrent', - 'http://torrage.ws/torrent/%s.torrent', 'http://torcache.net/torrent/%s.torrent', ] diff --git a/couchpotato/core/plugins/score/scores.py b/couchpotato/core/plugins/score/scores.py index 8afa129c..3d5a9e69 100644 --- a/couchpotato/core/plugins/score/scores.py +++ b/couchpotato/core/plugins/score/scores.py @@ -116,7 +116,7 @@ def sizeScore(size): def providerScore(provider): - if provider in ['NZBMatrix', 'Nzbs', 'Newzbin']: + if provider in ['OMGWTFNZBs', 'PassThePopcorn', 'SceneAccess', 'TorrentLeech']: return 20 if provider in ['Newznab']: diff --git a/couchpotato/core/providers/nzb/newznab/main.py b/couchpotato/core/providers/nzb/newznab/main.py index 43ea2bd0..fa531058 100644 --- a/couchpotato/core/providers/nzb/newznab/main.py +++ b/couchpotato/core/providers/nzb/newznab/main.py @@ -25,13 +25,7 @@ class Newznab(NZBProvider, RSS): limits_reached = {} - cat_ids = [ - ([2010], ['dvdr']), - ([2030], ['cam', 'ts', 'dvdrip', 'tc', 'r5', 'scr']), - ([2040], ['720p', '1080p']), - ([2050], ['bd50']), - ] - cat_backup_id = 2000 + cat_backup_id = '2000' http_time_between_calls = 1 # Seconds @@ -89,13 +83,13 @@ class Newznab(NZBProvider, RSS): cat_id = self.getCatId(quality['identifier']) arguments = tryUrlencode({ 'imdbid': movie['library']['identifier'].replace('tt', ''), - 'cat': cat_id[0], + 'cat': ','.join(cat_id), 'apikey': host['api_key'], 'extended': 1 }) url = "%s&%s" % (self.getUrl(host['host'], self.urls['search']), arguments) - cache_key = 'newznab.%s.%s.%s' % (host['host'], movie['library']['identifier'], cat_id[0]) + cache_key = 'newznab.%s.%s.%s' % (host['host'], movie['library']['identifier'], cat_id) results = self.createItems(url, cache_key, host, movie = movie, quality = quality) @@ -117,29 +111,18 @@ class Newznab(NZBProvider, RSS): results = [] for nzb in nzbs: - date = '' - size = 0 - for item in nzb: - if item.attrib.get('name') == 'size': - size = item.attrib.get('value') - elif item.attrib.get('name') == 'usenetdate': - date = item.attrib.get('value') - - if date is '': log.debug('Date not parsed properly or not available for %s: %s', (host['host'], self.getTextElement(nzb, "title"))) - if size is 0: log.debug('Size not parsed properly or not available for %s: %s', (host['host'], self.getTextElement(nzb, "title"))) - - id = self.getTextElement(nzb, "guid").split('/')[-1:].pop() + nzb_id = self.getTextElement(nzb, "guid").split('/')[-1:].pop() new = { - 'id': id, + 'id': nzb_id, 'provider': self.getName(), 'provider_extra': host['host'], 'type': 'nzb', 'name': self.getTextElement(nzb, "title"), - 'age': self.calculateAge(int(time.mktime(parse(date).timetuple()))), - 'size': int(size) / 1024 / 1024, - 'url': (self.getUrl(host['host'], self.urls['download']) % id) + self.getApiExt(host), + 'age': self.calculateAge(int(time.mktime(parse(self.getTextElement(nzb, 'pubDate')).timetuple()))), + 'size': int(self.getElement(nzb, "enclosure").attrib['length']) / 1024 / 1024, + 'url': (self.getUrl(host['host'], self.urls['download']) % nzb_id) + self.getApiExt(host), 'download': self.download, - 'detail_url': '%sdetails/%s' % (cleanHost(host['host']), id), + 'detail_url': '%sdetails/%s' % (cleanHost(host['host']), nzb_id), 'content': self.getTextElement(nzb, "description"), } diff --git a/couchpotato/core/providers/nzb/nzbx/__init__.py b/couchpotato/core/providers/nzb/nzbx/__init__.py new file mode 100644 index 00000000..129fba02 --- /dev/null +++ b/couchpotato/core/providers/nzb/nzbx/__init__.py @@ -0,0 +1,23 @@ +from .main import Nzbx + +def start(): + return Nzbx() + +config = [{ + 'name': 'nzbx', + 'groups': [ + { + 'tab': 'searcher', + 'subtab': 'nzb_providers', + 'name': 'nzbX', + 'description': 'Free provider, less accurate. See nzbX', + 'options': [ + { + 'name': 'enabled', + 'type': 'enabler', + 'default': True, + }, + ], + }, + ], +}] diff --git a/couchpotato/core/providers/nzb/nzbx/main.py b/couchpotato/core/providers/nzb/nzbx/main.py new file mode 100644 index 00000000..a67f1e6f --- /dev/null +++ b/couchpotato/core/providers/nzb/nzbx/main.py @@ -0,0 +1,91 @@ +from couchpotato.core.event import fireEvent +from couchpotato.core.helpers.encoding import tryUrlencode +from couchpotato.core.helpers.rss import RSS +from couchpotato.core.helpers.variable import tryInt +from couchpotato.core.logger import CPLog +from couchpotato.core.providers.nzb.base import NZBProvider +import json +import traceback + +log = CPLog(__name__) + + +class Nzbx(NZBProvider, RSS): + endpoint = 'https://nzbx.co/api/' + + urls = { + 'search': 'https://nzbx.co/api/search', + 'details': 'https://nzbx.co/api/details?guid=%s', + 'comments': 'https://nzbx.co/api/get-comments?guid=%s', + 'ratings': 'https://nzbx.co/api/get-votes?guid=%s', + 'downloads': 'https://nzbx.co/api/get-downloads-count?guid=%s', + 'categories': 'https://nzbx.co/api/categories', + 'groups': 'https://nzbx.co/api/groups', + } + + http_time_between_calls = 1 # Seconds + + def search(self, movie, quality): + results = [] + + if self.isDisabled(): + return results + + arguments = tryUrlencode({ + 'q': movie['library']['identifier'].replace('tt', ''), + 'sf': quality.get('size_min'), + }) + url = "%s?%s" % (self.urls['search'], arguments) + + cache_key = 'nzbx.%s.%s' % (movie['library']['identifier'], quality.get('identifier')) + + data = self.getCache(cache_key, url) + + if data: + try: + try: + nzbs = json.loads(data) + except Exception, e: + log.debug('%s, %s', (self.getName(), e)) + return results + + for nzb in nzbs: + + nzbx_guid = nzb['guid'] + + def extra_score(item): + score = 0 + if item['votes']['upvotes'] > item['votes']['downvotes']: + score += 5 + return score + + new = { + 'guid': nzbx_guid, + 'type': 'nzb', + 'provider': self.getName(), + 'download': self.download, + 'url': nzb['nzb'], + 'name': nzb['name'], + 'age': self.calculateAge(int(nzb['postdate'])), + 'size': tryInt(nzb['size']) / 1024 / 1024, + 'description': '', + 'extra_score': extra_score, + 'votes': nzb['votes'], + 'check_nzb': True, + } + + is_correct_movie = fireEvent('searcher.correct_movie', + nzb = new, movie = movie, quality = quality, + imdb_results = False, single = True) + + if is_correct_movie: + new['score'] = fireEvent('score.calculate', new, movie, single = True) + results.append(new) + self.found(new) + + return results + except: + log.error('Failed to parsing %s: %s', (self.getName(), traceback.format_exc())) + + return results +