add compatibility for other vendors

do not hardcode initurl to get easy compatibility with other initurls (e.g. onkyo)
This commit is contained in:
milaq 2019-01-24 22:07:06 +01:00
parent f0756bd5f6
commit 5888815cd8

View file

@ -8,7 +8,6 @@ import xml.etree.cElementTree as etree
import yaml import yaml
VTUNER_INITURL = '/setupapp/Yamaha/asp/BrowseXML/loginXML.asp'
YCAST_LOCATION = 'ycast' YCAST_LOCATION = 'ycast'
stations = {} stations = {}
@ -37,13 +36,13 @@ class YCastServer(BaseHTTPRequestHandler):
def do_GET(self): def do_GET(self):
get_stations() get_stations()
self.address = 'http://' + self.headers['Host'] self.address = 'http://' + self.headers['Host']
if self.path.startswith(VTUNER_INITURL + '?token='): if 'loginXML.asp?token=0' in self.path:
self.send_xml_header() self.send_xml_header()
self.wfile.write(bytes('<EncryptedToken>stub</EncryptedToken>', 'utf-8')) self.wfile.write(bytes('<EncryptedToken>stub</EncryptedToken>', 'utf-8'))
elif self.path == '/' \ elif self.path == '/' \
or self.path == '/' + YCAST_LOCATION \ or self.path == '/' + YCAST_LOCATION \
or self.path == '/' + YCAST_LOCATION + '/'\ or self.path == '/' + YCAST_LOCATION + '/'\
or self.path.startswith(VTUNER_INITURL): or self.path.startswith('/setupapp'):
self.send_xml_header() self.send_xml_header()
xml = self.create_root() xml = self.create_root()
for category in sorted(stations, key=str.lower): for category in sorted(stations, key=str.lower):