Skip to content

Instantly share code, notes, and snippets.

@simahawk
Created August 14, 2017 17:17
Show Gist options
  • Save simahawk/a93a8368cb80d4e3854d302809f105cd to your computer and use it in GitHub Desktop.
Save simahawk/a93a8368cb80d4e3854d302809f105cd to your computer and use it in GitHub Desktop.
Icecast server JSON status
# place this into /usr/share/icecast2/web/json.xsl
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:output omit-xml-declaration="yes" method="text" indent="no" media-type="text/javascript" encoding="UTF-8"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/icestats">{
<xsl:for-each select="source">
"<xsl:value-of select="@mount"/>":{
"server_name":"<xsl:value-of select="server_name"/>",
"listeners":"<xsl:value-of select="listeners"/>",
"description":"<xsl:value-of select="server_description"/>",
"title":"<xsl:if test="artist"><xsl:value-of select="artist"/>-</xsl:if><xsl:value-of select="title"/>",
"genre":"<xsl:value-of select="genre"/>",
"bitrate":"<xsl:value-of select="bitrate"/>",
"url":"<xsl:value-of select="server_url"/>"
}<xsl:if test="position() != last()"><xsl:text>,</xsl:text></xsl:if>
</xsl:for-each>}</xsl:template>
</xsl:stylesheet>
@gormih
Copy link

gormih commented Nov 9, 2020

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment