modify nectarine module to use the modified ICapRadio
Signed-off-by: Pierre Mazière <pierre.maziere@gmx.com>
This commit is contained in:
parent
f90cb73a85
commit
5f76ea4eef
2 changed files with 17 additions and 7 deletions
|
|
@ -56,3 +56,10 @@ class NectarineBackend(BaseBackend, ICapRadio, ICapCollection):
|
||||||
if rad.id == radio:
|
if rad.id == radio:
|
||||||
return rad
|
return rad
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def fill_radio(self, radio, fields):
|
||||||
|
if 'current' in fields:
|
||||||
|
return self.get_radio(radio.id)
|
||||||
|
return radio
|
||||||
|
|
||||||
|
OBJECTS = {Radio: fill_radio}
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,8 @@
|
||||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from weboob.tools.browser import BasePage
|
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']
|
__all__ = ['LivePage', 'StreamsPage']
|
||||||
|
|
||||||
|
|
@ -34,11 +35,13 @@ class StreamsPage(BasePage):
|
||||||
for el in self.document.xpath('//stream'):
|
for el in self.document.xpath('//stream'):
|
||||||
index += 1
|
index += 1
|
||||||
stream_url = unicode(el.findtext('url'))
|
stream_url = unicode(el.findtext('url'))
|
||||||
bitrate = unicode(el.findtext('bitrate'))
|
bitrate = el.findtext('bitrate')
|
||||||
encode = unicode(el.findtext('type'))
|
encode = unicode(el.findtext('type'))
|
||||||
country = unicode(el.findtext('country')).upper()
|
country = unicode(el.findtext('country')).upper()
|
||||||
stream = Stream(index)
|
stream = BaseAudioStream(index)
|
||||||
stream.title = ' '.join([radio.title, country, encode, bitrate, 'kbps'])
|
stream.bitrate=int(bitrate)
|
||||||
|
stream.format=encode
|
||||||
|
stream.title = ' '.join([radio.title, country, encode, unicode(bitrate), 'kbps'])
|
||||||
stream.url = stream_url
|
stream.url = stream_url
|
||||||
radio.streams.append(stream)
|
radio.streams.append(stream)
|
||||||
|
|
||||||
|
|
@ -48,7 +51,7 @@ class StreamsPage(BasePage):
|
||||||
|
|
||||||
class LivePage(BasePage):
|
class LivePage(BasePage):
|
||||||
def get_current_emission(self):
|
def get_current_emission(self):
|
||||||
current = Emission(0)
|
current = AudioStreamInfo(0)
|
||||||
current.artist = unicode(self.document.xpath('//playlist/now/entry/artist')[0].text)
|
current.who = unicode(self.document.xpath('//playlist/now/entry/artist')[0].text)
|
||||||
current.title = unicode(self.document.xpath('//playlist/now/entry/song')[0].text)
|
current.what = unicode(self.document.xpath('//playlist/now/entry/song')[0].text)
|
||||||
return current
|
return current
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue