Commit 10b93784 authored by Johann Broudin's avatar Johann Broudin Committed by Vincent A

[Virgin Radio] Small style changes

parent dc8eeab0
......@@ -22,6 +22,7 @@ from weboob.browser import Browser
from . import parser
class VirginBrowser(Browser):
_RADIOS_URL = 'https://www.virginradio.fr/desktop/js/all.min.js'
_PROGRAM_URL = 'https://www.virginradio.fr/calendar/api/current.json/argv/calendar_type/emission/origine_flags/virginradio/get_current_foreign_type/TRUE'
......@@ -43,7 +44,7 @@ class VirginBrowser(Browser):
if not self._radios:
self.radios()
if not radio in self._radios:
if radio not in self._radios:
return None
return self._radios[radio]
......
......@@ -52,13 +52,13 @@ class VirginRadioModule(Module, CapRadio, CapCollection):
stream_hls = BaseAudioStream(0)
stream_hls.url = r['hls_source']
stream_hls.bitrate = 135
stream_hls.format=u'aac'
stream_hls.format = u'aac'
stream_hls.title = u'%s %skbits/s' % (stream_hls.format, stream_hls.bitrate)
stream = BaseAudioStream(0)
stream.url = r['source']
stream.bitrate = 128
stream.format=u'mp3'
stream.format = u'mp3'
stream.title = u'%s %skbits/s' % (stream.format, stream.bitrate)
radio.streams = [stream_hls, stream]
......
......@@ -21,6 +21,7 @@ import re
from lxml import html
def radios(webradios, radiosjs):
radiosjs_re = (
r'{id:(?P<id>\d+),'
......@@ -35,14 +36,15 @@ def radios(webradios, radiosjs):
radios = {}
tree = html.fromstring(webradios.content)
for m in re.finditer(radiosjs_re, radiosjs.text):
radios[m.group('name')] = { 'radio_id': m.group('id_radio'),
'name': m.group('name'),
'hls_source': m.group('hls_source'),
'source': m.group('source'),
'title': tree.xpath(webradios_xpath % (m.group('id_radio')))[0] }
radios[m.group('name')] = {'radio_id': m.group('id_radio'),
'name': m.group('name'),
'hls_source': m.group('hls_source'),
'source': m.group('source'),
'title': tree.xpath(webradios_xpath % (m.group('id_radio')))[0]}
return radios
def current(r):
artist = ''
title = ''
......@@ -53,6 +55,7 @@ def current(r):
return artist, title
def description(r):
description = ''
info = r.json()['root_tab']['events']
......@@ -60,4 +63,3 @@ def description(r):
description = "%s - %s" % (info[0]['title'], info[0]['tab_foreign_type']['resum'])
return description
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment