From d05b8f959a502867a4fba282dd687254e6398784 Mon Sep 17 00:00:00 2001 From: Julien Veyssier Date: Thu, 28 Feb 2013 00:46:40 +0100 Subject: [PATCH] [kickass] Fix download URL and magnet support in all iter_torrents --- modules/kickass/pages.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/modules/kickass/pages.py b/modules/kickass/pages.py index b6f0b255..b4e46e46 100644 --- a/modules/kickass/pages.py +++ b/modules/kickass/pages.py @@ -38,6 +38,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': + magnet = NotAvailable + url = NotAvailable if not 'id' in tr.attrib: continue title = tr.getchildren()[0].getchildren()[1].getchildren()[1].text @@ -49,11 +51,14 @@ class TorrentsPage(BasePage): .replace('.html', '') # look for url - for a in tr.getchildren()[0].getiterator('a'): - if '.torrent' in a.attrib.get('href', ''): - url = a.attrib['href'] - if url.startswith('//'): - url = 'http:%s'%url + for a in self.parser.select(tr,'div.iaconbox a'): + href = a.attrib.get('href', '') + if href.startswith('magnet'): + magnet = href + elif href.startswith('http'): + url = href + elif href.startswith('//'): + url = 'http:%s'%href size = tr.getchildren()[1].text u = tr.getchildren()[1].getchildren()[0].text @@ -64,6 +69,7 @@ class TorrentsPage(BasePage): torrent = Torrent(idt, title) torrent.url = url + torrent.magnet = magnet torrent.description = NotAvailable.__unicode__() torrent.filename = parse_qs(urlsplit(url).query).get('title', [None])[0] torrent.size = get_bytes_size(size, u)