30 lines
831 B
Python
30 lines
831 B
Python
from rbRadios import RadioBrowser
|
|
|
|
rb = librb.RadioBrowser()
|
|
|
|
def getstations_byname(query):
|
|
results = rb.stations_byname(query)
|
|
stations = []
|
|
for st in results:
|
|
try:
|
|
# url = rb.playable_station(st['id'])['url']
|
|
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
|
|
return stations
|
|
|
|
def geturl_byid(id):
|
|
url = rb.playable_station(id)['url']
|
|
if url != None:
|
|
return url
|
|
else:
|
|
return "-1"
|
|
|
|
def getstationname_byid(id):
|
|
return rb.stations_byid(id)
|
|
|
|
if __name__ == "__main__":
|
|
r = getstations_byname('r.sh')
|
|
stationinfo = getstationname_byid(96748)
|
|
pass |