From 6716787ad9054f823720bd6a15a6fd11caffee4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Mazi=C3=A8re?= Date: Sun, 15 Dec 2013 20:14:17 +0100 Subject: [PATCH] modify nihonnooto module to use the modified ICapRadio MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Pierre Mazière --- modules/nihonnooto/backend.py | 7 +++++++ modules/nihonnooto/pages.py | 18 ++++++++++++------ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/modules/nihonnooto/backend.py b/modules/nihonnooto/backend.py index 0c3d5f95..1ece174f 100644 --- a/modules/nihonnooto/backend.py +++ b/modules/nihonnooto/backend.py @@ -57,3 +57,10 @@ class NihonNoOtoBackend(BaseBackend, ICapRadio, ICapCollection): if rad.id == radio: return rad return None + + def fill_radio(self, radio, fields): + if 'current' in fields: + return self.get_radio(radio.id) + return radio + + OBJECTS = {Radio: fill_radio} diff --git a/modules/nihonnooto/pages.py b/modules/nihonnooto/pages.py index 348d0b21..4ff29eae 100644 --- a/modules/nihonnooto/pages.py +++ b/modules/nihonnooto/pages.py @@ -18,7 +18,8 @@ # along with weboob. If not, see . from weboob.tools.browser import BasePage -from weboob.capabilities.radio import Radio, Stream, Emission +from weboob.capabilities.radio import Radio +from weboob.capabilities.audiostream import BaseAudioStream, AudioStreamInfo __all__ = ['LivePage', 'ProgramPage'] @@ -35,7 +36,12 @@ class LivePage(BasePage): index += 1 mime_type = unicode(el.attrib['type']) stream_url = unicode(el.attrib['src']) - stream = Stream(index) + stream = BaseAudioStream(index) + stream.bitrate=128 + if ( mime_type == u'audio/mpeg' ): + stream.format=u'mp3' + elif ( mime_type == u'audio/ogg' ): + stream.format=u'vorbis' stream.title = radio.title + ' ' + mime_type stream.url = stream_url radio.streams.append(stream) @@ -46,12 +52,12 @@ class LivePage(BasePage): class ProgramPage(BasePage): def get_current_emission(self): - current = Emission(0) + current = AudioStreamInfo(0) two_or_more = unicode(self.document.xpath('//p')[0].text).split('/////')[0].split(' - ') # Consider that if String(' - ') appears it'll be in title rather in the artist name if len(two_or_more) > 2: - current.artist = two_or_more.pop(0) - current.title = ' - '.join(two_or_more) + current.who = two_or_more.pop(0) + current.what = ' - '.join(two_or_more) else: - current.artist, current.title = two_or_more + current.who, current.what = two_or_more return current