[isohunt] small corrections

This commit is contained in:
Julien Veyssier 2013-03-10 00:33:00 +01:00
commit fe5499c8ac
2 changed files with 9 additions and 9 deletions

View file

@ -38,9 +38,9 @@ class TorrentsPage(BasePage):
seed = NotAvailable seed = NotAvailable
leech = NotAvailable leech = NotAvailable
atitle = tr.getchildren()[2].getchildren()[1] atitle = tr.getchildren()[2].getchildren()[1]
title = atitle.text title = unicode(atitle.text)
if not title: if not title:
title = '' title = u''
for bold in atitle.getchildren(): for bold in atitle.getchildren():
if bold.text: if bold.text:
title += bold.text title += bold.text
@ -57,7 +57,7 @@ class TorrentsPage(BasePage):
seed = int(sseed) seed = int(sseed)
if sleech != None and sleech != "": if sleech != None and sleech != "":
leech = int(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 = Torrent(idt, title)
torrent.url = url torrent.url = url
torrent.size = get_bytes_size(size, u) torrent.size = get_bytes_size(size, u)
@ -70,12 +70,12 @@ class TorrentsPage(BasePage):
class TorrentPage(BasePage): class TorrentPage(BasePage):
def get_torrent(self, id): def get_torrent(self, id):
title = '' title = NotAvailable
size = NotAvailable size = NotAvailable
url = 'https://isohunt.com/download/%s/%s.torrent' % (id, id) url = 'https://isohunt.com/download/%s/%s.torrent' % (id, id)
for a in self.document.getiterator('a'): for a in self.document.getiterator('a'):
if 'Search more torrents of' in a.attrib.get('title', ''): if 'Search more torrents of' in a.attrib.get('title', ''):
title = a.tail title = unicode(a.tail)
seed = NotAvailable seed = NotAvailable
leech = NotAvailable leech = NotAvailable
tip_id = "none" tip_id = "none"
@ -104,7 +104,7 @@ class TorrentPage(BasePage):
count_p_found += 1 count_p_found += 1
if count_p_found == 1: if count_p_found == 1:
if p.getchildren()[1].tail != None: if p.getchildren()[1].tail != None:
description = p.getchildren()[1].tail description = unicode(p.getchildren()[1].tail)
if count_p_found == 2: if count_p_found == 2:
if p.getchildren()[0].text == 'Directory:': if p.getchildren()[0].text == 'Directory:':
files.append(p.getchildren()[0].tail.strip() + '/') files.append(p.getchildren()[0].tail.strip() + '/')
@ -119,8 +119,6 @@ class TorrentPage(BasePage):
filename += slash.tail filename += slash.tail
files.append(filename) files.append(filename)
#--------------------------TODO
torrent = Torrent(id, title) torrent = Torrent(id, title)
torrent.url = url torrent.url = url
torrent.size = size torrent.size = size

View file

@ -25,6 +25,7 @@ from weboob.capabilities.torrent import ICapTorrent, MagnetOnly
from weboob.tools.application.repl import ReplApplication from weboob.tools.application.repl import ReplApplication
from weboob.tools.application.formatters.iformatter import IFormatter, PrettyFormatter from weboob.tools.application.formatters.iformatter import IFormatter, PrettyFormatter
from weboob.core import CallErrors from weboob.core import CallErrors
from weboob.capabilities.base import NotAvailable
__all__ = ['Weboorrents'] __all__ = ['Weboorrents']
@ -43,7 +44,8 @@ class TorrentInfoFormatter(IFormatter):
def format_obj(self, obj, alias): def format_obj(self, obj, alias):
result = u'%s%s%s\n' % (self.BOLD, obj.name, self.NC) result = u'%s%s%s\n' % (self.BOLD, obj.name, self.NC)
result += 'ID: %s\n' % obj.fullid 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 += 'Seeders: %s\n' % obj.seeders
result += 'Leechers: %s\n' % obj.leechers result += 'Leechers: %s\n' % obj.leechers
result += 'URL: %s\n' % obj.url result += 'URL: %s\n' % obj.url