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/>.
|
# 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.video import ICapVideo, BaseVideo
|
||||||
from weboob.capabilities.collection import ICapCollection, CollectionNotFound
|
from weboob.capabilities.collection import ICapCollection, CollectionNotFound
|
||||||
from weboob.tools.backend import BaseBackend, BackendConfig
|
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())
|
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):
|
def search_videos(self, pattern, sortby=ICapVideo.SEARCH_RELEVANCE, nsfw=False, max_results=None):
|
||||||
with self.browser:
|
# with self.browser:
|
||||||
return self.browser.search_videos(pattern)
|
# return self.browser.search_videos(pattern)
|
||||||
|
raise UserError('Search does not work on ASI website, use ls latest command')
|
||||||
|
|
||||||
def get_video(self, _id):
|
def get_video(self, _id):
|
||||||
with self.browser:
|
with self.browser:
|
||||||
|
|
@ -62,4 +64,21 @@ class ArretSurImagesBackend(BaseBackend, ICapVideo, ICapCollection):
|
||||||
|
|
||||||
return video
|
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}
|
OBJECTS = {ArretSurImagesVideo: fill_video}
|
||||||
|
|
|
||||||
|
|
@ -66,3 +66,8 @@ class ArretSurImagesBrowser(BaseBrowser):
|
||||||
if not self.is_logged():
|
if not self.is_logged():
|
||||||
raise BrowserIncorrectPassword()
|
raise BrowserIncorrectPassword()
|
||||||
|
|
||||||
|
def latest_videos(self):
|
||||||
|
self.location(self.buildurl('/emissions.php'))
|
||||||
|
assert self.is_on_page(IndexPage)
|
||||||
|
return self.page.iter_videos()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,6 @@ class IndexPage(BasePage):
|
||||||
if m:
|
if m:
|
||||||
_id = m.group(1)
|
_id = m.group(1)
|
||||||
|
|
||||||
|
|
||||||
video = ArretSurImagesVideo(_id)
|
video = ArretSurImagesVideo(_id)
|
||||||
video.title = unicode(title)
|
video.title = unicode(title)
|
||||||
video.rating = None
|
video.rating = None
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue