From e829406c787e94a2ac292df2e8d99c3f2b728ba1 Mon Sep 17 00:00:00 2001 From: Romain Bignon Date: Tue, 31 May 2011 09:09:01 +0200 Subject: [PATCH] fix parsing torrents in results (closes #663) --- weboob/backends/kickass/pages/torrents.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/weboob/backends/kickass/pages/torrents.py b/weboob/backends/kickass/pages/torrents.py index 37c79a1b..5b4e59ec 100644 --- a/weboob/backends/kickass/pages/torrents.py +++ b/weboob/backends/kickass/pages/torrents.py @@ -36,6 +36,8 @@ class TorrentsPage(BasePage): def iter_torrents(self): for tr in self.document.getiterator('tr'): if tr.attrib.get('class', '') == 'odd' or tr.attrib.get('class', '') == ' even': + if not 'id' in tr.attrib: + continue title = tr.getchildren()[0].getchildren()[1].getchildren()[1].text if not title: title = '' @@ -45,10 +47,9 @@ class TorrentsPage(BasePage): .replace('.html', '') # look for url - child = tr.getchildren()[0] - while child.attrib.get('href', None) is None and len(child.getchildren()) > 0: - child = child.getchildren()[0] - url = child.get('href', '') + for a in tr.getchildren()[0].getiterator('a'): + if '.torrent' in a.attrib.get('href', ''): + url = a.attrib['href'] size = tr.getchildren()[1].text u = tr.getchildren()[1].getchildren()[0].text