From f4489e9565325237c206cda82355c35037f5b907 Mon Sep 17 00:00:00 2001 From: ylde pm Date: Wed, 23 Aug 2017 03:43:50 +0100 Subject: [PATCH 1/2] Replacing torrentz provider with torrentz2. --- .../core/media/_base/providers/torrent/torrentz.py | 30 ++++++++-------------- .../core/media/movie/providers/torrent/torrentz.py | 2 +- 2 files changed, 12 insertions(+), 20 deletions(-) diff --git a/couchpotato/core/media/_base/providers/torrent/torrentz.py b/couchpotato/core/media/_base/providers/torrent/torrentz.py index 8412a8d..db27dcc 100644 --- a/couchpotato/core/media/_base/providers/torrent/torrentz.py +++ b/couchpotato/core/media/_base/providers/torrent/torrentz.py @@ -15,25 +15,19 @@ log = CPLog(__name__) class Base(TorrentMagnetProvider, RSS): urls = { - 'detail': 'https://torrentz.eu/%s', - 'search': 'https://torrentz.eu/feed?q=%s', - 'verified_search': 'https://torrentz.eu/feed_verified?q=%s' + 'detail': 'https://torrentz2.eu/%s', + 'search': 'https://torrentz2.eu/feed?f=%s' } http_time_between_calls = 0 def _searchOnTitle(self, title, media, quality, results): - search_url = self.urls['verified_search'] if self.conf('verified_only') else self.urls['search'] + search_url = self.urls['search'] # Create search parameters search_params = self.buildUrl(title, media, quality) - smin = quality.get('size_min') - smax = quality.get('size_max') - if smin and smax: - search_params += ' size %sm - %sm' % (smin, smax) - min_seeds = tryInt(self.conf('minimal_seeds')) if min_seeds: search_params += ' seed > %s' % (min_seeds - 1) @@ -52,17 +46,22 @@ class Base(TorrentMagnetProvider, RSS): magnet = splitString(detail_url, '/')[-1] magnet_url = 'magnet:?xt=urn:btih:%s&dn=%s&tr=%s' % (magnet.upper(), tryUrlencode(name), tryUrlencode('udp://tracker.openbittorrent.com/announce')) - reg = re.search('Size: (?P\d+) MB Seeds: (?P[\d,]+) Peers: (?P[\d,]+)', six.text_type(description)) + reg = re.search('Size: (?P\d+) (?P[MG]B) Seeds: (?P[\d,]+) Peers: (?P[\d,]+)', six.text_type(description)) size = reg.group('size') + unit = reg.group('unit') seeds = reg.group('seeds').replace(',', '') peers = reg.group('peers').replace(',', '') + multiplier = 1 + if unit == 'GB': + multiplier = 1000 + results.append({ 'id': magnet, 'name': six.text_type(name), 'url': magnet_url, 'detail_url': detail_url, - 'size': tryInt(size), + 'size': tryInt(size)*multiplier, 'seeders': tryInt(seeds), 'leechers': tryInt(peers), }) @@ -78,7 +77,7 @@ config = [{ 'tab': 'searcher', 'list': 'torrent_providers', 'name': 'Torrentz', - 'description': 'Torrentz is a free, fast and powerful meta-search engine. Torrentz', + 'description': 'Torrentz.eu was a free, fast and powerful meta-search engine combining results from dozens of search engines, Torrentz2.eu is trying to replace it. Torrentz2', 'wizard': True, 'icon': 'iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAQklEQVQ4y2NgAALjtJn/ycEMlGiGG0IVAxiwAKzOxaKGARcgxgC8YNSAwWoAzuRMjgsIugqfAUR5CZcBRIcHsWEAADSA96Ig020yAAAAAElFTkSuQmCC', 'options': [ @@ -88,13 +87,6 @@ config = [{ 'default': True }, { - 'name': 'verified_only', - 'type': 'bool', - 'default': True, - 'advanced': True, - 'description': 'Only search verified releases', - }, - { 'name': 'minimal_seeds', 'type': 'int', 'default': 1, diff --git a/couchpotato/core/media/movie/providers/torrent/torrentz.py b/couchpotato/core/media/movie/providers/torrent/torrentz.py index 011ec43..d1294e6 100644 --- a/couchpotato/core/media/movie/providers/torrent/torrentz.py +++ b/couchpotato/core/media/movie/providers/torrent/torrentz.py @@ -11,4 +11,4 @@ autoload = 'Torrentz' class Torrentz(MovieProvider, Base): def buildUrl(self, title, media, quality): - return tryUrlencode('"%s %s"' % (title, media['info']['year'])) \ No newline at end of file + return tryUrlencode('%s %s' % (title, media['info']['year'])) From eea8d7b0e252354e034ab897b5e10fc5fb3e7925 Mon Sep 17 00:00:00 2001 From: ylde pm Date: Wed, 23 Aug 2017 04:27:33 +0100 Subject: [PATCH 2/2] cater for KB size files --- couchpotato/core/media/_base/providers/torrent/torrentz.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/couchpotato/core/media/_base/providers/torrent/torrentz.py b/couchpotato/core/media/_base/providers/torrent/torrentz.py index db27dcc..96e8025 100644 --- a/couchpotato/core/media/_base/providers/torrent/torrentz.py +++ b/couchpotato/core/media/_base/providers/torrent/torrentz.py @@ -46,7 +46,7 @@ class Base(TorrentMagnetProvider, RSS): magnet = splitString(detail_url, '/')[-1] magnet_url = 'magnet:?xt=urn:btih:%s&dn=%s&tr=%s' % (magnet.upper(), tryUrlencode(name), tryUrlencode('udp://tracker.openbittorrent.com/announce')) - reg = re.search('Size: (?P\d+) (?P[MG]B) Seeds: (?P[\d,]+) Peers: (?P[\d,]+)', six.text_type(description)) + reg = re.search('Size: (?P\d+) (?P[KMG]B) Seeds: (?P[\d,]+) Peers: (?P[\d,]+)', six.text_type(description)) size = reg.group('size') unit = reg.group('unit') seeds = reg.group('seeds').replace(',', '') @@ -55,6 +55,8 @@ class Base(TorrentMagnetProvider, RSS): multiplier = 1 if unit == 'GB': multiplier = 1000 + elif unit == 'KB': + multiplier = 0 results.append({ 'id': magnet,