diff --git a/modules/isohunt/pages/torrents.py b/modules/isohunt/pages/torrents.py index 5b2b2d1b..79a99547 100644 --- a/modules/isohunt/pages/torrents.py +++ b/modules/isohunt/pages/torrents.py @@ -21,6 +21,7 @@ from weboob.capabilities.torrent import Torrent from weboob.tools.browser import BasePage from weboob.tools.misc import get_bytes_size +from weboob.capabilities.base import NotAvailable __all__ = ['TorrentsPage'] @@ -65,27 +66,29 @@ class TorrentsPage(BasePage): class TorrentPage(BasePage): def get_torrent(self, id): title = '' + size = NotAvailable url = 'https://isohunt.com/download/%s/%s.torrent' % (id, id) for a in self.document.getiterator('a'): if 'Search more torrents of' in a.attrib.get('title', ''): title = a.tail - seed = -1 - leech = -1 + seed = NotAvailable + leech = NotAvailable tip_id = "none" for span in self.document.getiterator('span'): if span.attrib.get('style', '') == 'color:green;' and ('ShowTip' in span.attrib.get('onmouseover', '')): - seed = span.tail.split(' ')[1] + seed = int(span.tail.split(' ')[1]) tip_id = span.attrib.get('onmouseover', '').split("'")[1] for div in self.document.getiterator('div'): # find the corresponding super tip which appears on super mouse hover! if div.attrib.get('class', '') == 'dirs ydsf' and tip_id in div.attrib.get('id', ''): - leech = div.getchildren()[0].getchildren()[1].tail.split(' ')[2] + leech = int(div.getchildren()[0].getchildren()[1].tail.split(' ')[2]) # the with the size in it doesn't have a distinction # have to get it by higher elif div.attrib.get('id', '') == 'torrent_details': size = div.getchildren()[6].getchildren()[0].getchildren()[0].text u = size[-2:] size = float(size[:-3]) + size = get_bytes_size(size, u) # files and description (uploader's comment) description = 'No description' @@ -115,9 +118,9 @@ class TorrentPage(BasePage): torrent = Torrent(id, title) torrent.url = url - torrent.size = get_bytes_size(size, u) - torrent.seeders = int(seed) - torrent.leechers = int(leech) + torrent.size = size + torrent.seeders = seed + torrent.leechers = leech torrent.description = description torrent.files = files return torrent diff --git a/modules/kickass/backend.py b/modules/kickass/backend.py index f1eb7ffa..d398e848 100644 --- a/modules/kickass/backend.py +++ b/modules/kickass/backend.py @@ -17,7 +17,7 @@ # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . -from weboob.capabilities.torrent import ICapTorrent +from weboob.capabilities.torrent import ICapTorrent, Torrent from weboob.tools.backend import BaseBackend from .browser import KickassBrowser @@ -61,3 +61,12 @@ class KickassBackend(BaseBackend, ICapTorrent): def iter_torrents(self, pattern): return self.browser.iter_torrents(quote_plus(pattern.encode('utf-8'))) + + def fill_torrent(self, torrent, fields): + print "plpl" + if 'description' in fields or fields == None: + return self.get_torrent(torrent.id) + + OBJECTS = { + Torrent:fill_torrent + } diff --git a/weboob/applications/weboorrents/weboorrents.py b/weboob/applications/weboorrents/weboorrents.py index 87b66440..0feb211b 100644 --- a/weboob/applications/weboorrents/weboorrents.py +++ b/weboob/applications/weboorrents/weboorrents.py @@ -95,8 +95,14 @@ class Weboorrents(ReplApplication): Get information about a torrent. """ - - torrent = self.get_object(id, 'get_torrent') + # Following commented line could be better + #torrent = self.get_object(id, 'get_torrent', ('description','files')) + torrent = None + _id, backend = self.parse_id(id) + for _backend, result in self.do('get_torrent', _id, backends=backend, caps=ICapTorrent): + if result: + backend = _backend + torrent = result if not torrent: print >>sys.stderr, 'Torrent not found: %s' % id return 3