From 8ae6e6b399ef1b8966e94209ebbdd563c9e2ed90 Mon Sep 17 00:00:00 2001 From: elpatron68 Date: Sun, 28 Jul 2019 10:10:10 +0200 Subject: [PATCH] More information in query results --- .gitignore | 1 + librb/radiobrowser.py | 6 +++--- mumbleBot.py | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 3be6ef1..916a549 100644 --- a/.gitignore +++ b/.gitignore @@ -107,3 +107,4 @@ venv.bak/ configuration.ini .vscode/settings.json +2019-07-27 22_09_08-radiobrowser.py - botamusique - Visual Studio Code.png diff --git a/librb/radiobrowser.py b/librb/radiobrowser.py index f934e6f..c908823 100644 --- a/librb/radiobrowser.py +++ b/librb/radiobrowser.py @@ -1,6 +1,6 @@ -from librb.rbRadios import RadioBrowser +from rbRadios import RadioBrowser -rb = RadioBrowser() +rb = librb.RadioBrowser() def getstations_byname(query): results = rb.stations_byname(query) @@ -8,7 +8,7 @@ def getstations_byname(query): for st in results: try: # url = rb.playable_station(st['id'])['url'] - station = {'stationname': st['name'], 'id':st['id']} + station = {'stationname': st['name'], 'id':st['id'], 'codec':st['codec'], 'bitrate':st['bitrate'], 'country':st['country'], 'homepage':st['homepage'], 'genre':st['tags']} stations.append(station) except: pass diff --git a/mumbleBot.py b/mumbleBot.py index 8af13e8..433bb7b 100644 --- a/mumbleBot.py +++ b/mumbleBot.py @@ -373,13 +373,13 @@ class MumbleBot: self.send_msg('Searching for stations - this may take some seconds...', text) rb_stations = radiobrowser.getstations_byname(parameter) msg = var.config.get('strings', 'rbqueryresult') + " :" - msg += '\n' + msg += '\n
IDStation Name
' if not rb_stations: logging.debug('No matches found for rbquery ' + parameter) self.send_msg('Radio-Browser found no matches for ' + parameter, text) else: for s in rb_stations: - msg += '' + msg += f'
!rbplay IDStation NameGenreCodec/BitrateCountryHomepage
' + s['id'] + '' + s['stationname'] + '
{s['id']}{s['stationname']}{s['genre']}{s['codec']}/{s['bitrate']}{s['country']}{s['homepage']}/
' msg += '' self.send_msg(msg, text) # Play a secific station (by id) from http://www.radio-browser.info API