From fe5499c8accfbe53f85e4e6f152f7fbd57fe1a9d Mon Sep 17 00:00:00 2001 From: Julien Veyssier Date: Sun, 10 Mar 2013 00:33:00 +0100 Subject: [PATCH] [isohunt] small corrections --- modules/isohunt/pages/torrents.py | 14 ++++++-------- weboob/applications/weboorrents/weboorrents.py | 4 +++- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/modules/isohunt/pages/torrents.py b/modules/isohunt/pages/torrents.py index 29124769..e0aacadc 100644 --- a/modules/isohunt/pages/torrents.py +++ b/modules/isohunt/pages/torrents.py @@ -38,9 +38,9 @@ class TorrentsPage(BasePage): seed = NotAvailable leech = NotAvailable atitle = tr.getchildren()[2].getchildren()[1] - title = atitle.text + title = unicode(atitle.text) if not title: - title = '' + title = u'' for bold in atitle.getchildren(): if bold.text: title += bold.text @@ -57,7 +57,7 @@ class TorrentsPage(BasePage): seed = int(sseed) if sleech != None and sleech != "": leech = int(sleech) - url = 'https://isohunt.com/download/%s/mon_joli_torrent.torrent' % idt + url = u'https://isohunt.com/download/%s/mon_joli_torrent.torrent' % idt torrent = Torrent(idt, title) torrent.url = url torrent.size = get_bytes_size(size, u) @@ -70,12 +70,12 @@ class TorrentsPage(BasePage): class TorrentPage(BasePage): def get_torrent(self, id): - title = '' + title = NotAvailable 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 + title = unicode(a.tail) seed = NotAvailable leech = NotAvailable tip_id = "none" @@ -104,7 +104,7 @@ class TorrentPage(BasePage): count_p_found += 1 if count_p_found == 1: if p.getchildren()[1].tail != None: - description = p.getchildren()[1].tail + description = unicode(p.getchildren()[1].tail) if count_p_found == 2: if p.getchildren()[0].text == 'Directory:': files.append(p.getchildren()[0].tail.strip() + '/') @@ -119,8 +119,6 @@ class TorrentPage(BasePage): filename += slash.tail files.append(filename) - #--------------------------TODO - torrent = Torrent(id, title) torrent.url = url torrent.size = size diff --git a/weboob/applications/weboorrents/weboorrents.py b/weboob/applications/weboorrents/weboorrents.py index 5f3299a9..7f341f0f 100644 --- a/weboob/applications/weboorrents/weboorrents.py +++ b/weboob/applications/weboorrents/weboorrents.py @@ -25,6 +25,7 @@ from weboob.capabilities.torrent import ICapTorrent, MagnetOnly from weboob.tools.application.repl import ReplApplication from weboob.tools.application.formatters.iformatter import IFormatter, PrettyFormatter from weboob.core import CallErrors +from weboob.capabilities.base import NotAvailable __all__ = ['Weboorrents'] @@ -43,7 +44,8 @@ class TorrentInfoFormatter(IFormatter): def format_obj(self, obj, alias): result = u'%s%s%s\n' % (self.BOLD, obj.name, self.NC) result += 'ID: %s\n' % obj.fullid - result += 'Size: %s\n' % sizeof_fmt(obj.size) + if obj.size != NotAvailable: + result += 'Size: %s\n' % sizeof_fmt(obj.size) result += 'Seeders: %s\n' % obj.seeders result += 'Leechers: %s\n' % obj.leechers result += 'URL: %s\n' % obj.url