Change improve parser tolerance for torrent providers.

Change disable TorrentBytes provider, over 90s for a response is not good.
This commit is contained in:
JackDandy 2016-10-02 18:30:47 +01:00
parent bcfcfaec8d
commit d626c65a24
37 changed files with 165 additions and 62 deletions

View file

@ -97,6 +97,8 @@
* Add Torrentz2 provider
* Add freeleech options to fano, freshon, hdspace, phd, ptf providers
* Change SceneTime to cookie auth
* Change improve parser tolerance for torrent providers
* Change disable TorrentBytes provider, over 90s for a response is not good
* Remove Usenet-Crawler provider
* Change CPU throttling on General Config/Advanced to "Disabled" by default for new installs
* Change provider OMGWTFNZBS api url and auto reject nuked releases

View file

@ -30,7 +30,7 @@ from . import alpharatio, beyondhd, bithdtv, bitmetv, btn, btscene, dh, extrator
fano, filelist, freshontv, funfile, gftracker, grabtheinfo, hd4free, hdbits, hdspace, hdtorrents, \
iptorrents, limetorrents, morethan, ncore, pisexy, pretome, privatehd, ptf, \
rarbg, revtt, scc, scenetime, shazbat, speedcd, \
thepiratebay, torlock, torrentbytes, torrentday, torrenting, torrentleech, \
thepiratebay, torlock, torrentday, torrenting, torrentleech, \
torrentshack, torrentz2, transmithe_net, tvchaosuk, zooqle
# anime
from . import anizb, nyaatorrents, tokyotoshokan
@ -78,7 +78,6 @@ __all__ = ['omgwtfnzbs',
'speedcd',
'thepiratebay',
'torlock',
'torrentbytes',
'torrentday',
'torrenting',
'torrentleech',

View file

@ -80,9 +80,12 @@ class AlphaRatioProvider(generic.TorrentProvider):
raise generic.HaltParseException
for tr in torrent_rows[1:]:
cells = tr.find_all('td')
if 5 > len(cells):
continue
try:
seeders, leechers, size = [tryInt(n, n) for n in [
tr.find_all('td')[x].get_text().strip() for x in -2, -1, -4]]
cells[x].get_text().strip() for x in -2, -1, -4]]
if self._peers_fail(mode, seeders, leechers):
continue

View file

@ -80,9 +80,12 @@ class BitHDTVProvider(generic.TorrentProvider):
raise generic.HaltParseException
for tr in torrent_rows[1:]:
cells = tr.find_all('td')
if 6 > len(cells):
continue
try:
seeders, leechers, size = [tryInt(n, n) for n in [
tr.find_all('td')[x].get_text().strip() for x in -3, -2, -5]]
cells[x].get_text().strip() for x in -3, -2, -5]]
if self.freeleech and not tr.attrs.get('bgcolor').endswith('FF99') or \
self._peers_fail(mode, seeders, leechers):
continue

View file

@ -79,9 +79,12 @@ class BitmetvProvider(generic.TorrentProvider):
raise generic.HaltParseException
for tr in torrent_rows[1:]:
cells = tr.find_all('td')
if 6 > len(cells):
continue
try:
seeders, leechers, size = [tryInt(n, n) for n in [
(tr.find_all('td')[x].get_text().strip()) for x in -3, -2, -5]]
cells[x].get_text().strip() for x in -3, -2, -5]]
if self._peers_fail(mode, seeders, leechers):
continue

View file

@ -77,9 +77,12 @@ class BTSceneProvider(generic.TorrentProvider):
raise generic.HaltParseException
for tr in torrent_rows:
cells = tr.find_all('td')
if 6 > len(cells):
continue
try:
seeders, leechers, size = [tryInt(n, n) for n in [
tr.find_all('td')[x].get_text().strip() for x in -4, -3, -5]]
cells[x].get_text().strip() for x in -4, -3, -5]]
if self._peers_fail(mode, seeders, leechers) or \
self.confirmed and not (tr.find('img', src=rc['verified'])
or tr.find('img', title=rc['verified'])):

View file

@ -80,9 +80,12 @@ class DHProvider(generic.TorrentProvider):
raise generic.HaltParseException
for tr in torrent_rows[1:]:
cells = tr.find_all('td')
if 6 > len(cells):
continue
try:
seeders, leechers, size = [tryInt(n, n) for n in [
tr.find_all('td')[x].get_text().strip() for x in -3, -2, -5]]
cells[x].get_text().strip() for x in -3, -2, -5]]
if self._peers_fail(mode, seeders, leechers) or not tr.find('a', href=rc['cats']):
continue

View file

@ -78,9 +78,12 @@ class ExtraTorrentProvider(generic.TorrentProvider):
raise generic.HaltParseException
for tr in torrent_rows[1:]:
cells = tr.find_all('td')
if 5 > len(cells):
continue
try:
seeders, leechers, size = [tryInt(n.replace('---', '0'), n) for n in [
tr.find_all('td')[x].get_text().strip() for x in -3, -2, -4]]
cells[x].get_text().strip() for x in -3, -2, -4]]
if self._peers_fail(mode, seeders, leechers):
continue

View file

@ -97,13 +97,15 @@ class FanoProvider(generic.TorrentProvider):
raise generic.HaltParseException
for tr in torrent_rows[1:]:
if (any(self.filter)
and ((non_marked and rc['filter'].search(str(tr)))
or (not non_marked and not rc['filter'].search(str(tr))))):
cells = tr.find_all('td')
if (5 > len(cells)
or (any(self.filter)
and ((non_marked and rc['filter'].search(str(tr)))
or (not non_marked and not rc['filter'].search(str(tr)))))):
continue
try:
seeders, leechers, size = [tryInt(n, n) for n in [
tr.find_all('td')[x].get_text().strip() for x in -2, -1, -4]]
cells[x].get_text().strip() for x in -2, -1, -4]]
if self._peers_fail(mode, seeders, leechers) or not tr.find('a', href=rc['cats']):
continue

View file

@ -76,9 +76,12 @@ class FLProvider(generic.TorrentProvider):
raise generic.HaltParseException
for tr in torrent_rows:
cells = tr.select('span[style*="cell"]')
if 6 > len(cells):
continue
try:
seeders, leechers, size = [tryInt(n, n) for n in [
tr.select('span[style*="cell"]')[x].get_text().strip() for x in -3, -2, -5]]
cells[x].get_text().strip() for x in -3, -2, -5]]
if self._peers_fail(mode, seeders, leechers) or not tr.find('a', href=rc['cats']):
continue

View file

@ -102,14 +102,15 @@ class FreshOnTVProvider(generic.TorrentProvider):
raise generic.HaltParseException
for tr in torrent_rows[1:]:
if (tr.find('img', alt='Nuked')
cells = tr.find_all('td')
if (5 > len(cells) or tr.find('img', alt='Nuked')
or (any(self.filter)
and ((non_marked and tr.find('img', src=rc['filter']))
or (not non_marked and not tr.find('img', src=rc['filter']))))):
continue
try:
seeders, leechers, size = [tryInt(n, n) for n in [
tr.find_all('td')[x].get_text().strip() for x in -2, -1, -4]]
cells[x].get_text().strip() for x in -2, -1, -4]]
if self._peers_fail(mode, seeders, leechers):
continue

View file

@ -16,6 +16,7 @@
# along with SickGear. If not, see <http://www.gnu.org/licenses/>.
import re
import time
import traceback
from . import generic
@ -33,7 +34,7 @@ class FunFileProvider(generic.TorrentProvider):
self.url_base = 'https://www.funfile.org/'
self.urls = {'config_provider_home_uri': self.url_base,
'login_action': self.url_base + 'login.php',
'search': self.url_base + 'browse.php?%s&search=%s&incldead=0&showspam=1&',
'search': self.url_base + 'browse.php?%s&search=%s&incldead=0&showspam=1',
'get': self.url_base + '%s'}
self.categories = {'shows': [7], 'anime': [44]}
@ -44,6 +45,7 @@ class FunFileProvider(generic.TorrentProvider):
def _authorised(self, **kwargs):
time.sleep(2.5)
return super(FunFileProvider, self)._authorised(
logged_in=(lambda y=None: all(
[None is not self.session.cookies.get(x, domain='.funfile.org') for x in 'uid', 'pass'])),
@ -79,13 +81,13 @@ class FunFileProvider(generic.TorrentProvider):
raise generic.HaltParseException
for tr in torrent_rows[1:]:
cells = tr.find_all('td')
info = tr.find('a', href=rc['info'])
if 5 > len(cells) or not info:
continue
try:
info = tr.find('a', href=rc['info'])
if not info:
continue
seeders, leechers, size = [tryInt(n, n) for n in [
tr.find_all('td')[x].get_text().strip() for x in -2, -1, -4]]
cells[x].get_text().strip() for x in -2, -1, -4]]
if None is tr.find('a', href=rc['cats']) or self._peers_fail(mode, seeders, leechers):
continue

View file

@ -967,6 +967,8 @@ class TorrentProvider(object, GenericProvider):
url = self.urls.get('login_action')
if url:
response = helpers.getURL(url, session=self.session)
if None is response:
return False
try:
post_params = isinstance(post_params, type({})) and post_params or {}
form = 'form_tmpl' in post_params and post_params.pop('form_tmpl')

View file

@ -82,8 +82,11 @@ class GFTrackerProvider(generic.TorrentProvider):
raise generic.HaltParseException
for tr in torrent_rows[1:]:
cells = tr.find_all('td')
if 3 > len(cells):
continue
try:
seeders, leechers = 2 * [tr.find_all('td')[-1].get_text().strip()]
seeders, leechers = 2 * [cells[-1].get_text().strip()]
seeders, leechers = [tryInt(n) for n in [
rc['seeders'].findall(seeders)[0], rc['leechers'].findall(leechers)[0]]]
if self._peers_fail(mode, seeders, leechers):
@ -91,7 +94,7 @@ class GFTrackerProvider(generic.TorrentProvider):
info = tr.find('a', href=rc['info'])
title = (info.attrs.get('title') or info.get_text()).strip()
size = tr.find_all('td')[-2].get_text().strip()
size = cells[-2].get_text().strip()
download_url = self._link(tr.find('a', href=rc['get'])['href'])
except (AttributeError, TypeError, ValueError):
continue

View file

@ -32,7 +32,7 @@ class GrabTheInfoProvider(generic.TorrentProvider):
self.url_base = 'http://grabthe.info/'
self.urls = {'config_provider_home_uri': self.url_base,
'login': self.url_base + 'takelogin.php',
'login': self.url_base + 'rules.php',
'browse': self.url_base + 'browse.php?%s&incldead=%s&blah=0%s',
'search': '&search=%s',
'get': self.url_base + '%s'}
@ -41,7 +41,19 @@ class GrabTheInfoProvider(generic.TorrentProvider):
self.url = self.urls['config_provider_home_uri']
self.username, self.password, self.freeleech, self.minseed, self.minleech = 5 * [None]
self.digest, self.freeleech, self.minseed, self.minleech = 4 * [None]
def _authorised(self, **kwargs):
return super(GrabTheInfoProvider, self)._authorised(
logged_in=(lambda y='': all(
['Rules</title' in y, self.has_all_cookies()] +
[(self.session.cookies.get(x) or 'sg!no!pw') in self.digest for x in 'uid', 'pass'])),
failed_msg=(lambda y=None: u'Invalid cookie details for %s. Check settings'))
@staticmethod
def _has_signature(data=None):
return generic.TorrentProvider._has_signature(data) or (data and re.search(r'(?i)<title[^<]+?(G\s*T)', data))
def _search_provider(self, search_params, **kwargs):
@ -80,9 +92,12 @@ class GrabTheInfoProvider(generic.TorrentProvider):
raise generic.HaltParseException
for tr in torrent_rows[1 + shows_found:]:
cells = tr.find_all('td')
if 4 > len(cells):
continue
try:
seeders, leechers, size = [tryInt(n, n) for n in [
tr.find_all('td')[x].get_text().strip() for x in -2, -1, -3]]
cells[x].get_text().strip() for x in -2, -1, -3]]
if self._peers_fail(mode, seeders, leechers):
continue

View file

@ -99,7 +99,8 @@ class HDSpaceProvider(generic.TorrentProvider):
raise generic.HaltParseException
for tr in torrent_rows[1:]:
if (tr.find('td', class_='header')
cells = tr.find_all('td')
if (6 > len(cells) or tr.find('td', class_='header')
or (any(self.filter)
and ((non_marked and tr.find('img', src=rc['filter']))
or (not non_marked and not tr.find('img', src=rc['filter']))))):
@ -115,7 +116,7 @@ class HDSpaceProvider(generic.TorrentProvider):
info = tr.find('a', href=rc['info'])
title = (info.attrs.get('title') or info.get_text()).strip()
size = tr.find_all('td')[-5].get_text().strip()
size = cells[-5].get_text().strip()
download_url = self._link(downlink['href'])
except (AttributeError, TypeError, ValueError):
continue

View file

@ -107,13 +107,14 @@ class HDTorrentsProvider(generic.TorrentProvider):
raise generic.HaltParseException
for tr in torrent_rows:
if (any(self.filter)
cells = tr.find_all('td')
if (6 > len(cells) or any(self.filter)
and ((non_marked and tr.find('img', src=rc['filter']))
or (not non_marked and not tr.find('img', src=rc['filter'])))):
continue
try:
seeders, leechers, size = [tryInt(n, n) for n in [
tr.find_all('td')[x].get_text().strip() for x in -3, -2, -5]]
cells[x].get_text().strip() for x in -3, -2, -5]]
if self._peers_fail(mode, seeders, leechers) or not tr.find('a', href=rc['cats']):
continue
title = tr.find('a', href=rc['info']).get_text().strip()

View file

@ -87,6 +87,9 @@ class IPTorrentsProvider(generic.TorrentProvider):
raise generic.HaltParseException
for tr in torrent_rows[1:]:
cells = tr.find_all('td')
if 5 > len(cells):
continue
try:
seeders, leechers = [tryInt(tr.find('td', class_='t_' + x).get_text().strip())
for x in 'seeders', 'leechers']
@ -95,7 +98,7 @@ class IPTorrentsProvider(generic.TorrentProvider):
info = tr.find('a', href=rc['info'])
title = (info.attrs.get('title') or info.get_text()).strip()
size = tr.find_all('td')[-4].get_text().strip()
size = cells[-4].get_text().strip()
download_url = self._link(tr.find('a', href=rc['get'])['href'])
except (AttributeError, TypeError, ValueError):
continue

View file

@ -78,9 +78,12 @@ class LimeTorrentsProvider(generic.TorrentProvider):
raise generic.HaltParseException
for tr in torrent_rows[0]: # 0 = all rows
cells = tr.find_all('td')
if 5 > len(cells):
continue
try:
seeders, leechers, size = [tryInt(n.replace(',', ''), n) for n in [
tr.find_all('td')[x].get_text().strip() for x in -3, -2, -4]]
cells[x].get_text().strip() for x in -3, -2, -4]]
if self._peers_fail(mode, seeders, leechers):
continue

View file

@ -81,12 +81,12 @@ class MoreThanProvider(generic.TorrentProvider):
raise generic.HaltParseException
for tr in torrent_rows[1:]:
if tr.find('img', alt=rc['nuked']):
cells = tr.find_all('td')
if 5 > len(cells) or tr.find('img', alt=rc['nuked']):
continue
try:
seeders, leechers, size = [tryInt(n, n) for n in [
tr.find_all('td')[x].get_text().strip() for x in -2, -1, -4]]
cells[x].get_text().strip() for x in -2, -1, -4]]
if self._peers_fail(mode, seeders, leechers):
continue

View file

@ -74,8 +74,11 @@ class PiSexyProvider(generic.TorrentProvider):
raise generic.HaltParseException
for tr in torrent_rows[1:]:
cells = tr.find_all('td')
if 5 > len(cells):
continue
try:
seeders, leechers = 2 * [tr.find_all('td')[-4].get_text().strip()]
seeders, leechers = 2 * [cells[-4].get_text().strip()]
seeders, leechers = [tryInt(n) for n in [
rc['seeders'].findall(seeders)[0], rc['leechers'].findall(leechers)[0]]]
if self._peers_fail(mode, seeders, leechers) or not tr.find('a', href=rc['valid_cat']) \
@ -84,7 +87,7 @@ class PiSexyProvider(generic.TorrentProvider):
info = tr.find('a', href=rc['info'])
title = (rc['title'].sub('', info.attrs.get('title', '')) or info.get_text()).strip()
size = tr.find_all('td')[3].get_text().strip()
size = cells[3].get_text().strip()
download_url = self._link(tr.find('a', href=rc['get'])['href'])
except (AttributeError, TypeError, ValueError, KeyError, IndexError):
continue

View file

@ -111,7 +111,8 @@ class PrivateHDProvider(generic.TorrentProvider):
raise generic.HaltParseException
for tr in torrent_rows[1:]:
if self.confirmed and tr.find('i', title=re.compile('(?i)unverified')):
cells = tr.find_all('td')
if 5 > len(cells) or (self.confirmed and tr.find('i', title=re.compile('(?i)unverified'))):
continue
if any(self.filter):
marked = ','.join([x.attrs.get('title', '').lower() for x in tr.find_all(
@ -122,7 +123,7 @@ class PrivateHDProvider(generic.TorrentProvider):
continue
try:
seeders, leechers, size = [tryInt(n, n) for n in [
tr.find_all('td')[x].get_text().strip() for x in -3, -2, -4]]
cells[x].get_text().strip() for x in -3, -2, -4]]
if self._peers_fail(mode, seeders, leechers):
continue

View file

@ -105,6 +105,9 @@ class PTFProvider(generic.TorrentProvider):
raise generic.HaltParseException
for tr in torrent_rows[1:]:
cells = tr.find_all('td')
if 4 > len(cells):
continue
if any(self.filter):
marker = ''
try:
@ -115,7 +118,7 @@ class PTFProvider(generic.TorrentProvider):
(not non_marked and not rc['filter'].search(marker))):
continue
try:
seeders, leechers = 2 * [tr.find_all('td')[-2].get_text().strip()]
seeders, leechers = 2 * [cells[-2].get_text().strip()]
seeders, leechers = [tryInt(n) for n in [
rc['seeders'].findall(seeders)[0], rc['leechers'].findall(leechers)[0]]]
if self._peers_fail(mode, seeders, leechers) or\
@ -124,7 +127,7 @@ class PTFProvider(generic.TorrentProvider):
title = tr.find('a', href=rc['info']).get_text().strip()
snatches = tr.find('a', href=rc['snatch']).get_text().strip()
size = tr.find_all('td')[-3].get_text().strip().replace(snatches, '')
size = cells[-3].get_text().strip().replace(snatches, '')
download_url = self._link(tr.find('a', href=rc['get'])['href'])
except (AttributeError, TypeError, ValueError, IndexError):
continue

View file

@ -78,9 +78,12 @@ class RevTTProvider(generic.TorrentProvider):
raise generic.HaltParseException
for tr in torrent_rows[1:]:
cells = tr.find_all('td')
if 5 > len(cells):
continue
try:
seeders, leechers, size = [tryInt(n, n) for n in [
tr.find_all('td')[x].get_text().strip() for x in -2, -1, -4]]
cells[x].get_text().strip() for x in -2, -1, -4]]
if self._peers_fail(mode, seeders, leechers) or not tr.find('a', href=rc['cats']):
continue

View file

@ -94,11 +94,14 @@ class SceneTimeProvider(generic.TorrentProvider):
raise generic.HaltParseException
for tr in torrent_rows[1:]:
cells = tr.find_all('td')
if 4 > len(cells):
continue
try:
seeders, leechers, size = [tryInt(n, n) for n in [
tr.find_all('td')[x].get_text().strip() for x in -2, -1, -3]]
cells[x].get_text().strip() for x in -2, -1, -3]]
if None is tr.find('a', href=rc['cats'])\
or self.freeleech and None is rc['fl'].search(tr.find_all('td')[1].get_text())\
or self.freeleech and None is rc['fl'].search(cells[1].get_text())\
or self._peers_fail(mode, seeders, leechers):
continue

View file

@ -99,8 +99,11 @@ class ShazbatProvider(generic.TorrentProvider):
raise generic.HaltParseException
for tr in torrent_rows[0:]:
cells = tr.find_all('td')
if 4 > len(cells):
continue
try:
stats = tr.find_all('td')[3].get_text().strip()
stats = cells[3].get_text().strip()
seeders, leechers = [(tryInt(x[0], 0), tryInt(x[1], 0)) for x in
re.findall('(?::(\d+))(?:\W*[/]\W*:(\d+))?', stats) if x[0]][0]
if self._peers_fail(mode, seeders, leechers):
@ -109,7 +112,7 @@ class ShazbatProvider(generic.TorrentProvider):
re.findall('([\d.]+\w+)?(?:\s*[(\[](\d+)[)\]])?', stats) if x[0]][0]
size = sizes[(0, 1)[1 < len(sizes)]]
for element in [x for x in tr.find_all('td')[2].contents[::-1] if unicode(x).strip()]:
for element in [x for x in cells[2].contents[::-1] if unicode(x).strip()]:
if 'NavigableString' in str(element.__class__):
title = unicode(element).strip()
break

View file

@ -79,11 +79,14 @@ class SpeedCDProvider(generic.TorrentProvider):
raise generic.HaltParseException
for tr in torrent_rows[1:]:
cells = tr.find_all('td')
if 4 > len(cells):
continue
try:
seeders, leechers, size = [tryInt(n, n) for n in [
tr.find_all('td')[x].get_text().strip() for x in -2, -1, -3]]
cells[x].get_text().strip() for x in -2, -1, -3]]
if None is tr.find('a', href=rc['cats']) \
or self.freeleech and None is rc['fl'].search(tr.find_all('td')[1].get_text()) \
or self.freeleech and None is rc['fl'].search(cells[1].get_text()) \
or self._peers_fail(mode, seeders, leechers):
continue

View file

@ -162,8 +162,11 @@ class ThePirateBayProvider(generic.TorrentProvider):
raise generic.HaltParseException
for tr in torrent_table.find_all('tr')[1:]:
cells = tr.find_all('td')
if 3 > len(cells):
continue
try:
seeders, leechers = [tryInt(tr.find_all('td')[x].get_text().strip()) for x in -2, -1]
seeders, leechers = [tryInt(cells[x].get_text().strip()) for x in -2, -1]
if self._peers_fail(mode, seeders, leechers):
continue

View file

@ -84,9 +84,12 @@ class TorLockProvider(generic.TorrentProvider):
raise generic.HaltParseException
for tr in torrent_rows[1:]:
cells = tr.find_all('td')
if 5 > len(cells):
continue
try:
seeders, leechers, size = [tryInt(n, n) for n in [
tr.find_all('td')[x].get_text().strip() for x in -3, -2, -4]]
cells[x].get_text().strip() for x in -3, -2, -4]]
if self._peers_fail(mode, seeders, leechers) \
or self.confirmed and not (tr.find('img', src=rc['versrc'])
or tr.find('img', title=rc['verified'])):

View file

@ -75,10 +75,13 @@ class TorrentBytesProvider(generic.TorrentProvider):
raise generic.HaltParseException
for tr in torrent_rows[1:]:
cells = tr.find_all('td')
if 5 > len(cells):
continue
try:
info = tr.find('a', href=rc['info'])
seeders, leechers, size = [tryInt(n, n) for n in [
tr.find_all('td')[x].get_text().strip() for x in -2, -1, -4]]
cells[x].get_text().strip() for x in -2, -1, -4]]
if self.freeleech and (len(info.contents) < 2 or not rc['fl'].search(
info.contents[1].string.strip())) or self._peers_fail(mode, seeders, leechers):
continue

View file

@ -87,6 +87,9 @@ class TorrentDayProvider(generic.TorrentProvider):
raise generic.HaltParseException
for tr in torrent_rows[1:]:
cells = tr.find_all('td')
if 4 > len(cells):
continue
try:
seeders, leechers = [tryInt(tr.find('td', class_=x + 'ersInfo').get_text().strip())
for x in 'seed', 'leech']
@ -94,7 +97,7 @@ class TorrentDayProvider(generic.TorrentProvider):
continue
title = tr.find('a', href=rc['info']).get_text().strip()
size = tr.find_all('td')[-3].get_text().strip()
size = cells[-3].get_text().strip()
download_url = self._link(tr.find('a', href=rc['get'])['href'])
except (AttributeError, TypeError, ValueError):
continue

View file

@ -83,9 +83,12 @@ class TorrentingProvider(generic.TorrentProvider):
raise generic.HaltParseException
for tr in torrent_rows[1:]:
cells = tr.find_all('td')
if 4 > len(cells):
continue
try:
seeders, leechers, size = [tryInt(n, n) for n in [
tr.find_all('td')[x].get_text().strip() for x in -2, -1, -3]]
cells[x].get_text().strip() for x in -2, -1, -3]]
if None is tr.find('a', href=rc['cats']) or self._peers_fail(mode, seeders, leechers):
continue

View file

@ -77,6 +77,9 @@ class TorrentLeechProvider(generic.TorrentProvider):
raise generic.HaltParseException
for tr in torrent_rows[1:]:
cells = tr.find_all('td')
if 6 > len(cells):
continue
try:
seeders, leechers = [tryInt(n) for n in [
tr.find('td', class_=x).get_text().strip() for x in 'seeders', 'leechers']]
@ -85,7 +88,7 @@ class TorrentLeechProvider(generic.TorrentProvider):
info = tr.find('td', class_='name').a
title = (info.attrs.get('title') or info.get_text()).strip()
size = tr.find_all('td')[-5].get_text().strip()
size = cells[-5].get_text().strip()
download_url = self._link(tr.find('a', href=rc['get'])['href'])
except (AttributeError, TypeError, ValueError):
continue

View file

@ -82,9 +82,12 @@ class TorrentShackProvider(generic.TorrentProvider):
raise generic.HaltParseException
for tr in torrent_rows[1:]:
cells = tr.find_all('td')
if 5 > len(cells):
continue
try:
seeders, leechers, size = [tryInt(n, n) for n in [
tr.find_all('td')[x].get_text().strip() for x in -2, -1, -4]]
cells[x].get_text().strip() for x in -2, -1, -4]]
if self._peers_fail(mode, seeders, leechers):
continue

View file

@ -76,11 +76,14 @@ class Torrentz2Provider(generic.TorrentProvider):
raise generic.HaltParseException
for tr in torrent_rows:
cells = tr.dd.find_all('span')
if 4 > len(cells):
continue
try:
if not rc['info'].search(unidecode(tr.dt.get_text().strip())):
continue
seeders, leechers, size = [tryInt(n, n) for n in [
tr.dd.find_all('span')[x].get_text().strip() for x in -2, -1, -3]]
cells[x].get_text().strip() for x in -2, -1, -3]]
if self._peers_fail(mode, seeders, leechers):
continue

View file

@ -82,11 +82,14 @@ class TVChaosUKProvider(generic.TorrentProvider):
raise generic.HaltParseException
for tr in torrent_rows[1:]:
cells = tr.find_all('td')
if 6 > len(cells):
continue
try:
seeders, leechers, size = [tryInt(n, n) for n in [
tr.find_all('td')[x].get_text().strip() for x in -3, -2, -5]]
cells[x].get_text().strip() for x in -3, -2, -5]]
if self._peers_fail(mode, seeders, leechers) \
or self.freeleech and None is tr.find_all('td')[1].find('img', title=rc['fl']):
or self.freeleech and None is cells[1].find('img', title=rc['fl']):
continue
info = tr.find('a', href=rc['info'])

View file

@ -72,16 +72,18 @@ class ZooqleProvider(generic.TorrentProvider):
raise generic.HaltParseException
for tr in torrent_rows[1:]:
cells = tr.find_all('td')
if 4 > len(cells):
continue
try:
td = tr.find_all('td')
stats = rc['peers'].findall((td[-1].find(class_='progress') or {}).get('title', ''))
stats = rc['peers'].findall((cells[-1].find(class_='progress') or {}).get('title', ''))
seeders, leechers = any(stats) and [tryInt(x) for x in stats[0]] or (0, 0)
if self._peers_fail(mode, seeders, leechers):
continue
info = td[1].find('a', href=rc['info'])
info = cells[1].find('a', href=rc['info'])
title = info and info.get_text().strip()
size = td[-3].get_text().strip()
size = cells[-3].get_text().strip()
download_url = info and (self.urls['get'] % rc['info'].findall(info['href'])[0])
except (AttributeError, TypeError, ValueError, IndexError):
continue