From 5f76ea4eefc14c233abb74d503f15a6b099da7c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Mazi=C3=A8re?= Date: Sun, 15 Dec 2013 20:13:56 +0100 Subject: [PATCH] modify nectarine 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/nectarine/backend.py | 7 +++++++ modules/nectarine/pages.py | 17 ++++++++++------- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/modules/nectarine/backend.py b/modules/nectarine/backend.py index 9261be72..30909ede 100644 --- a/modules/nectarine/backend.py +++ b/modules/nectarine/backend.py @@ -56,3 +56,10 @@ class NectarineBackend(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/nectarine/pages.py b/modules/nectarine/pages.py index 43f0c0d3..6946381c 100644 --- a/modules/nectarine/pages.py +++ b/modules/nectarine/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', 'StreamsPage'] @@ -34,11 +35,13 @@ class StreamsPage(BasePage): for el in self.document.xpath('//stream'): index += 1 stream_url = unicode(el.findtext('url')) - bitrate = unicode(el.findtext('bitrate')) + bitrate = el.findtext('bitrate') encode = unicode(el.findtext('type')) country = unicode(el.findtext('country')).upper() - stream = Stream(index) - stream.title = ' '.join([radio.title, country, encode, bitrate, 'kbps']) + stream = BaseAudioStream(index) + stream.bitrate=int(bitrate) + stream.format=encode + stream.title = ' '.join([radio.title, country, encode, unicode(bitrate), 'kbps']) stream.url = stream_url radio.streams.append(stream) @@ -48,7 +51,7 @@ class StreamsPage(BasePage): class LivePage(BasePage): def get_current_emission(self): - current = Emission(0) - current.artist = unicode(self.document.xpath('//playlist/now/entry/artist')[0].text) - current.title = unicode(self.document.xpath('//playlist/now/entry/song')[0].text) + current = AudioStreamInfo(0) + current.who = unicode(self.document.xpath('//playlist/now/entry/artist')[0].text) + current.what = unicode(self.document.xpath('//playlist/now/entry/song')[0].text) return current