From de3f137d859520352337137ca0617198c91c7b41 Mon Sep 17 00:00:00 2001 From: Romain Bignon Date: Sun, 5 Feb 2012 17:53:44 +0100 Subject: [PATCH] fix kickass --- modules/kickass/browser.py | 12 ++++++------ modules/kickass/pages/torrents.py | 10 +++++++--- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/modules/kickass/browser.py b/modules/kickass/browser.py index 8eee75b80e..a38661d4d9 100644 --- a/modules/kickass/browser.py +++ b/modules/kickass/browser.py @@ -27,24 +27,24 @@ class KickassBrowser(BaseBrowser): - DOMAIN = 'kickasstorrents.com' + DOMAIN = 'kat.ph' PROTOCOL = 'http' ENCODING = 'utf-8' USER_AGENT = BaseBrowser.USER_AGENTS['wget'] PAGES = { - 'http://fr.(kickasstorrents.com|kat.ph)/new/.*field=seeders&sorder=desc': TorrentsPage, - 'http://fr.(kickasstorrents.com|kat.ph)/.*.html': TorrentPage, + 'http://kat.ph/new/.*field=seeders&sorder=desc': TorrentsPage, + 'http://kat.ph/.*.html': TorrentPage, } def home(self): - return self.location('http://kickasstorrents.com') + return self.location('http://kat.ph') def iter_torrents(self, pattern): - self.location('http://fr.kickasstorrents.com/new/?q=%s&field=seeders&sorder=desc' % pattern.encode('utf-8')) + self.location('http://kat.ph/new/?q=%s&field=seeders&sorder=desc' % pattern.encode('utf-8')) assert self.is_on_page(TorrentsPage) return self.page.iter_torrents() def get_torrent(self, id): - self.location('http://fr.kickasstorrents.com/%s.html' % id) + self.location('http://kat.ph/%s.html' % id) assert self.is_on_page(TorrentPage) return self.page.get_torrent(id) diff --git a/modules/kickass/pages/torrents.py b/modules/kickass/pages/torrents.py index 5b4e59ecc4..8700f9617b 100644 --- a/modules/kickass/pages/torrents.py +++ b/modules/kickass/pages/torrents.py @@ -25,6 +25,7 @@ from urlparse import urlsplit from weboob.capabilities.torrent import Torrent +from weboob.capabilities.base import NotAvailable from weboob.tools.browser import BasePage from weboob.tools.misc import get_bytes_size @@ -71,8 +72,9 @@ class TorrentPage(BasePage): def get_torrent(self, id): seed = 0 leech = 0 - description = 'No description' - url = 'No Url found' + description = NotAvailable + url = NotAvailable + title = NotAvailable for div in self.document.getiterator('div'): if div.attrib.get('id', '') == 'desc': try: @@ -99,6 +101,7 @@ def get_torrent(self, id): url = a.attrib.get('href', '') size = 0 + u = '' for span in self.document.getiterator('span'): # sometimes there are others span, this is not so sure but the size of the children list # is enough to know if this is the right span @@ -114,7 +117,8 @@ def get_torrent(self, id): torrent = Torrent(id, title) torrent.url = url - torrent.filename = parse_qs(urlsplit(url).query).get('title', [None])[0] + if torrent.url: + torrent.filename = parse_qs(urlsplit(url).query).get('title', [None])[0] torrent.size = get_bytes_size(size, u) torrent.seeders = int(seed) torrent.leechers = int(leech) -- GitLab