Skip to content
video.py 1.83 KiB
Newer Older
# -*- coding: utf-8 -*-

# Copyright(C) 2010-2013 Romain Bignon, Christophe Benz
# Copyright(C) 2013 Pierre Mazière
Romain Bignon's avatar
Romain Bignon committed
# This file is part of weboob.
Romain Bignon's avatar
Romain Bignon committed
# weboob is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
Romain Bignon's avatar
Romain Bignon committed
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# weboob is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
Romain Bignon's avatar
Romain Bignon committed
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public License
Romain Bignon's avatar
Romain Bignon committed
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from .image import CapImage, BaseImage
Romain Bignon's avatar
Romain Bignon committed

Christophe Benz's avatar
Christophe Benz committed

__all__ = ['BaseVideo', 'CapVideo']
Christophe Benz's avatar
Christophe Benz committed

class BaseVideo(BaseImage):
Christophe Benz's avatar
Christophe Benz committed
    """
    Represents a video.
Christophe Benz's avatar
Christophe Benz committed
    This object has to be inherited to specify how to calculate the URL of the video from its ID.
    """
    duration =  DeltaField('file duration')
class CapVideo(CapImage):
Christophe Benz's avatar
Christophe Benz committed
    """
Christophe Benz's avatar
Christophe Benz committed
    """
    def search_videos(self, pattern, sortby=CapImage.SEARCH_RELEVANCE, nsfw=False):
        :param pattern: pattern to search on
        :type pattern: str
        :param sortby: sort by... (use SEARCH_* constants)
        :param nsfw: include non-suitable for work videos if True
        :type nsfw: bool
        :rtype: iter[:class:`BaseVideo`]
        return self.search_image(pattern, sortby, nsfw)
    def get_video(self, _id):
        Get a video file from an ID.
        :param _id: video file ID
        :type _id: str
        :rtype: :class:`BaseVideo` or None is fot found.
        return self.get_image(_id)