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