From 787405ae62deea6cdf19141de1acb1ae7d960d78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joel=20K=C3=A5berg?= Date: Thu, 19 Dec 2013 22:14:29 +0100 Subject: [PATCH] Updated YIFY provider to use proxies and magnet links, #2560 (manuall merge) --- .../core/providers/torrent/yify/__init__.py | 6 +++++ .../core/providers/torrent/yify/main.py | 27 +++++++++++++------ 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/couchpotato/core/providers/torrent/yify/__init__.py b/couchpotato/core/providers/torrent/yify/__init__.py index 775ecdbe..99c1162e 100644 --- a/couchpotato/core/providers/torrent/yify/__init__.py +++ b/couchpotato/core/providers/torrent/yify/__init__.py @@ -18,6 +18,12 @@ config = [{ 'type': 'enabler', 'default': 0 }, + { + 'name': 'domain', + 'advanced': True, + 'label': 'Proxy server', + 'description': 'Domain for requests, keep empty to let CouchPotato pick.', + }, { 'name': 'seed_ratio', 'label': 'Seed ratio', diff --git a/couchpotato/core/providers/torrent/yify/main.py b/couchpotato/core/providers/torrent/yify/main.py index 60b2f9b1..0b5e8b87 100644 --- a/couchpotato/core/providers/torrent/yify/main.py +++ b/couchpotato/core/providers/torrent/yify/main.py @@ -1,20 +1,27 @@ from couchpotato.core.helpers.variable import tryInt from couchpotato.core.logger import CPLog -from couchpotato.core.providers.torrent.base import TorrentProvider +from couchpotato.core.providers.torrent.base import TorrentMagnetProvider import traceback log = CPLog(__name__) -class Yify(TorrentProvider): +class Yify(TorrentMagnetProvider): urls = { - 'test' : 'https://yify-torrents.com/api', - 'search' : 'https://yify-torrents.com/api/list.json?keywords=%s&quality=%s', - 'detail': 'https://yify-torrents.com/api/movie.json?id=%s' + 'test' : '%s/api', + 'search' : '%s/api/list.json?keywords=%s&quality=%s', + 'detail': '%s/api/movie.json?id=%s' } http_time_between_calls = 1 #seconds + + proxy_list = [ + 'https://yify-torrents.im', + 'http://yify.unlocktorrent.com', + 'http://yify.ftwnet.co.uk', + 'http://yify-torrents.com.come.in', + ] def search(self, movie, quality): @@ -25,7 +32,9 @@ class Yify(TorrentProvider): def _search(self, movie, quality, results): - data = self.getJsonData(self.urls['search'] % (movie['library']['identifier'], quality['identifier'])) + search_url = self.urls['search'] % (self.getDomain(), movie['library']['identifier'], quality['identifier']) + + data = self.getJsonData(search_url) if data and data.get('MovieList'): try: @@ -41,8 +50,8 @@ class Yify(TorrentProvider): results.append({ 'id': result['MovieID'], 'name': title, - 'url': result['TorrentUrl'], - 'detail_url': self.urls['detail'] % result['MovieID'], + 'url': result['TorrentMagnetUrl'], + 'detail_url': self.urls['detail'] % (self.getDomain(),result['MovieID']), 'size': self.parseSize(result['Size']), 'seeders': tryInt(result['TorrentSeeds']), 'leechers': tryInt(result['TorrentPeers']) @@ -51,3 +60,5 @@ class Yify(TorrentProvider): except: log.error('Failed getting results from %s: %s', (self.getName(), traceback.format_exc())) + def correctProxy(self, data): + return 'title="YIFY-Torrents RSS feed"' in data