Move the "empty search for latest" to collections
There is now a "latest" collection (or "latest_nsfw"). The feature didn't look much used, since it didn't work on many backends. Using collections will make it easy to support other things like most viewed, featured, etc. As a bonus, I added tests for every backend with the feature.
This commit is contained in:
parent
4d628112d5
commit
e958c229e6
32 changed files with 366 additions and 112 deletions
|
|
@ -20,7 +20,8 @@
|
|||
|
||||
from __future__ import with_statement
|
||||
|
||||
from weboob.capabilities.video import ICapVideo
|
||||
from weboob.capabilities.video import ICapVideo, BaseVideo
|
||||
from weboob.capabilities.collection import ICapCollection, CollectionNotFound
|
||||
from weboob.tools.backend import BaseBackend
|
||||
|
||||
from .browser import PluzzBrowser
|
||||
|
|
@ -30,7 +31,7 @@ from .video import PluzzVideo
|
|||
__all__ = ['PluzzBackend']
|
||||
|
||||
|
||||
class PluzzBackend(BaseBackend, ICapVideo):
|
||||
class PluzzBackend(BaseBackend, ICapVideo, ICapCollection):
|
||||
NAME = 'francetelevisions'
|
||||
MAINTAINER = 'Romain Bignon'
|
||||
EMAIL = 'romain@weboob.org'
|
||||
|
|
@ -43,7 +44,7 @@ class PluzzBackend(BaseBackend, ICapVideo):
|
|||
with self.browser:
|
||||
return self.browser.get_video(_id)
|
||||
|
||||
def search_videos(self, pattern=None, sortby=ICapVideo.SEARCH_RELEVANCE, nsfw=False, max_results=None):
|
||||
def search_videos(self, pattern, sortby=ICapVideo.SEARCH_RELEVANCE, nsfw=False, max_results=None):
|
||||
with self.browser:
|
||||
return self.browser.search_videos(pattern)
|
||||
|
||||
|
|
@ -58,4 +59,21 @@ class PluzzBackend(BaseBackend, ICapVideo):
|
|||
|
||||
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
|
||||
|
||||
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 France Télévisions videos'
|
||||
return
|
||||
raise CollectionNotFound(collection.split_path)
|
||||
|
||||
OBJECTS = {PluzzVideo: fill_video}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue