[weboorrents] cleaning get_object

This commit is contained in:
Julien Veyssier 2013-03-10 00:03:04 +01:00
commit e8a788cb00
3 changed files with 8 additions and 13 deletions

View file

@ -63,7 +63,6 @@ class KickassBackend(BaseBackend, ICapTorrent):
return self.browser.iter_torrents(quote_plus(pattern.encode('utf-8'))) return self.browser.iter_torrents(quote_plus(pattern.encode('utf-8')))
def fill_torrent(self, torrent, fields): def fill_torrent(self, torrent, fields):
print "plpl"
if 'description' in fields or fields == None: if 'description' in fields or fields == None:
return self.get_torrent(torrent.id) return self.get_torrent(torrent.id)

View file

@ -26,7 +26,7 @@ except ImportError:
from urlparse import urlsplit from urlparse import urlsplit
from weboob.capabilities.torrent import Torrent from weboob.capabilities.torrent import Torrent
from weboob.capabilities.base import NotAvailable from weboob.capabilities.base import NotAvailable, NotLoaded
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
@ -70,7 +70,8 @@ class TorrentsPage(BasePage):
torrent = Torrent(idt, title) torrent = Torrent(idt, title)
torrent.url = url torrent.url = url
torrent.magnet = magnet torrent.magnet = magnet
torrent.description = NotAvailable.__unicode__() torrent.description = NotLoaded
torrent.files = NotLoaded
torrent.filename = parse_qs(urlsplit(url).query).get('title', [None])[0] torrent.filename = parse_qs(urlsplit(url).query).get('title', [None])[0]
torrent.size = get_bytes_size(size, u) torrent.size = get_bytes_size(size, u)
torrent.seeders = int(seed) torrent.seeders = int(seed)
@ -82,7 +83,7 @@ class TorrentPage(BasePage):
def get_torrent(self, id): def get_torrent(self, id):
seed = 0 seed = 0
leech = 0 leech = 0
description = NotAvailable.__unicode__() description = NotAvailable
url = NotAvailable url = NotAvailable
magnet = NotAvailable magnet = NotAvailable
title = NotAvailable title = NotAvailable
@ -142,6 +143,8 @@ class TorrentPage(BasePage):
torrent.size = get_bytes_size(size, u) torrent.size = get_bytes_size(size, u)
torrent.seeders = int(seed) torrent.seeders = int(seed)
torrent.leechers = int(leech) torrent.leechers = int(leech)
if description == '':
description = NotAvailable
torrent.description = description torrent.description = description
torrent.files = files torrent.files = files
return torrent return torrent

View file

@ -54,7 +54,7 @@ class TorrentInfoFormatter(IFormatter):
for f in obj.files: for f in obj.files:
result += ' * %s\n' % f result += ' * %s\n' % f
result += '\n%sDescription%s\n' % (self.BOLD, self.NC) result += '\n%sDescription%s\n' % (self.BOLD, self.NC)
result += obj.description result += '%s'%obj.description
return result return result
@ -95,14 +95,7 @@ class Weboorrents(ReplApplication):
Get information about a torrent. Get information about a torrent.
""" """
# Following commented line could be better torrent = self.get_object(id, 'get_torrent', ('description','files'))
#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: if not torrent:
print >>sys.stderr, 'Torrent not found: %s' % id print >>sys.stderr, 'Torrent not found: %s' % id
return 3 return 3