new capability ICapAudio

for web sites providing search and audio files download

Signed-off-by: Pierre Mazière <pierre.maziere@gmx.com>
This commit is contained in:
Pierre Mazière 2013-09-09 23:06:50 +02:00 committed by Florent
commit 976fd7984e

View file

@ -0,0 +1,61 @@
# -*- coding: utf-8 -*-
# Copyright(C) 2013 Pierre Mazière
#
# This file is part of weboob.
#
# weboob is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# 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
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from datetime import timedelta
from .base import IBaseCap, CapBaseObject,Field, StringField
from .file import ICapFile, BaseFile
__all__ = ['BaseAudio','ICapAudio']
class BaseAudio(BaseFile):
"""
Represent an audio file
"""
ext = StringField('Audio file extension')
duration = Field('Audio file duration', int, long, timedelta)
bitrate = Field('Audio stream bit rate un Kbps',int)
format = StringField('Audio stream format')
class ICapAudio(ICapFile):
"""
Audio file provider
"""
def search_audio(self,pattern,sortby=ICapFile.SEARCH_RELEVANCE):
"""
search for a audio file
:param pattern: pattern to search on
:type pattern: str
:param sortby: sort by ...(use SEARCH_* constants)
:rtype: iter[:class:`BaseAudio`]
"""
return self.search_file(pattern,sortby)
def get_audio(self, id):
"""
Get an audio file from an ID.
:param id: audio file ID
:type id: str
:rtype: :class:`BaseAudio`]
"""
return self.get_file(self, id)