add support for ls command (videoob -b arretsurimages ls latest)
Signed-off-by: franek <franek@chicour.net>
This commit is contained in:
parent
b6f46ab694
commit
145f3cf2c0
3 changed files with 27 additions and 4 deletions
|
|
@ -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}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue