Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 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 All @@ -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()
Expand Down Expand Up @@ -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,
Expand Down
23 changes: 15 additions & 8 deletions ycast/vtuner.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,21 @@ def to_xml(self):
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