From 17e01689d9d833845c41a2444b6767012b7e8e54 Mon Sep 17 00:00:00 2001 From: Ruud Date: Wed, 19 Dec 2012 16:13:40 +0100 Subject: [PATCH 1/7] Remove torrage.ws. fix #1157 --- couchpotato/core/downloaders/base.py | 1 - 1 file changed, 1 deletion(-) 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', ] From 3c04eed2182a30648fa237f755dbc9a1c1393da7 Mon Sep 17 00:00:00 2001 From: Ruud Date: Thu, 20 Dec 2012 15:18:46 +0100 Subject: [PATCH 2/7] Added nzbx option --- .../core/providers/nzb/nzbx/__init__.py | 23 +++++ couchpotato/core/providers/nzb/nzbx/main.py | 92 +++++++++++++++++++ 2 files changed, 115 insertions(+) create mode 100644 couchpotato/core/providers/nzb/nzbx/__init__.py create mode 100644 couchpotato/core/providers/nzb/nzbx/main.py diff --git a/couchpotato/core/providers/nzb/nzbx/__init__.py b/couchpotato/core/providers/nzb/nzbx/__init__.py new file mode 100644 index 00000000..9d794e3d --- /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..e7c2d342 --- /dev/null +++ b/couchpotato/core/providers/nzb/nzbx/main.py @@ -0,0 +1,92 @@ +from couchpotato.core.event import fireEvent +from couchpotato.core.helpers.encoding import toUnicode, tryUrlencode, \ + simplifyString +from couchpotato.core.helpers.rss import RSS +from couchpotato.core.helpers.variable import tryInt, getTitle +from couchpotato.core.logger import CPLog +from couchpotato.core.providers.nzb.base import NZBProvider +from couchpotato.environment import Env +from dateutil.parser import parse +import re +import time +import traceback +import json + +log = CPLog(__name__) + + +class Nzbx(NZBProvider, RSS): + endpoint = 'https://nzbx.co/api/' + + urls = { + 'search': endpoint + 'search', + 'details': endpoint + 'details?guid=%s', + 'comments': endpoint + 'get-comments?guid=%s', + 'ratings': endpoint + 'get-votes?guid=%s', + 'downloads': endpoint + 'get-downloads-count?guid=%s', + 'categories': endpoint + 'categories', + 'groups': endpoint + 'groups', + } + + http_time_between_calls = 1 # Seconds + + def search(self, movie, quality): + + results = [] + if self.isDisabled(): + return results + + q = '"%s %s" %s' % (simplifyString(getTitle(movie['library'])), movie['library']['year'], quality.get('identifier')) + arguments = tryUrlencode({ + 'q': q, + 'l': 250, # Limit on number of files returned + #'i': '', # index of file + #'sf': '' # size filter + }) + 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'] + + # need to filter by completed + + new = { + 'guid': nzbx_guid, + 'type': 'nzb', + 'provider': self.getName(), + 'download': nzb['nzb'], + 'name': nzb['name'], + 'age': self.calculateAge(int(nzb['postdate'])), + 'size': tryInt(nzb['size']) / 1024 / 1024, + '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 + + def isEnabled(self): + return NZBProvider.isEnabled(self) and self.conf('enabled') From 031a186d71e14c4f020abd258de30cd887f8eb45 Mon Sep 17 00:00:00 2001 From: Ruud Date: Thu, 20 Dec 2012 15:19:40 +0100 Subject: [PATCH 3/7] NZBx fixes --- couchpotato/core/providers/nzb/nzbx/main.py | 45 ++++++++++++--------- 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/couchpotato/core/providers/nzb/nzbx/main.py b/couchpotato/core/providers/nzb/nzbx/main.py index e7c2d342..138641e9 100644 --- a/couchpotato/core/providers/nzb/nzbx/main.py +++ b/couchpotato/core/providers/nzb/nzbx/main.py @@ -16,18 +16,18 @@ log = CPLog(__name__) class Nzbx(NZBProvider, RSS): - endpoint = 'https://nzbx.co/api/' - + endpoint = 'https://nzbx.co/api/' + urls = { - 'search': endpoint + 'search', - 'details': endpoint + 'details?guid=%s', - 'comments': endpoint + 'get-comments?guid=%s', - 'ratings': endpoint + 'get-votes?guid=%s', - 'downloads': endpoint + 'get-downloads-count?guid=%s', - 'categories': endpoint + 'categories', - 'groups': endpoint + 'groups', + '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): @@ -39,9 +39,9 @@ class Nzbx(NZBProvider, RSS): q = '"%s %s" %s' % (simplifyString(getTitle(movie['library'])), movie['library']['year'], quality.get('identifier')) arguments = tryUrlencode({ 'q': q, - 'l': 250, # Limit on number of files returned - #'i': '', # index of file - #'sf': '' # size filter + 'l': 250, # Limit on number of files returned + #'i': '', # index of file + #'sf': '' # size filter }) url = "%s?%s" % (self.urls['search'], arguments) @@ -59,17 +59,26 @@ class Nzbx(NZBProvider, RSS): for nzb in nzbs: nzbx_guid = nzb['guid'] - - # need to filter by completed - + + 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': nzb['nzb'], + '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, } @@ -89,4 +98,4 @@ class Nzbx(NZBProvider, RSS): return results def isEnabled(self): - return NZBProvider.isEnabled(self) and self.conf('enabled') + return NZBProvider.isEnabled(self) and self.conf('enabled') \ No newline at end of file From b8e86b378fb2481b50dd70faef641f307ea89fbb Mon Sep 17 00:00:00 2001 From: Ruud Date: Thu, 20 Dec 2012 15:45:04 +0100 Subject: [PATCH 4/7] NZBx provider --- .../core/providers/nzb/nzbx/__init__.py | 4 +-- couchpotato/core/providers/nzb/nzbx/main.py | 32 +++++++------------ 2 files changed, 13 insertions(+), 23 deletions(-) diff --git a/couchpotato/core/providers/nzb/nzbx/__init__.py b/couchpotato/core/providers/nzb/nzbx/__init__.py index 9d794e3d..129fba02 100644 --- a/couchpotato/core/providers/nzb/nzbx/__init__.py +++ b/couchpotato/core/providers/nzb/nzbx/__init__.py @@ -9,8 +9,8 @@ config = [{ { 'tab': 'searcher', 'subtab': 'nzb_providers', - 'name': 'nzbx', - 'description': 'Free provider, less accurate. See nzbx', + 'name': 'nzbX', + 'description': 'Free provider, less accurate. See nzbX', 'options': [ { 'name': 'enabled', diff --git a/couchpotato/core/providers/nzb/nzbx/main.py b/couchpotato/core/providers/nzb/nzbx/main.py index 138641e9..a67f1e6f 100644 --- a/couchpotato/core/providers/nzb/nzbx/main.py +++ b/couchpotato/core/providers/nzb/nzbx/main.py @@ -1,23 +1,18 @@ from couchpotato.core.event import fireEvent -from couchpotato.core.helpers.encoding import toUnicode, tryUrlencode, \ - simplifyString +from couchpotato.core.helpers.encoding import tryUrlencode from couchpotato.core.helpers.rss import RSS -from couchpotato.core.helpers.variable import tryInt, getTitle +from couchpotato.core.helpers.variable import tryInt from couchpotato.core.logger import CPLog from couchpotato.core.providers.nzb.base import NZBProvider -from couchpotato.environment import Env -from dateutil.parser import parse -import re -import time -import traceback 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', @@ -27,27 +22,25 @@ class Nzbx(NZBProvider, RSS): '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 - q = '"%s %s" %s' % (simplifyString(getTitle(movie['library'])), movie['library']['year'], quality.get('identifier')) arguments = tryUrlencode({ - 'q': q, - 'l': 250, # Limit on number of files returned - #'i': '', # index of file - #'sf': '' # size filter + '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: @@ -59,14 +52,13 @@ class Nzbx(NZBProvider, RSS): 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', @@ -97,5 +89,3 @@ class Nzbx(NZBProvider, RSS): return results - def isEnabled(self): - return NZBProvider.isEnabled(self) and self.conf('enabled') \ No newline at end of file From b225980ce7e5aaf3145903aba07b3f483617a46d Mon Sep 17 00:00:00 2001 From: Ruud Date: Fri, 21 Dec 2012 22:14:37 +0100 Subject: [PATCH 5/7] Use pubDate and enclosure length for newznab --- .../core/providers/nzb/newznab/main.py | 23 +++++-------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/couchpotato/core/providers/nzb/newznab/main.py b/couchpotato/core/providers/nzb/newznab/main.py index 43ea2bd0..7b3c2267 100644 --- a/couchpotato/core/providers/nzb/newznab/main.py +++ b/couchpotato/core/providers/nzb/newznab/main.py @@ -117,29 +117,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"), } From 6c7c4c7aba8e2616d07ee591e6ea60fb25ca72fa Mon Sep 17 00:00:00 2001 From: Ruud Date: Fri, 21 Dec 2012 23:17:42 +0100 Subject: [PATCH 6/7] Use same api call for all qualities. closes #1164 --- couchpotato/core/providers/nzb/newznab/main.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/couchpotato/core/providers/nzb/newznab/main.py b/couchpotato/core/providers/nzb/newznab/main.py index 7b3c2267..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) From 5e6aea97f73c4cec71ee3f1c0b77c0448b9f48ce Mon Sep 17 00:00:00 2001 From: Ruud Date: Fri, 21 Dec 2012 23:17:50 +0100 Subject: [PATCH 7/7] Score providers --- couchpotato/core/plugins/score/scores.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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']: