From 976fd7984e36ea6d21e33fd56de4785fd2b9b62f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Mazi=C3=A8re?= Date: Mon, 9 Sep 2013 23:06:50 +0200 Subject: [PATCH] new capability ICapAudio MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit for web sites providing search and audio files download Signed-off-by: Pierre Mazière --- weboob/capabilities/audio.py | 61 ++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 weboob/capabilities/audio.py diff --git a/weboob/capabilities/audio.py b/weboob/capabilities/audio.py new file mode 100644 index 00000000..05a691d1 --- /dev/null +++ b/weboob/capabilities/audio.py @@ -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 . + + +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)