From 843e98e262e6bd44b192390af7f7451b2071021e Mon Sep 17 00:00:00 2001 From: Julien Veyssier Date: Tue, 11 Jan 2011 23:06:04 +0100 Subject: [PATCH] [piratebay] fix parsing to find leecher and seeders (closes #458) --- weboob/backends/piratebay/pages/torrents.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/weboob/backends/piratebay/pages/torrents.py b/weboob/backends/piratebay/pages/torrents.py index aed406fe..24000353 100644 --- a/weboob/backends/piratebay/pages/torrents.py +++ b/weboob/backends/piratebay/pages/torrents.py @@ -78,11 +78,18 @@ class TorrentPage(BasePage): size = float(div.getchildren()[0].getchildren()[5].text.split('(')[1].split('Bytes')[0]) if len(div.getchildren()) > 1 \ and div.getchildren()[1].attrib.get('class','') == 'col2' : - seed = div.getchildren()[1].getchildren()[7].text - leech = div.getchildren()[1].getchildren()[9].text + child_to_explore = div.getchildren()[1] else: - seed = div.getchildren()[0].getchildren()[24].text - leech = div.getchildren()[0].getchildren()[26].text + child_to_explore = div.getchildren()[0] + prev_child_txt = "none" + seed="-1" + leech="-1" + for ch in child_to_explore.getchildren(): + if prev_child_txt == "Seeders:": + seed = ch.text + if prev_child_txt == "Leechers:": + leech = ch.text + prev_child_txt = ch.text elif div.attrib.get('class','') == 'nfo': description = div.getchildren()[0].text torrent = Torrent(id, title)