diff --git a/CHANGES.md b/CHANGES.md index 39ab6cbe..cfa8c663 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -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 diff --git a/sickbeard/providers/__init__.py b/sickbeard/providers/__init__.py index b3ded784..6d1a4e86 100755 --- a/sickbeard/providers/__init__.py +++ b/sickbeard/providers/__init__.py @@ -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', diff --git a/sickbeard/providers/alpharatio.py b/sickbeard/providers/alpharatio.py index c6fae1fd..db8fb3b7 100644 --- a/sickbeard/providers/alpharatio.py +++ b/sickbeard/providers/alpharatio.py @@ -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 diff --git a/sickbeard/providers/bithdtv.py b/sickbeard/providers/bithdtv.py index 8a7af6d7..6367aabc 100644 --- a/sickbeard/providers/bithdtv.py +++ b/sickbeard/providers/bithdtv.py @@ -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 diff --git a/sickbeard/providers/bitmetv.py b/sickbeard/providers/bitmetv.py index f00eaff3..ba003a16 100644 --- a/sickbeard/providers/bitmetv.py +++ b/sickbeard/providers/bitmetv.py @@ -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 diff --git a/sickbeard/providers/btscene.py b/sickbeard/providers/btscene.py index fddd2cb5..5b1ee1be 100644 --- a/sickbeard/providers/btscene.py +++ b/sickbeard/providers/btscene.py @@ -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'])): diff --git a/sickbeard/providers/dh.py b/sickbeard/providers/dh.py index fb3a29c1..9eb22ec1 100644 --- a/sickbeard/providers/dh.py +++ b/sickbeard/providers/dh.py @@ -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 diff --git a/sickbeard/providers/extratorrent.py b/sickbeard/providers/extratorrent.py index 23154d59..11806bd8 100644 --- a/sickbeard/providers/extratorrent.py +++ b/sickbeard/providers/extratorrent.py @@ -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 diff --git a/sickbeard/providers/fano.py b/sickbeard/providers/fano.py index 7ab48722..140b8075 100644 --- a/sickbeard/providers/fano.py +++ b/sickbeard/providers/fano.py @@ -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 diff --git a/sickbeard/providers/filelist.py b/sickbeard/providers/filelist.py index 545d2e11..78b2328b 100644 --- a/sickbeard/providers/filelist.py +++ b/sickbeard/providers/filelist.py @@ -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 diff --git a/sickbeard/providers/freshontv.py b/sickbeard/providers/freshontv.py index 297cf8bf..91d91e61 100644 --- a/sickbeard/providers/freshontv.py +++ b/sickbeard/providers/freshontv.py @@ -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 diff --git a/sickbeard/providers/funfile.py b/sickbeard/providers/funfile.py index a5d18646..0bd400af 100644 --- a/sickbeard/providers/funfile.py +++ b/sickbeard/providers/funfile.py @@ -16,6 +16,7 @@ # along with SickGear. If not, see . 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 diff --git a/sickbeard/providers/generic.py b/sickbeard/providers/generic.py index d3246509..2edad3a6 100644 --- a/sickbeard/providers/generic.py +++ b/sickbeard/providers/generic.py @@ -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') diff --git a/sickbeard/providers/gftracker.py b/sickbeard/providers/gftracker.py index 24ca21ae..2510c77b 100644 --- a/sickbeard/providers/gftracker.py +++ b/sickbeard/providers/gftracker.py @@ -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 diff --git a/sickbeard/providers/grabtheinfo.py b/sickbeard/providers/grabtheinfo.py index 7922c5a0..bde8a422 100644 --- a/sickbeard/providers/grabtheinfo.py +++ b/sickbeard/providers/grabtheinfo.py @@ -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 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 diff --git a/sickbeard/providers/hdspace.py b/sickbeard/providers/hdspace.py index c29d9503..6083ee4c 100644 --- a/sickbeard/providers/hdspace.py +++ b/sickbeard/providers/hdspace.py @@ -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 diff --git a/sickbeard/providers/hdtorrents.py b/sickbeard/providers/hdtorrents.py index bc85bca0..ce2ea8b3 100644 --- a/sickbeard/providers/hdtorrents.py +++ b/sickbeard/providers/hdtorrents.py @@ -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() diff --git a/sickbeard/providers/iptorrents.py b/sickbeard/providers/iptorrents.py index 72fd2cb6..2434c3fa 100644 --- a/sickbeard/providers/iptorrents.py +++ b/sickbeard/providers/iptorrents.py @@ -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 diff --git a/sickbeard/providers/limetorrents.py b/sickbeard/providers/limetorrents.py index 280b70a3..18828dd5 100644 --- a/sickbeard/providers/limetorrents.py +++ b/sickbeard/providers/limetorrents.py @@ -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 diff --git a/sickbeard/providers/morethan.py b/sickbeard/providers/morethan.py index 69410949..c98ee8e2 100644 --- a/sickbeard/providers/morethan.py +++ b/sickbeard/providers/morethan.py @@ -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 diff --git a/sickbeard/providers/pisexy.py b/sickbeard/providers/pisexy.py index 439aa856..5fe5cf01 100644 --- a/sickbeard/providers/pisexy.py +++ b/sickbeard/providers/pisexy.py @@ -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 diff --git a/sickbeard/providers/privatehd.py b/sickbeard/providers/privatehd.py index e0ba5b17..af701e45 100644 --- a/sickbeard/providers/privatehd.py +++ b/sickbeard/providers/privatehd.py @@ -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 diff --git a/sickbeard/providers/ptf.py b/sickbeard/providers/ptf.py index 6d51ac8d..35929dd3 100644 --- a/sickbeard/providers/ptf.py +++ b/sickbeard/providers/ptf.py @@ -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 diff --git a/sickbeard/providers/revtt.py b/sickbeard/providers/revtt.py index 90e9f882..4d4a491e 100644 --- a/sickbeard/providers/revtt.py +++ b/sickbeard/providers/revtt.py @@ -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 diff --git a/sickbeard/providers/scenetime.py b/sickbeard/providers/scenetime.py index 82f6a6e7..35a5ce32 100644 --- a/sickbeard/providers/scenetime.py +++ b/sickbeard/providers/scenetime.py @@ -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 diff --git a/sickbeard/providers/shazbat.py b/sickbeard/providers/shazbat.py index bcdf1876..4bbeeec0 100644 --- a/sickbeard/providers/shazbat.py +++ b/sickbeard/providers/shazbat.py @@ -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 diff --git a/sickbeard/providers/speedcd.py b/sickbeard/providers/speedcd.py index 5ed35fa6..2aac1c14 100644 --- a/sickbeard/providers/speedcd.py +++ b/sickbeard/providers/speedcd.py @@ -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 diff --git a/sickbeard/providers/thepiratebay.py b/sickbeard/providers/thepiratebay.py index 6ad41806..e1ab2c51 100644 --- a/sickbeard/providers/thepiratebay.py +++ b/sickbeard/providers/thepiratebay.py @@ -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 diff --git a/sickbeard/providers/torlock.py b/sickbeard/providers/torlock.py index 89205f22..ceab716a 100644 --- a/sickbeard/providers/torlock.py +++ b/sickbeard/providers/torlock.py @@ -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'])): diff --git a/sickbeard/providers/torrentbytes.py b/sickbeard/providers/torrentbytes.py index 1de627a0..0a8eeb1f 100644 --- a/sickbeard/providers/torrentbytes.py +++ b/sickbeard/providers/torrentbytes.py @@ -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 diff --git a/sickbeard/providers/torrentday.py b/sickbeard/providers/torrentday.py index 003e063b..bb6c7f21 100644 --- a/sickbeard/providers/torrentday.py +++ b/sickbeard/providers/torrentday.py @@ -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 diff --git a/sickbeard/providers/torrenting.py b/sickbeard/providers/torrenting.py index e262ec33..b2f3a5c6 100644 --- a/sickbeard/providers/torrenting.py +++ b/sickbeard/providers/torrenting.py @@ -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 diff --git a/sickbeard/providers/torrentleech.py b/sickbeard/providers/torrentleech.py index 420bae0c..bdc1f336 100644 --- a/sickbeard/providers/torrentleech.py +++ b/sickbeard/providers/torrentleech.py @@ -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 diff --git a/sickbeard/providers/torrentshack.py b/sickbeard/providers/torrentshack.py index de6c15a5..c3ab0e0e 100644 --- a/sickbeard/providers/torrentshack.py +++ b/sickbeard/providers/torrentshack.py @@ -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 diff --git a/sickbeard/providers/torrentz2.py b/sickbeard/providers/torrentz2.py index 3c20c308..5b140d29 100644 --- a/sickbeard/providers/torrentz2.py +++ b/sickbeard/providers/torrentz2.py @@ -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 diff --git a/sickbeard/providers/tvchaosuk.py b/sickbeard/providers/tvchaosuk.py index f80c7728..041be9eb 100644 --- a/sickbeard/providers/tvchaosuk.py +++ b/sickbeard/providers/tvchaosuk.py @@ -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']) diff --git a/sickbeard/providers/zooqle.py b/sickbeard/providers/zooqle.py index d4d017b6..8dd7450d 100644 --- a/sickbeard/providers/zooqle.py +++ b/sickbeard/providers/zooqle.py @@ -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