Put Thumbnail in a tools.capabilities
This commit is contained in:
parent
ecb076d9b5
commit
afe5db74b4
6 changed files with 44 additions and 40 deletions
|
|
@ -19,27 +19,12 @@
|
|||
|
||||
from datetime import datetime
|
||||
|
||||
from weboob.tools.capabilities.thumbnail import Thumbnail
|
||||
from .base import IBaseCap, CapBaseObject, NotLoaded
|
||||
|
||||
__all__ = ['Thumbnail', 'ICapGallery', 'BaseGallery', 'BaseImage']
|
||||
|
||||
|
||||
class Thumbnail(CapBaseObject):
|
||||
def __init__(self, url):
|
||||
CapBaseObject.__init__(self, url)
|
||||
self.add_field('url', basestring, url.replace(' ', '%20'))
|
||||
self.add_field('data', str)
|
||||
|
||||
def __str__(self):
|
||||
return self.url
|
||||
|
||||
def __repr__(self):
|
||||
return '<Thumbnail url="%s">' % self.url
|
||||
|
||||
def __iscomplete__(self):
|
||||
return self.data is not NotLoaded
|
||||
|
||||
|
||||
class BaseGallery(CapBaseObject):
|
||||
"""
|
||||
Represents a gallery.
|
||||
|
|
|
|||
|
|
@ -21,27 +21,11 @@
|
|||
from datetime import datetime, timedelta
|
||||
|
||||
from .base import IBaseCap, CapBaseObject, NotLoaded
|
||||
from weboob.tools.capabilities.thumbnail import Thumbnail
|
||||
|
||||
|
||||
__all__ = ['BaseVideo', 'ICapVideo']
|
||||
|
||||
|
||||
class VideoThumbnail(CapBaseObject):
|
||||
def __init__(self, url):
|
||||
CapBaseObject.__init__(self, url)
|
||||
self.add_field('url', basestring, url.replace(' ', '%20'))
|
||||
self.add_field('data', str)
|
||||
|
||||
def __str__(self):
|
||||
return self.url
|
||||
|
||||
def __repr__(self):
|
||||
return '<Thumbnail url="%s">' % self.url
|
||||
|
||||
def __iscomplete__(self):
|
||||
return self.data is not NotLoaded
|
||||
|
||||
|
||||
class BaseVideo(CapBaseObject):
|
||||
"""
|
||||
Represents a video.
|
||||
|
|
@ -60,12 +44,12 @@ class BaseVideo(CapBaseObject):
|
|||
self.add_field('date', datetime, date)
|
||||
self.add_field('rating', (int,long,float), rating)
|
||||
self.add_field('rating_max', (int,long,float), rating_max)
|
||||
self.add_field('thumbnail', VideoThumbnail, thumbnail)
|
||||
self.add_field('thumbnail', Thumbnail, thumbnail)
|
||||
self.add_field('nsfw', bool, nsfw)
|
||||
|
||||
# XXX remove this and fix all backends
|
||||
if thumbnail_url is not None and self.thumbnail is NotLoaded:
|
||||
self.thumbnail = VideoThumbnail(thumbnail_url)
|
||||
self.thumbnail = Thumbnail(thumbnail_url)
|
||||
|
||||
@classmethod
|
||||
def id2url(cls, _id):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue