[isohunt] fillobj integration

This commit is contained in:
Julien Veyssier 2013-03-10 00:15:33 +01:00
commit e0d1c7919d
2 changed files with 24 additions and 11 deletions

View file

@ -18,7 +18,7 @@
# along with weboob. If not, see <http://www.gnu.org/licenses/>. # along with weboob. If not, see <http://www.gnu.org/licenses/>.
from weboob.capabilities.torrent import ICapTorrent from weboob.capabilities.torrent import ICapTorrent, Torrent
from weboob.tools.backend import BaseBackend from weboob.tools.backend import BaseBackend
from .browser import IsohuntBrowser from .browser import IsohuntBrowser
@ -50,3 +50,11 @@ class IsohuntBackend(BaseBackend, ICapTorrent):
def iter_torrents(self, pattern): def iter_torrents(self, pattern):
return self.browser.iter_torrents(pattern.replace(' ','+')) return self.browser.iter_torrents(pattern.replace(' ','+'))
def fill_torrent(self, torrent, fields):
if 'description' in fields or fields == None or 'files' in fields:
return self.get_torrent(torrent.id)
OBJECTS = {
Torrent:fill_torrent
}

View file

@ -21,7 +21,7 @@
from weboob.capabilities.torrent import Torrent from weboob.capabilities.torrent import Torrent
from weboob.tools.browser import BasePage from weboob.tools.browser import BasePage
from weboob.tools.misc import get_bytes_size from weboob.tools.misc import get_bytes_size
from weboob.capabilities.base import NotAvailable from weboob.capabilities.base import NotAvailable, NotLoaded
__all__ = ['TorrentsPage'] __all__ = ['TorrentsPage']
@ -34,6 +34,9 @@ class TorrentsPage(BasePage):
# sometimes the first tr also has the attribute hlRow # sometimes the first tr also has the attribute hlRow
# i use that to ditinct it from the others # i use that to ditinct it from the others
if 'onmouseout' in tr.attrib: if 'onmouseout' in tr.attrib:
size = NotAvailable
seed = NotAvailable
leech = NotAvailable
atitle = tr.getchildren()[2].getchildren()[1] atitle = tr.getchildren()[2].getchildren()[1]
title = atitle.text title = atitle.text
if not title: if not title:
@ -48,18 +51,20 @@ class TorrentsPage(BasePage):
size = tr.getchildren()[3].text size = tr.getchildren()[3].text
u = size[-2:] u = size[-2:]
size = float(size[:-3]) size = float(size[:-3])
seed = tr.getchildren()[4].text sseed = tr.getchildren()[4].text
leech = tr.getchildren()[5].text sleech = tr.getchildren()[5].text
if sseed != None and sseed != "":
seed = int(sseed)
if sleech != None and sleech != "":
leech = int(sleech)
url = 'https://isohunt.com/download/%s/mon_joli_torrent.torrent' % idt url = '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)
if seed == None or seed == "": torrent.seeders = seed
seed = 0 torrent.leechers = leech
torrent.seeders = int(seed) torrent.description = NotLoaded
if leech == None or leech == "": torrent.files = NotLoaded
leech = 0
torrent.leechers = int(leech)
yield torrent yield torrent
@ -91,7 +96,7 @@ class TorrentPage(BasePage):
size = get_bytes_size(size, u) size = get_bytes_size(size, u)
# files and description (uploader's comment) # files and description (uploader's comment)
description = 'No description' description = NotAvailable
files = [] files = []
count_p_found = 0 count_p_found = 0
for p in self.document.getiterator('p'): for p in self.document.getiterator('p'):