From a0000eec95e7d79e5cd98c0d8e02e9dee36466b5 Mon Sep 17 00:00:00 2001 From: milaq Date: Mon, 26 Aug 2019 21:07:23 +0200 Subject: [PATCH] Only fetch additional info for stations if requested E.g.: We don't need the playable stream URL for fetching icons --- ycast/server.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ycast/server.py b/ycast/server.py index 84fd9dd..8692a74 100644 --- a/ycast/server.py +++ b/ycast/server.py @@ -92,13 +92,14 @@ def get_paged_elements(items, requestargs): return items[offset:limit] -def get_station_by_id(stationid): +def get_station_by_id(stationid, additional_info=False): station_id_prefix = generic.get_stationid_prefix(stationid) if station_id_prefix == my_stations.ID_PREFIX: 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)) - station.get_playable_url() + if additional_info: + station.get_playable_url() return station return None @@ -220,7 +221,7 @@ def get_stream_url(): if not stationid: logging.error("Stream URL without station ID requested") abort(400) - station = get_station_by_id(stationid) + station = get_station_by_id(stationid, additional_info=True) if not station: logging.error("Could not get station with id '%s'", stationid) abort(404) @@ -234,7 +235,7 @@ def get_station_info(tracked=True): if not stationid: logging.error("Station info without station ID requested") abort(400) - station = get_station_by_id(stationid) + station = get_station_by_id(stationid, additional_info=not tracked) if not station: logging.error("Could not get station with id '%s'", stationid) page = vtuner.Page()