check if serch query in station search is a valid YCast station ID

Some devices obtain station url, title and description using search query with
station ID
This commit is contained in:
Jakub Janeczko 2020-10-12 17:20:18 +02:00
parent 89d4af8be4
commit f2fffcedce

View file

@ -105,7 +105,7 @@ def get_station_by_id(stationid, additional_info=False):
return my_stations.get_station_by_id(generic.get_stationid_without_prefix(stationid))
elif station_id_prefix == radiobrowser.ID_PREFIX:
station = radiobrowser.get_station_by_id(generic.get_stationid_without_prefix(stationid))
if additional_info:
if station and additional_info:
station.get_playable_url()
return station
return None
@ -245,10 +245,13 @@ def station_search():
page.add(vtuner.Display("Search query too short"))
page.set_count(1)
return page.to_string()
station = get_station_by_id(query, additional_info=(not station_tracking))
if station:
stations = [station]
else:
# TODO: we also need to include 'my station' elements
stations = radiobrowser.search(query)
return get_stations_page(stations, request).to_string()
return get_stations_page(stations, request).to_string()
@app.route('/' + PATH_ROOT + '/' + PATH_PLAY,