Private GIT

Skip to content
Snippets Groups Projects
Commit 4437624a authored by miigotu's avatar miigotu
Browse files

Move try/catch in ettv, fix typo in torrentleech

parent d8ba2baa
No related branches found
No related tags found
No related merge requests found
......@@ -18,7 +18,6 @@
# along with SickRage. If not, see <http://www.gnu.org/licenses/>.
import re
import traceback
import sickbeard
from sickbeard import logger
from sickbeard import tvcache
......@@ -74,18 +73,21 @@ class ExtraTorrentProvider(TorrentProvider): # pylint: disable=too-many-instanc
with BS4Parser(data, 'html5lib') as parser:
for item in parser.findAll('item'):
try:
title = re.sub(r'^<!\[CDATA\[|\]\]>$', '', item.find('title').get_text(strip=True)) if item.find('title') else None
size = try_int(item.find('size').get_text(strip=True), -1) if item.find('size') else -1
seeders = try_int(item.find('seeders').get_text(strip=True)) if item.find('seeders') else 0
leechers = try_int(item.find('leechers').get_text(strip=True)) if item.find('leechers') else 0
title = re.sub(r'^<!\[CDATA\[|\]\]>$', '', item.find('title').get_text(strip=True))
size = try_int(item.find('size').get_text(strip=True), -1)
seeders = try_int(item.find('seeders').get_text(strip=True))
leechers = try_int(item.find('leechers').get_text(strip=True))
if sickbeard.TORRENT_METHOD == 'blackhole':
enclosure = item.find('enclosure') # Backlog doesnt have enclosure
download_url = enclosure['url'] if enclosure else item.find('link').next.strip()
download_url = re.sub(r'(.*)/torrent/(.*).html', r'\1/download/\2.torrent', download_url)
else:
info_hash = item.find('info_hash').get_text(strip=True) if item.find('info_hash') else None
download_url = "magnet:?xt=urn:btih:" + info_hash + "&dn=" + title + self._custom_trackers if info_hash and title else None
info_hash = item.find('info_hash').get_text(strip=True)
download_url = "magnet:?xt=urn:btih:" + info_hash + "&dn=" + title + self._custom_trackers
except (AttributeError, TypeError, KeyError, ValueError):
continue
if not all([title, download_url]):
continue
......@@ -102,9 +104,6 @@ class ExtraTorrentProvider(TorrentProvider): # pylint: disable=too-many-instanc
items[mode].append(item)
except (AttributeError, TypeError, KeyError, ValueError):
logger.log(u"Failed parsing provider. Traceback: %r" % traceback.format_exc(), logger.WARNING)
# For each search mode sort all the items by seeders if available
items[mode].sort(key=lambda tup: tup[3], reverse=True)
......
......@@ -116,7 +116,7 @@ class TorrentLeechProvider(TorrentProvider):
seeders = try_int(result.find('td', class_='seeders').get_text(strip=True))
leechers = try_int(result.find('td', class_='leechers').get_text(strip=True))
size = self._convertSize(result.find_all('td')[labels.indexof('Size')].get_text(strip=True))
size = self._convertSize(result.find_all('td')[labels.index('Size')].get_text(strip=True))
except (AttributeError, TypeError, KeyError, ValueError):
continue
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment