From 10b93784c87c47ebe562b39cb20ae099d2f01c16 Mon Sep 17 00:00:00 2001 From: Johann Broudin <45597667+broujo@users.noreply.github.com> Date: Mon, 15 Jun 2020 22:35:40 +0200 Subject: [PATCH] [Virgin Radio] Small style changes --- modules/virginradio/browser.py | 3 ++- modules/virginradio/module.py | 4 ++-- modules/virginradio/parser.py | 14 ++++++++------ 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/modules/virginradio/browser.py b/modules/virginradio/browser.py index 0128e62744..7e001f0658 100644 --- a/modules/virginradio/browser.py +++ b/modules/virginradio/browser.py @@ -22,6 +22,7 @@ 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 @@ def radio(self, radio): if not self._radios: self.radios() - if not radio in self._radios: + if radio not in self._radios: return None return self._radios[radio] diff --git a/modules/virginradio/module.py b/modules/virginradio/module.py index 17eebadbff..1f579808d7 100644 --- a/modules/virginradio/module.py +++ b/modules/virginradio/module.py @@ -52,13 +52,13 @@ def get_radio(self, radio): 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] diff --git a/modules/virginradio/parser.py b/modules/virginradio/parser.py index 647812543b..2f58ed9b6f 100644 --- a/modules/virginradio/parser.py +++ b/modules/virginradio/parser.py @@ -21,6 +21,7 @@ from lxml import html + def radios(webradios, radiosjs): radiosjs_re = ( r'{id:(?P\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 - -- GitLab