mirror of
https://github.com/SickGear/SickGear.git
synced 2025-01-07 10:33:38 +00:00
Merge pull request #441 from JackDandy/feature/ChangeSimplifyTPB
Change refactor TPB to use torrent provider simplification and PEP8.
This commit is contained in:
commit
f9190ef51c
3 changed files with 115 additions and 264 deletions
|
@ -35,6 +35,7 @@
|
||||||
* Change refactor SCC to use torrent provider simplification and PEP8
|
* Change refactor SCC to use torrent provider simplification and PEP8
|
||||||
* Change refactor SCD to use torrent provider simplification
|
* Change refactor SCD to use torrent provider simplification
|
||||||
* Change refactor TB to use torrent provider simplification and PEP8
|
* Change refactor TB to use torrent provider simplification and PEP8
|
||||||
|
* Change refactor TBP to use torrent provider simplification and PEP8
|
||||||
* Change refactor TD to use torrent provider simplification and PEP8
|
* Change refactor TD to use torrent provider simplification and PEP8
|
||||||
* Change refactor TL to use torrent provider simplification and PEP8
|
* Change refactor TL to use torrent provider simplification and PEP8
|
||||||
* Remove HDTorrents torrent provider
|
* Remove HDTorrents torrent provider
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 3.5 KiB |
|
@ -1,5 +1,4 @@
|
||||||
# Author: Mr_Orange <mr_orange@hotmail.it>
|
# coding=utf-8
|
||||||
# URL: http://code.google.com/p/sickbeard/
|
|
||||||
#
|
#
|
||||||
# This file is part of SickGear.
|
# This file is part of SickGear.
|
||||||
#
|
#
|
||||||
|
@ -18,84 +17,47 @@
|
||||||
|
|
||||||
from __future__ import with_statement
|
from __future__ import with_statement
|
||||||
|
|
||||||
import re
|
|
||||||
import urllib
|
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
import datetime
|
import datetime
|
||||||
|
import urllib
|
||||||
|
import traceback
|
||||||
|
|
||||||
import sickbeard
|
from . import generic
|
||||||
import generic
|
from sickbeard import config, logger, tvcache, show_name_helpers
|
||||||
from sickbeard.common import Quality, mediaExtensions
|
from sickbeard.common import Quality, mediaExtensions
|
||||||
from sickbeard.name_parser.parser import NameParser, InvalidNameException, InvalidShowException
|
from sickbeard.name_parser.parser import NameParser, InvalidNameException, InvalidShowException
|
||||||
from sickbeard import db, classes, logger, tvcache, helpers
|
from sickbeard.bs4_parser import BS4Parser
|
||||||
from sickbeard.show_name_helpers import allPossibleShowNames, sanitizeSceneName
|
|
||||||
from lib.unidecode import unidecode
|
from lib.unidecode import unidecode
|
||||||
|
|
||||||
|
|
||||||
class ThePirateBayProvider(generic.TorrentProvider):
|
class ThePirateBayProvider(generic.TorrentProvider):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
generic.TorrentProvider.__init__(self, 'The Pirate Bay', True, False)
|
generic.TorrentProvider.__init__(self, 'The Pirate Bay')
|
||||||
self.ratio = None
|
|
||||||
|
self.urls = {'config_provider_home_uri': ['https://thepiratebay.gd/', 'https://thepiratebay.mn/',
|
||||||
|
'https://thepiratebay.am/', 'https://thepiratebay.vg/',
|
||||||
|
'https://thepiratebay.la/'],
|
||||||
|
'search': 'search/%s/0/7/200',
|
||||||
|
'cache': 'tv/latest/'} # order by seed
|
||||||
|
|
||||||
|
self.url = self.urls['config_provider_home_uri'][0]
|
||||||
|
|
||||||
|
self.minseed, self.minleech = 2 * [None]
|
||||||
self.confirmed = False
|
self.confirmed = False
|
||||||
self.minseed = None
|
|
||||||
self.minleech = None
|
|
||||||
self.cache = ThePirateBayCache(self)
|
self.cache = ThePirateBayCache(self)
|
||||||
# self.proxy = ThePirateBayWebproxy()
|
|
||||||
self.urls = {'base_url': ['https://thepiratebay.gd', 'https://thepiratebay.mn',
|
|
||||||
'https://thepiratebay.am', 'https://thepiratebay.vg', 'https://thepiratebay.la'],
|
|
||||||
'search': '/search/%s/0/7/200'} # order by seed
|
|
||||||
self.url = self.urls['base_url'][4]
|
|
||||||
self.re_title_url = '/torrent/(?P<id>\d+)/(?P<title>.*?)//1".+?(?P<url>magnet.*?)//1".+?(?P<seeders>\d+)</td>.+?(?P<leechers>\d+)</td>'
|
|
||||||
|
|
||||||
def getQuality(self, item, anime=False):
|
|
||||||
|
|
||||||
quality = Quality.sceneQuality(item[0], anime)
|
|
||||||
return quality
|
|
||||||
|
|
||||||
def _reverseQuality(self, quality):
|
|
||||||
|
|
||||||
quality_string = ''
|
|
||||||
|
|
||||||
if Quality.SDTV == quality:
|
|
||||||
quality_string = 'HDTV x264'
|
|
||||||
if Quality.SDDVD == quality:
|
|
||||||
quality_string = 'DVDRIP'
|
|
||||||
elif Quality.HDTV == quality:
|
|
||||||
quality_string = '720p HDTV x264'
|
|
||||||
elif Quality.FULLHDTV == quality:
|
|
||||||
quality_string = '1080p HDTV x264'
|
|
||||||
elif Quality.RAWHDTV == quality:
|
|
||||||
quality_string = '1080i HDTV mpeg2'
|
|
||||||
elif Quality.HDWEBDL == quality:
|
|
||||||
quality_string = '720p WEB-DL h264'
|
|
||||||
elif Quality.FULLHDWEBDL == quality:
|
|
||||||
quality_string = '1080p WEB-DL h264'
|
|
||||||
elif Quality.HDBLURAY == quality:
|
|
||||||
quality_string = '720p Bluray x264'
|
|
||||||
elif Quality.FULLHDBLURAY == quality:
|
|
||||||
quality_string = '1080p Bluray x264'
|
|
||||||
|
|
||||||
return quality_string
|
|
||||||
|
|
||||||
def _find_season_quality(self, title, torrent_id, ep_number):
|
def _find_season_quality(self, title, torrent_id, ep_number):
|
||||||
""" Return the modified title of a Season Torrent with the quality found inspecting torrent file list """
|
""" Return the modified title of a Season Torrent with the quality found inspecting torrent file list """
|
||||||
|
|
||||||
quality = Quality.UNKNOWN
|
quality = Quality.UNKNOWN
|
||||||
|
file_name = None
|
||||||
fileName = None
|
|
||||||
|
|
||||||
data = None
|
data = None
|
||||||
has_signature = False
|
has_signature = False
|
||||||
details_url = '/ajax_details_filelist.php?id=%s' % torrent_id
|
details_url = '/ajax_details_filelist.php?id=%s' % torrent_id
|
||||||
for idx, url in enumerate(self.urls['base_url']):
|
for idx, url in enumerate(self.urls['config_provider_home_uri']):
|
||||||
url += details_url
|
data = self.getURL(url + details_url)
|
||||||
if hasattr(self, 'proxy'):
|
|
||||||
url = self.proxy._buildURL(url)
|
|
||||||
|
|
||||||
if self.proxy and self.proxy.isEnabled():
|
|
||||||
self.headers.update({'referer': self.proxy.getProxyURL()})
|
|
||||||
|
|
||||||
data = self.getURL(url)
|
|
||||||
if data and re.search(r'<title>The\sPirate\sBay', data[33:200:]):
|
if data and re.search(r'<title>The\sPirate\sBay', data[33:200:]):
|
||||||
has_signature = True
|
has_signature = True
|
||||||
break
|
break
|
||||||
|
@ -103,22 +65,22 @@ class ThePirateBayProvider(generic.TorrentProvider):
|
||||||
data = None
|
data = None
|
||||||
|
|
||||||
if not has_signature:
|
if not has_signature:
|
||||||
logger.log(u'Failed to identify a page from ThePirateBay at %s attempted urls (tpb blocked? general network issue or site dead)' % len(self.urls['base_url']), logger.ERROR)
|
logger.log(u'Failed to identify a page from ThePirateBay at %s attempted urls (tpb blocked? general network issue or site dead)' % len(self.urls['config_provider_home_uri']), logger.ERROR)
|
||||||
|
|
||||||
if not data:
|
if not data:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
filesList = re.findall('<td.+>(.*?)</td>', data)
|
files_list = re.findall('<td.+>(.*?)</td>', data)
|
||||||
|
|
||||||
if not filesList:
|
if not files_list:
|
||||||
logger.log(u'Unable to get the torrent file list for ' + title, logger.ERROR)
|
logger.log(u'Unable to get the torrent file list for ' + title, logger.ERROR)
|
||||||
|
|
||||||
videoFiles = filter(lambda x: x.rpartition('.')[2].lower() in mediaExtensions, filesList)
|
video_files = filter(lambda x: x.rpartition('.')[2].lower() in mediaExtensions, files_list)
|
||||||
|
|
||||||
# Filtering SingleEpisode/MultiSeason Torrent
|
# Filtering SingleEpisode/MultiSeason Torrent
|
||||||
if ep_number > len(videoFiles) or float(ep_number * 1.1) < len(videoFiles):
|
if ep_number > len(video_files) or float(ep_number * 1.1) < len(video_files):
|
||||||
logger.log(u'Result %s has episode %s and total episodes retrieved in torrent are %s'
|
logger.log(u'Result %s has episode %s and total episodes retrieved in torrent are %s'
|
||||||
% (title, str(ep_number), str(len(videoFiles))), logger.DEBUG)
|
% (title, str(ep_number), str(len(video_files))), logger.DEBUG)
|
||||||
logger.log(u'Result %s seems to be a single episode or multiseason torrent, skipping result...'
|
logger.log(u'Result %s seems to be a single episode or multiseason torrent, skipping result...'
|
||||||
% title, logger.DEBUG)
|
% title, logger.DEBUG)
|
||||||
return None
|
return None
|
||||||
|
@ -126,21 +88,21 @@ class ThePirateBayProvider(generic.TorrentProvider):
|
||||||
if Quality.UNKNOWN != Quality.sceneQuality(title):
|
if Quality.UNKNOWN != Quality.sceneQuality(title):
|
||||||
return title
|
return title
|
||||||
|
|
||||||
for fileName in videoFiles:
|
for file_name in video_files:
|
||||||
quality = Quality.sceneQuality(os.path.basename(fileName))
|
quality = Quality.sceneQuality(os.path.basename(file_name))
|
||||||
if Quality.UNKNOWN != quality:
|
if Quality.UNKNOWN != quality:
|
||||||
break
|
break
|
||||||
|
|
||||||
if None is not fileName and Quality.UNKNOWN == quality:
|
if None is not file_name and Quality.UNKNOWN == quality:
|
||||||
quality = Quality.assumeQuality(os.path.basename(fileName))
|
quality = Quality.assumeQuality(os.path.basename(file_name))
|
||||||
|
|
||||||
if Quality.UNKNOWN == quality:
|
if Quality.UNKNOWN == quality:
|
||||||
logger.log(u'Unable to obtain a Season Quality for ' + title, logger.DEBUG)
|
logger.log(u'Unable to obtain a Season Quality for ' + title, logger.DEBUG)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
myParser = NameParser(showObj=self.show)
|
my_parser = NameParser(showObj=self.show)
|
||||||
parse_result = myParser.parse(fileName)
|
parse_result = my_parser.parse(file_name)
|
||||||
except (InvalidNameException, InvalidShowException):
|
except (InvalidNameException, InvalidShowException):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -149,249 +111,137 @@ class ThePirateBayProvider(generic.TorrentProvider):
|
||||||
if parse_result.series_name and parse_result.season_number:
|
if parse_result.series_name and parse_result.season_number:
|
||||||
title = '%s S%02d %s' % (parse_result.series_name,
|
title = '%s S%02d %s' % (parse_result.series_name,
|
||||||
int(parse_result.season_number),
|
int(parse_result.season_number),
|
||||||
self._reverseQuality(quality))
|
self._reverse_quality(quality))
|
||||||
|
|
||||||
return title
|
return title
|
||||||
|
|
||||||
def _get_season_search_strings(self, ep_obj):
|
def _get_season_search_strings(self, ep_obj, **kwargs):
|
||||||
|
|
||||||
search_string = {'Season': []}
|
if ep_obj.show.air_by_date or ep_obj.show.sports:
|
||||||
for show_name in set(allPossibleShowNames(self.show)):
|
airdate = str(ep_obj.airdate).split('-')[0]
|
||||||
if ep_obj.show.air_by_date or ep_obj.show.sports:
|
ep_detail = [airdate, 'Season ' + airdate]
|
||||||
ep_string = show_name + ' ' + str(ep_obj.airdate).split('-')[0]
|
elif ep_obj.show.anime:
|
||||||
search_string['Season'].append(ep_string)
|
ep_detail = '%02i' % ep_obj.scene_absolute_number
|
||||||
ep_string = show_name + ' Season ' + str(ep_obj.airdate).split('-')[0]
|
|
||||||
search_string['Season'].append(ep_string)
|
|
||||||
elif ep_obj.show.anime:
|
|
||||||
ep_string = show_name + ' ' + '%02d' % ep_obj.scene_absolute_number
|
|
||||||
search_string['Season'].append(ep_string)
|
|
||||||
else:
|
|
||||||
ep_string = show_name + ' S%02d' % int(ep_obj.scene_season)
|
|
||||||
search_string['Season'].append(ep_string)
|
|
||||||
ep_string = show_name + ' Season %s -Ep*' % str(ep_obj.scene_season)
|
|
||||||
search_string['Season'].append(ep_string)
|
|
||||||
|
|
||||||
search_string['Season'].append(ep_string)
|
|
||||||
|
|
||||||
return [search_string]
|
|
||||||
|
|
||||||
def _get_episode_search_strings(self, ep_obj, add_string=''):
|
|
||||||
|
|
||||||
search_string = {'Episode': []}
|
|
||||||
|
|
||||||
if self.show.air_by_date:
|
|
||||||
for show_name in set(allPossibleShowNames(self.show)):
|
|
||||||
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
|
||||||
str(ep_obj.airdate).replace('-', ' ')
|
|
||||||
search_string['Episode'].append(ep_string)
|
|
||||||
elif self.show.sports:
|
|
||||||
for show_name in set(allPossibleShowNames(self.show)):
|
|
||||||
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
|
||||||
str(ep_obj.airdate).replace('-', '|') + '|' + \
|
|
||||||
ep_obj.airdate.strftime('%b')
|
|
||||||
search_string['Episode'].append(ep_string)
|
|
||||||
elif self.show.anime:
|
|
||||||
for show_name in set(allPossibleShowNames(self.show)):
|
|
||||||
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
|
||||||
'%02i' % int(ep_obj.scene_absolute_number)
|
|
||||||
search_string['Episode'].append(ep_string)
|
|
||||||
else:
|
else:
|
||||||
for show_name in set(allPossibleShowNames(self.show)):
|
ep_detail = ['S%02d' % int(ep_obj.scene_season),
|
||||||
ep_string = sanitizeSceneName(show_name) + ' ' + \
|
'Season %s -Ep*' % ep_obj.scene_season]
|
||||||
sickbeard.config.naming_ep_type[2] % {'seasonnumber': ep_obj.scene_season,
|
|
||||||
'episodenumber': ep_obj.scene_episode} + '|' + \
|
|
||||||
sickbeard.config.naming_ep_type[0] % {'seasonnumber': ep_obj.scene_season,
|
|
||||||
'episodenumber': ep_obj.scene_episode} + ' %s' % add_string
|
|
||||||
search_string['Episode'].append(re.sub('\s+', ' ', ep_string))
|
|
||||||
|
|
||||||
return [search_string]
|
return [{'Season': self._build_search_strings(ep_detail)}]
|
||||||
|
|
||||||
|
def _get_episode_search_strings(self, ep_obj, add_string='', **kwargs):
|
||||||
|
|
||||||
|
if self.show.air_by_date or self.show.sports:
|
||||||
|
ep_detail = str(ep_obj.airdate).replace('-', ' ')
|
||||||
|
if self.show.sports:
|
||||||
|
ep_detail += '|' + ep_obj.airdate.strftime('%b')
|
||||||
|
elif self.show.anime:
|
||||||
|
ep_detail = '%02i' % ep_obj.scene_absolute_number
|
||||||
|
else:
|
||||||
|
ep_detail = '%s|%s' % (config.naming_ep_type[2] % {'seasonnumber': ep_obj.scene_season,
|
||||||
|
'episodenumber': ep_obj.scene_episode},
|
||||||
|
config.naming_ep_type[0] % {'seasonnumber': ep_obj.scene_season,
|
||||||
|
'episodenumber': ep_obj.scene_episode})
|
||||||
|
|
||||||
|
return [{'Episode': self._build_search_strings(ep_detail, append=(add_string, '')[self.show.anime])}]
|
||||||
|
|
||||||
def _doSearch(self, search_params, search_mode='eponly', epcount=0, age=0):
|
def _doSearch(self, search_params, search_mode='eponly', epcount=0, age=0):
|
||||||
|
|
||||||
results = []
|
results = []
|
||||||
items = {'Season': [], 'Episode': [], 'RSS': []}
|
items = {'Season': [], 'Episode': [], 'Cache': []}
|
||||||
|
|
||||||
if hasattr(self, 'proxy') and self.proxy and self.proxy.isEnabled():
|
|
||||||
self.headers.update({'referer': self.proxy.getProxyURL()})
|
|
||||||
|
|
||||||
|
rc = dict((k, re.compile('(?i)' + v))
|
||||||
|
for (k, v) in {'info': 'detail', 'get': 'download[^"]+magnet', 'tid': '.*/(\d{5,}).*',
|
||||||
|
'verify': '(?:helper|moderator|trusted|vip)'}.items())
|
||||||
has_signature = False
|
has_signature = False
|
||||||
for mode in search_params.keys():
|
for mode in search_params.keys():
|
||||||
for search_string in search_params[mode]:
|
for search_string in search_params[mode]:
|
||||||
search_string, url = self._get_title_and_url([search_string, '', '', '', ''])
|
|
||||||
if isinstance(search_string, unicode):
|
if isinstance(search_string, unicode):
|
||||||
search_string = unidecode(search_string)
|
search_string = unidecode(search_string)
|
||||||
|
|
||||||
for idx, url in enumerate(self.urls['base_url']):
|
log_url = '%s %s' % (self.name, search_string) # placebo value
|
||||||
if 'RSS' == mode:
|
for idx, search_url in enumerate(self.urls['config_provider_home_uri']):
|
||||||
url += '/tv/latest/'
|
search_url += self.urls['cache'] if 'Cache' == mode\
|
||||||
else:
|
else self.urls['search'] % (urllib.quote(search_string))
|
||||||
url += self.urls['search'] % (urllib.quote(search_string))
|
|
||||||
|
|
||||||
if hasattr(self, 'proxy'):
|
log_url = u'(%s/%s): %s' % (idx + 1, len(self.urls['config_provider_home_uri']), search_url)
|
||||||
url = self.proxy._buildURL(url)
|
|
||||||
|
|
||||||
logger.log(u'Search string at server(%s/%s): %s' % (idx + 1, len(self.urls['base_url']), url),
|
html = self.getURL(search_url)
|
||||||
logger.DEBUG)
|
if html and re.search(r'Pirate\sBay', html[33:7632:]):
|
||||||
|
|
||||||
data = self.getURL(url)
|
|
||||||
if data and re.search(r'Pirate\sBay', data[33:7632:]):
|
|
||||||
has_signature = True
|
has_signature = True
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
data = None
|
html = None
|
||||||
|
|
||||||
if not data:
|
cnt = len(items[mode])
|
||||||
continue
|
try:
|
||||||
|
if not html or self._has_no_results(html):
|
||||||
|
raise generic.HaltParseException
|
||||||
|
|
||||||
if hasattr(self, 'proxy'):
|
with BS4Parser(html, features=['html5lib', 'permissive']) as soup:
|
||||||
re_title_url = self.proxy._buildRE(self.re_title_url)
|
torrent_table = soup.find('table', attrs={'id': 'searchResult'})
|
||||||
else:
|
torrent_rows = [] if not torrent_table else torrent_table.find_all('tr')
|
||||||
re_title_url = re.sub('//1', '', self.re_title_url)
|
|
||||||
|
|
||||||
# Extracting torrent information from data returned by searchURL
|
if 2 > len(torrent_rows):
|
||||||
match = re.compile(re_title_url, re.DOTALL).finditer(urllib.unquote(data))
|
raise generic.HaltParseException
|
||||||
for torrent in match:
|
|
||||||
|
|
||||||
title = torrent.group('title').replace('_', '.') # Do not know why but SickBeard skip release with '_' in name
|
for tr in torrent_table.find_all('tr')[1:]:
|
||||||
url = torrent.group('url')
|
try:
|
||||||
id = int(torrent.group('id'))
|
seeders, leechers = [int(tr.find_all('td')[x].get_text().strip()) for x in (-2, -1)]
|
||||||
seeders = int(torrent.group('seeders'))
|
if 'Cache' != mode and (seeders < self.minseed or leechers < self.minleech):
|
||||||
leechers = int(torrent.group('leechers'))
|
continue
|
||||||
|
|
||||||
# Filter unseeded torrent
|
info = tr.find('a', title=rc['info'])
|
||||||
if 'RSS' != mode and (self.minseed > seeders or self.minleech > leechers):
|
title = info.get_text().strip().replace('_', '.')
|
||||||
continue
|
tid = rc['tid'].sub(r'\1', str(info['href']))
|
||||||
|
|
||||||
# Accept Torrent only from Good People for every Episode Search
|
download_magnet = tr.find('a', title=rc['get'])['href']
|
||||||
if self.confirmed and re.search('(VIP|Trusted|Helper|Moderator)', torrent.group(0)) is None:
|
except (AttributeError, TypeError):
|
||||||
logger.log(u'ThePirateBay Provider found result ' + torrent.group(
|
continue
|
||||||
'title') + ' but that doesn\'t seem like a trusted result so I\'m ignoring it', logger.DEBUG)
|
|
||||||
continue
|
|
||||||
|
|
||||||
# Check number video files = episode in season and find the real Quality for full season torrent analyzing files in torrent
|
if self.confirmed and not tr.find('img', title=rc['verify']):
|
||||||
if 'Season' == mode and 'sponly' == search_mode:
|
logger.log(u'Skipping untrusted non-verified result: ' + title, logger.DEBUG)
|
||||||
ep_number = int(epcount / len(set(allPossibleShowNames(self.show))))
|
continue
|
||||||
title = self._find_season_quality(title, id, ep_number)
|
|
||||||
|
|
||||||
if not title or not url:
|
# Check number video files = episode in season and
|
||||||
continue
|
# find the real Quality for full season torrent analyzing files in torrent
|
||||||
|
if 'Season' == mode and 'sponly' == search_mode:
|
||||||
|
ep_number = int(epcount / len(set(show_name_helpers.allPossibleShowNames(self.show))))
|
||||||
|
title = self._find_season_quality(title, tid, ep_number)
|
||||||
|
|
||||||
item = title, url, id, seeders, leechers
|
if title and download_magnet:
|
||||||
|
items[mode].append((title, download_magnet, seeders))
|
||||||
|
|
||||||
items[mode].append(item)
|
except generic.HaltParseException:
|
||||||
|
pass
|
||||||
|
except Exception:
|
||||||
|
logger.log(u'Failed to parse. Traceback: %s' % traceback.format_exc(), logger.ERROR)
|
||||||
|
self._log_result(mode, len(items[mode]) - cnt, log_url)
|
||||||
|
|
||||||
# For each search mode sort all the items by seeders
|
# For each search mode sort all the items by seeders
|
||||||
items[mode].sort(key=lambda tup: tup[3], reverse=True)
|
items[mode].sort(key=lambda tup: tup[2], reverse=True)
|
||||||
|
|
||||||
results += items[mode]
|
results += items[mode]
|
||||||
|
|
||||||
if not has_signature:
|
if not has_signature:
|
||||||
logger.log(u'Failed to identify a page from ThePirateBay at %s attempted urls (tpb blocked? general network issue or site dead)' % len(self.urls['base_url']), logger.ERROR)
|
logger.log(u'Failed to identify a page from ThePirateBay at %s attempted urls (tpb blocked? general network issue or site dead)' % len(self.urls['config_provider_home_uri']), logger.ERROR)
|
||||||
|
|
||||||
return results
|
return results
|
||||||
|
|
||||||
def _get_title_and_url(self, item):
|
|
||||||
|
|
||||||
title, url, id, seeders, leechers = item
|
|
||||||
|
|
||||||
if title:
|
|
||||||
title += u''
|
|
||||||
title = re.sub(r'\s+', '.', title)
|
|
||||||
|
|
||||||
if url:
|
|
||||||
url = url.replace('&', '&')
|
|
||||||
|
|
||||||
return title, url
|
|
||||||
|
|
||||||
def findPropers(self, search_date=datetime.datetime.today()):
|
def findPropers(self, search_date=datetime.datetime.today()):
|
||||||
|
|
||||||
results = []
|
return self._find_propers(search_date, '')
|
||||||
|
|
||||||
myDB = db.DBConnection()
|
|
||||||
sqlResults = myDB.select(
|
|
||||||
'SELECT s.show_name, e.showid, e.season, e.episode, e.status, e.airdate FROM tv_episodes AS e' +
|
|
||||||
' INNER JOIN tv_shows AS s ON (e.showid = s.indexer_id)' +
|
|
||||||
' WHERE e.airdate >= ' + str(search_date.toordinal()) +
|
|
||||||
' AND (e.status IN (' + ','.join([str(x) for x in Quality.DOWNLOADED]) + ')' +
|
|
||||||
' OR (e.status IN (' + ','.join([str(x) for x in Quality.SNATCHED]) + ')))'
|
|
||||||
)
|
|
||||||
|
|
||||||
if not sqlResults:
|
|
||||||
return results
|
|
||||||
|
|
||||||
for sqlshow in sqlResults:
|
|
||||||
self.show = helpers.findCertainShow(sickbeard.showList, int(sqlshow['showid']))
|
|
||||||
|
|
||||||
if self.show:
|
|
||||||
curEp = self.show.getEpisode(int(sqlshow['season']), int(sqlshow['episode']))
|
|
||||||
|
|
||||||
searchString = self._get_episode_search_strings(curEp, add_string='PROPER|REPACK')
|
|
||||||
|
|
||||||
for item in self._doSearch(searchString[0]):
|
|
||||||
title, url = self._get_title_and_url(item)
|
|
||||||
results.append(classes.Proper(title, url, datetime.datetime.today(), self.show))
|
|
||||||
|
|
||||||
return results
|
|
||||||
|
|
||||||
def seedRatio(self):
|
|
||||||
return self.ratio
|
|
||||||
|
|
||||||
|
|
||||||
class ThePirateBayCache(tvcache.TVCache):
|
class ThePirateBayCache(tvcache.TVCache):
|
||||||
def __init__(self, provider):
|
|
||||||
|
|
||||||
tvcache.TVCache.__init__(self, provider)
|
def __init__(self, this_provider):
|
||||||
|
tvcache.TVCache.__init__(self, this_provider)
|
||||||
|
|
||||||
# only poll ThePirateBay every 10 minutes max
|
self.minTime = 20 # cache update frequency
|
||||||
self.minTime = 20
|
|
||||||
|
|
||||||
def _getRSSData(self):
|
def _getRSSData(self):
|
||||||
search_params = {'RSS': ['rss']}
|
|
||||||
return self.provider._doSearch(search_params)
|
|
||||||
|
|
||||||
|
return self.provider.get_cache_data()
|
||||||
class ThePirateBayWebproxy:
|
|
||||||
def __init__(self):
|
|
||||||
self.Type = 'GlypeProxy'
|
|
||||||
self.param = 'browse.php?u='
|
|
||||||
self.option = '&b=32'
|
|
||||||
self.enabled = False
|
|
||||||
self.url = None
|
|
||||||
|
|
||||||
self.urls = {
|
|
||||||
'Getprivate.eu (NL)': 'http://getprivate.eu/',
|
|
||||||
'Hideme.nl (NL)': 'http://hideme.nl/',
|
|
||||||
'Hiload.org (NL)': 'http://hiload.org/',
|
|
||||||
'Hiload.org (NL) SSL': 'https://hiload.org/',
|
|
||||||
'Interproxy.net (EU)': 'http://interproxy.net/',
|
|
||||||
'Interproxy.net (EU) SSL': 'https://interproxy.net/',
|
|
||||||
'Proxite.eu (DE)': 'http://proxite.eu/',
|
|
||||||
'Proxite.eu (DE) SSL ': 'https://proxite.eu/',
|
|
||||||
}
|
|
||||||
|
|
||||||
def isEnabled(self):
|
|
||||||
""" Return True if we Choose to call TPB via Proxy """
|
|
||||||
return self.enabled
|
|
||||||
|
|
||||||
def getProxyURL(self):
|
|
||||||
""" Return the Proxy URL Choosen via Provider Setting """
|
|
||||||
return str(self.url)
|
|
||||||
|
|
||||||
def _buildURL(self, url):
|
|
||||||
""" Return the Proxyfied URL of the page """
|
|
||||||
if self.isEnabled():
|
|
||||||
url = self.getProxyURL() + self.param + url + self.option
|
|
||||||
|
|
||||||
return url
|
|
||||||
|
|
||||||
def _buildRE(self, regx):
|
|
||||||
""" Return the Proxyfied RE string """
|
|
||||||
if self.isEnabled():
|
|
||||||
regx = re.sub('//1', self.option, regx).replace('&', '&')
|
|
||||||
else:
|
|
||||||
regx = re.sub('//1', '', regx)
|
|
||||||
|
|
||||||
return regx
|
|
||||||
|
|
||||||
|
|
||||||
provider = ThePirateBayProvider()
|
provider = ThePirateBayProvider()
|
||||||
|
|
Loading…
Reference in a new issue