diff --git a/weboob/backends/canalplus/pages/videopage.py b/weboob/backends/canalplus/pages/videopage.py index 087d7a3a..dfad147c 100644 --- a/weboob/backends/canalplus/pages/videopage.py +++ b/weboob/backends/canalplus/pages/videopage.py @@ -20,7 +20,7 @@ from datetime import datetime -from weboob.capabilities.video import VideoThumbnail +from weboob.tools.capabilities.thumbnail import Thumbnail from weboob.tools.browser import BasePage from .video import CanalplusVideo @@ -49,7 +49,7 @@ class VideoPage(BasePage): video.description = infos.find('DESCRIPTION').text media = el.find('MEDIA') - video.thumbnail = VideoThumbnail(media.find('IMAGES').find('PETIT').text) + video.thumbnail = Thumbnail(media.find('IMAGES').find('PETIT').text) lastest_format = None for format in media.find('VIDEOS'): if format.text is None: diff --git a/weboob/backends/dailymotion/pages.py b/weboob/backends/dailymotion/pages.py index fba45452..96767657 100644 --- a/weboob/backends/dailymotion/pages.py +++ b/weboob/backends/dailymotion/pages.py @@ -21,7 +21,7 @@ import datetime import urllib import re -from weboob.capabilities.video import VideoThumbnail +from weboob.tools.capabilities.thumbnail import Thumbnail from weboob.tools.misc import html2text from weboob.tools.browser import BasePage @@ -52,7 +52,7 @@ class IndexPage(BasePage): minutes, seconds = self.parser.select(div, 'div.duration', 1).text.split(':') video.duration = datetime.timedelta(minutes=int(minutes), seconds=int(seconds)) url = self.parser.select(div, 'img.dmco_image', 1).attrib['src'] - video.thumbnail = VideoThumbnail(url) + video.thumbnail = Thumbnail(url) rating_div = self.parser.select(div, 'div.small_stars', 1) video.rating_max = self.get_rate(rating_div) diff --git a/weboob/backends/ehentai/pages.py b/weboob/backends/ehentai/pages.py index 24768ae6..e90ebeb8 100644 --- a/weboob/backends/ehentai/pages.py +++ b/weboob/backends/ehentai/pages.py @@ -19,7 +19,7 @@ from weboob.tools.browser import BasePage from weboob.tools.misc import html2text -from weboob.capabilities.gallery import Thumbnail +from weboob.tools.capabilities.thumbnail import Thumbnail from datetime import datetime import re diff --git a/weboob/capabilities/gallery.py b/weboob/capabilities/gallery.py index 05352332..a01bfee4 100644 --- a/weboob/capabilities/gallery.py +++ b/weboob/capabilities/gallery.py @@ -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 '' % self.url - - def __iscomplete__(self): - return self.data is not NotLoaded - - class BaseGallery(CapBaseObject): """ Represents a gallery. diff --git a/weboob/capabilities/video.py b/weboob/capabilities/video.py index 22c92ffb..4d5c5c32 100644 --- a/weboob/capabilities/video.py +++ b/weboob/capabilities/video.py @@ -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 '' % 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): diff --git a/weboob/tools/capabilities/thumbnail.py b/weboob/tools/capabilities/thumbnail.py new file mode 100644 index 00000000..e260cdd1 --- /dev/null +++ b/weboob/tools/capabilities/thumbnail.py @@ -0,0 +1,35 @@ +# -*- coding: utf-8 -*- + +# Copyright(C) 2011 Romain Bignon, NoƩ Rubinstein +# +# This file is part of weboob. +# +# weboob is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# weboob is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with weboob. If not, see . + +from weboob.capabilities.base import CapBaseObject + +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 '' % self.url + + def __iscomplete__(self): + return self.data is not NotLoaded