|
|
@ -1,11 +1,9 @@ |
|
|
|
from bs4 import BeautifulSoup |
|
|
|
from couchpotato.core.helpers.encoding import toUnicode, tryUrlencode |
|
|
|
from couchpotato.core.helpers.variable import tryInt, cleanHost |
|
|
|
from couchpotato.core.helpers.variable import tryInt |
|
|
|
from couchpotato.core.logger import CPLog |
|
|
|
from couchpotato.core.providers.torrent.base import TorrentMagnetProvider |
|
|
|
from couchpotato.environment import Env |
|
|
|
import re |
|
|
|
import time |
|
|
|
import traceback |
|
|
|
|
|
|
|
log = CPLog(__name__) |
|
|
@ -30,8 +28,8 @@ class ThePirateBay(TorrentMagnetProvider): |
|
|
|
http_time_between_calls = 0 |
|
|
|
|
|
|
|
proxy_list = [ |
|
|
|
'https://thepiratebay.se', |
|
|
|
'https://tpb.ipredator.se', |
|
|
|
'https://thepiratebay.se', |
|
|
|
'https://depiraatbaai.be', |
|
|
|
'https://piratereverse.info', |
|
|
|
'https://tpb.pirateparty.org.uk', |
|
|
@ -43,10 +41,6 @@ class ThePirateBay(TorrentMagnetProvider): |
|
|
|
'https://kuiken.co', |
|
|
|
] |
|
|
|
|
|
|
|
def __init__(self): |
|
|
|
self.domain = self.conf('domain') |
|
|
|
super(ThePirateBay, self).__init__() |
|
|
|
|
|
|
|
def _searchOnTitle(self, title, movie, quality, results): |
|
|
|
|
|
|
|
page = 0 |
|
|
@ -108,38 +102,11 @@ class ThePirateBay(TorrentMagnetProvider): |
|
|
|
except: |
|
|
|
log.error('Failed getting results from %s: %s', (self.getName(), traceback.format_exc())) |
|
|
|
|
|
|
|
|
|
|
|
def isEnabled(self): |
|
|
|
return super(ThePirateBay, self).isEnabled() and self.getDomain() |
|
|
|
|
|
|
|
def getDomain(self, url = ''): |
|
|
|
|
|
|
|
if not self.domain: |
|
|
|
for proxy in self.proxy_list: |
|
|
|
|
|
|
|
prop_name = 'tpb_proxy.%s' % proxy |
|
|
|
last_check = float(Env.prop(prop_name, default = 0)) |
|
|
|
if last_check > time.time() - 1209600: |
|
|
|
continue |
|
|
|
|
|
|
|
data = '' |
|
|
|
try: |
|
|
|
data = self.urlopen(proxy, timeout = 3, show_error = False) |
|
|
|
except: |
|
|
|
log.debug('Failed tpb proxy %s', proxy) |
|
|
|
|
|
|
|
if 'title="Pirate Search"' in data: |
|
|
|
log.debug('Using proxy: %s', proxy) |
|
|
|
self.domain = proxy |
|
|
|
break |
|
|
|
|
|
|
|
Env.prop(prop_name, time.time()) |
|
|
|
|
|
|
|
if not self.domain: |
|
|
|
log.error('No TPB proxies left, please add one in settings, or let us know which one to add on the forum.') |
|
|
|
return None |
|
|
|
|
|
|
|
return cleanHost(self.domain).rstrip('/') + url |
|
|
|
def correctProxy(self, data): |
|
|
|
return 'title="Pirate Search"' in data |
|
|
|
|
|
|
|
def getMoreInfo(self, item): |
|
|
|
full_description = self.getCache('tpb.%s' % item['id'], item['detail_url'], cache_timeout = 25920000) |
|
|
|