From 19e0ff8649c36b0b9cd57c339e2339833aad3902 Mon Sep 17 00:00:00 2001 From: milaq Date: Thu, 22 Aug 2019 23:16:40 +0200 Subject: [PATCH] Add ability to fetch single station element by hardcoded vTuner URL Some AVRs fetch the station info by calling statxml.asp with the station ID parameter. It seems like they expect a single station element in a vTuner compatible page. This should not be confused with the streamurl acquisition proxying implemented in 7c3161aff96e251da1b2695a2345540b016928c5. --- ycast/server.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/ycast/server.py b/ycast/server.py index 645987b..e6ab9d3 100644 --- a/ycast/server.py +++ b/ycast/server.py @@ -10,6 +10,7 @@ import ycast.generic as generic PATH_ROOT = 'ycast' PATH_PLAY = 'play' +PATH_STATION = 'station' PATH_SEARCH = 'search' PATH_MY_STATIONS = 'my_stations' PATH_RADIOBROWSER = 'radiobrowser' @@ -101,6 +102,8 @@ def upstream(path): return vtuner.get_init_token() if request.args.get('search'): return station_search() + if 'statxml.asp' in path and request.args.get('id'): + return get_station_info() if 'loginXML.asp' in path: return redirect(url_for('landing', _external=True), code=302) logging.error("Unhandled upstream query (/setupapp/%s)", path) @@ -219,3 +222,19 @@ def get_stream_url(): abort(404) logging.debug("Station with ID '%s' requested", station.id) return redirect(station.url, code=302) + + +@app.route('/' + PATH_ROOT + '/' + PATH_STATION) +def get_station_info(): + stationid = request.args.get('id') + if not stationid: + logging.error("Station info without station ID requested") + abort(400) + station = get_station_by_id(stationid) + if not station: + logging.error("Could not get station with id '%s'", stationid) + abort(404) + page = vtuner.Page() + page.add(station.to_vtuner()) + page.set_count(1) + return page.to_string()