问题
I am getting icecast metadata using jquery XMLHttpRequest. There is status.xsl and status-json.xsl url. How do I know when do I use each one, if I only have icecast radio url?
For example this radio works with both of them:
http://149.56.195.94:8416/status.xsl
http://149.56.195.94:8416/status-json.xsl
This radio throws an error using status-json.xsl
http://stream.radios-arra.fr:8000/status.xsl
http://stream.radios-arra.fr:8000/status-json.xsl - ERROR: Could not parse XSLT file
回答1:
If you are not the operator/administrator of the Icecast server, then it's impossible to know for sure if any query will work, as it's possible to individually disable all of the XSLT endpoints.
From a client developer perspective, your best bet is to probe the server and ideally cache the result. Server behavior will only change if it gets updated to a newer version or the administrator changes configuration, both of which is not a common occurrence.
If you probe the server, please note that the JSON endpoint is known to be unreliable on Icecast versions below 2.4.1! Only version 2.4.1 and above will deliver reliable and valid JSON.
Please also note that status.xsl is not an API and content varies wildly between versions! Also individual "customizations" of output have been frequently observed in the wild. So if you chose to scrape this, make your code as robust as possible and prepare for unexpected content.
来源:https://stackoverflow.com/questions/57341271/fetching-icecast-metadata-file