Skip to content

Commit

Permalink
Fix ET parsing with daily search (#1136)
Browse files Browse the repository at this point in the history
  • Loading branch information
medariox authored and fernandog committed Sep 18, 2016
1 parent 6966c62 commit 929f1f0
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions sickbeard/providers/torrent/html/extratorrent.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,25 +111,29 @@ def parse(self, data, mode):
:param mode: The current mode used to search, e.g. RSS
:return: A list of items found
"""
# RSS search has one less column
decrease = 1 if mode == 'RSS' else 0

items = []

with BS4Parser(data, 'html5lib') as html:
torrent_table = html.find('table', class_='tl')
torrent_rows = torrent_table('tr') if torrent_table else []

# Continue only if at least one release is found
if torrent_rows < 3 or (torrent_rows == 3 and torrent_rows[2].get_text() == 'No torrents'):
if len(torrent_rows) < 3 or (torrent_rows == 3 and torrent_rows[2].get_text() == 'No torrents'):
logger.log('Data returned from provider does not contain any torrents', logger.DEBUG)
return items

# RSS search has one less column
decrease = 1

# Avoid parsing of 'related torrents'
h2s = html.find_all('h2')
if h2s > 2 and h2s[1].get_text() == 'Related torrents':
logger.log('Data returned from provider does not contain any torrents', logger.DEBUG)
return items
if mode != 'RSS':
h2s = html.find_all('h2')
if len(h2s) > 2 and h2s[1].get_text() == 'Related torrents':
logger.log('Data returned from provider does not contain any torrents', logger.DEBUG)
return items

# Don't decrease column
decrease = 0

# Skip column headers
for result in torrent_rows[2:]:
Expand Down

0 comments on commit 929f1f0

Please sign in to comment.