This commit is contained in:
Jakub Janeczko 2022-02-19 22:06:08 +01:00 committed by GitHub
commit ae197814fa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 11 deletions

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
@ -123,7 +123,7 @@ def vtuner_redirect(url):
def upstream(path):
if request.args.get('token') == '0':
return vtuner.get_init_token()
if request.args.get('search'):
if request.args.get('search') or request.args.get('Search'):
return station_search()
if 'statxml.asp' in path and request.args.get('id'):
return get_station_info()
@ -238,15 +238,20 @@ def radiobrowser_popular():
methods=['GET', 'POST'])
def station_search():
query = request.args.get('search')
if not query:
query = request.args.get('Search')
if not query or len(query) < 3:
page = vtuner.Page()
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,

View file

@ -131,14 +131,21 @@ class Station:
ET.SubElement(item, 'StationName').text = self.name
if self.trackurl:
ET.SubElement(item, 'StationUrl').text = self.trackurl
else:
elif self.url:
ET.SubElement(item, 'StationUrl').text = self.url
ET.SubElement(item, 'StationDesc').text = self.description
ET.SubElement(item, 'Logo').text = self.icon
ET.SubElement(item, 'StationFormat').text = self.genre
ET.SubElement(item, 'StationLocation').text = self.location
ET.SubElement(item, 'StationBandWidth').text = str(self.bitrate)
ET.SubElement(item, 'StationMime').text = self.mime
if self.description:
ET.SubElement(item, 'StationDesc').text = self.description
if self.icon:
ET.SubElement(item, 'Logo').text = self.icon
if self.genre:
ET.SubElement(item, 'StationFormat').text = self.genre
if self.location:
ET.SubElement(item, 'StationLocation').text = self.location
if self.bitrate:
ET.SubElement(item, 'StationBandWidth').text = str(self.bitrate)
if self.mime:
ET.SubElement(item, 'StationMime').text = self.mime
ET.SubElement(item, 'Relia').text = '3'
ET.SubElement(item, 'Bookmark').text = self.bookmark
if self.bookmark:
ET.SubElement(item, 'Bookmark').text = self.bookmark
return item