Przeglądaj źródła

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
Jakub Janeczko 4 lat temu
rodzic
commit
f2fffcedce
1 zmienionych plików z 5 dodań i 2 usunięć
  1. 5 2
      ycast/server.py

+ 5 - 2
ycast/server.py

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