From c9d40ffb44483dec9c55dff1590dbb67dc6cd8fb Mon Sep 17 00:00:00 2001 From: Romain Bignon Date: Mon, 4 Jul 2011 15:15:23 +0200 Subject: [PATCH] fix parsing of file lists on some gazelle websites --- weboob/backends/gazelle/pages/torrents.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/weboob/backends/gazelle/pages/torrents.py b/weboob/backends/gazelle/pages/torrents.py index 0dbdf548..ebe6ef64 100644 --- a/weboob/backends/gazelle/pages/torrents.py +++ b/weboob/backends/gazelle/pages/torrents.py @@ -194,11 +194,15 @@ class TorrentsPage(BasePage): torrent.description = u'' torrent.description += u'%s\n\n%s\n' % (title, body) - div = self.document.getroot().cssselect('div#files_%s,div#filelist_%s,tr#torrent_%s td' % (torrentid, torrentid, torrentid)) - if div: + divs = self.document.getroot().cssselect('div#files_%s,div#filelist_%s,tr#torrent_%s td' % (torrentid, torrentid, torrentid)) + if divs: torrent.files = [] - for tr in div[0].find('table'): - if tr.attrib.get('class', None) != 'colhead_dark': - torrent.files.append(tr.find('td').text) + for div in divs: + table = div.find('table') + if table is None: + continue + for tr in table: + if tr.attrib.get('class', None) != 'colhead_dark': + torrent.files.append(tr.find('td').text) return torrent