ajout de la prise en charge de Arte Live Web par le module arte

Signed-off-by: Bezleputh <carton_ben@yahoo.fr>
Signed-off-by: Romain Bignon <romain@budget-insight.com>
This commit is contained in:
Bezleputh 2013-05-13 21:37:01 +02:00 committed by Romain Bignon
commit d1fd5de309
6 changed files with 191 additions and 21 deletions

View file

@ -21,17 +21,16 @@
from __future__ import with_statement
from weboob.capabilities.video import ICapVideo, BaseVideo
from weboob.capabilities.collection import ICapCollection, CollectionNotFound
from weboob.capabilities.collection import ICapCollection, CollectionNotFound, Collection
from weboob.tools.backend import BaseBackend, BackendConfig
from weboob.tools.value import Value
from .browser import ArteBrowser
from .video import ArteVideo
from .video import ArteVideo, ArteLiveVideo
from .collection import ArteLiveCollection
__all__ = ['ArteBackend']
class ArteBackend(BaseBackend, ICapVideo, ICapCollection):
NAME = 'arte'
MAINTAINER = u'Romain Bignon'
@ -59,28 +58,42 @@ class ArteBackend(BaseBackend, ICapVideo, ICapCollection):
if fields != ['thumbnail']:
# if we don't want only the thumbnail, we probably want also every fields
with self.browser:
video = self.browser.get_video(ArteVideo.id2url(video.id), video)
if 'thumbnail' in fields and video.thumbnail:
if isinstance(video,ArteVideo):
video = self.browser.get_video(ArteVideo.id2url(video.id), video)
if isinstance(video,ArteLiveVideo):
video = self.browser.get_live_video(ArteLiveVideo.id2url(video.id), video)
if 'thumbnail' in fields and video and video.thumbnail:
with self.browser:
video.thumbnail.data = self.browser.readurl(video.thumbnail.url)
return video
def iter_resources(self, objs, split_path):
if BaseVideo in objs:
collection = self.get_collection(objs, split_path)
if collection.path_level == 0:
yield self.get_collection(objs, [u'latest'])
if collection.split_path == [u'latest']:
for video in self.browser.latest_videos():
yield video
with self.browser:
if BaseVideo in objs:
collection = self.get_collection(objs, split_path)
if collection.path_level == 0:
yield Collection([u'latest'],u'Latest Arte videos')
yield Collection([u'live'],u'Arte Web Live videos')
if collection.path_level == 1:
if collection.split_path == [u'latest']:
for video in self.browser.latest_videos():
yield video
if collection.split_path == [u'live']:
for categorie in self.browser.get_arte_live_categories():
yield categorie
if collection.path_level == 2:
if collection.split_path[0] == u'live':
for video in self.browser.live_videos(ArteLiveCollection.id2url(collection.basename)):
yield video
def validate_collection(self, objs, collection):
if collection.path_level == 0:
return
if BaseVideo in objs and collection.split_path == [u'latest']:
collection.title = u'Latest Arte videos'
if BaseVideo in objs and ( collection.split_path == [u'latest'] or collection.split_path == [u'live'] ):
return
if BaseVideo in objs and collection.path_level == 2 and collection.split_path[0] == u'live' :
return
raise CollectionNotFound(collection.split_path)
OBJECTS = {ArteVideo: fill_video}
OBJECTS = {ArteVideo: fill_video, ArteLiveVideo: fill_video }