Skip to content

Commit

Permalink
check if serch query in station search is a valid YCast station ID
Browse files Browse the repository at this point in the history
Some devices obtain station url, title and description using search query with
station ID
  • Loading branch information
yay6 committed Feb 19, 2022
1 parent 89d4af8 commit f2fffce
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions ycast/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit f2fffce

Please sign in to comment.