Commit de3f137d authored by Romain Bignon's avatar Romain Bignon

fix kickass

parent dfb52a26
......@@ -27,24 +27,24 @@ __all__ = ['KickassBrowser']
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)
......@@ -25,6 +25,7 @@ except ImportError:
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 @@ class TorrentPage(BasePage):
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 @@ class TorrentPage(BasePage):
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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment