add support for ls command (videoob -b arretsurimages ls latest)

Signed-off-by: franek <franek@chicour.net>
This commit is contained in:
franek 2013-04-01 12:32:54 +02:00 committed by Florent
commit 145f3cf2c0
3 changed files with 27 additions and 4 deletions

View file

@ -18,6 +18,7 @@
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from weboob.capabilities.base import UserError
from weboob.capabilities.video import ICapVideo, BaseVideo
from weboob.capabilities.collection import ICapCollection, CollectionNotFound
from weboob.tools.backend import BaseBackend, BackendConfig
@ -44,8 +45,9 @@ class ArretSurImagesBackend(BaseBackend, ICapVideo, ICapCollection):
return self.create_browser(self.config['login'].get(), self.config['password'].get())
def search_videos(self, pattern, sortby=ICapVideo.SEARCH_RELEVANCE, nsfw=False, max_results=None):
with self.browser:
return self.browser.search_videos(pattern)
# with self.browser:
# return self.browser.search_videos(pattern)
raise UserError('Search does not work on ASI website, use ls latest command')
def get_video(self, _id):
with self.browser:
@ -61,5 +63,22 @@ class ArretSurImagesBackend(BaseBackend, ICapVideo, ICapCollection):
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
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 ArretSurImages videos'
return
raise CollectionNotFound(collection.split_path)
OBJECTS = {ArretSurImagesVideo: fill_video}