More information in query results

This commit is contained in:
elpatron68 2019-07-28 10:10:10 +02:00
parent fa1ec8a52e
commit 8ae6e6b399
3 changed files with 6 additions and 5 deletions

1
.gitignore vendored
View File

@ -107,3 +107,4 @@ venv.bak/
configuration.ini
.vscode/settings.json
2019-07-27 22_09_08-radiobrowser.py - botamusique - Visual Studio Code.png

View File

@ -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

View File

@ -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<table><tr><th>ID</th><th>Station Name</th></tr>'
msg += '\n<table><tr><th>!rbplay ID</th><th>Station Name</th><th>Genre</th><th>Codec/Bitrate</th><th>Country</th><th>Homepage</th></tr>'
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 += '<tr><td>' + s['id'] + '</td><td>' + s['stationname'] + '</td></tr>'
msg += f'<tr><td>{s['id']}</td><td>{s['stationname']}</td><td>{s['genre']}</td><td>{s['codec']}/{s['bitrate']}</td><td>{s['country']}</td><td>{s['homepage']}/</td></tr></table>'
msg += '</table>'
self.send_msg(msg, text)
# Play a secific station (by id) from http://www.radio-browser.info API