Skip to content

Instantly share code, notes, and snippets.

@denzuko
Forked from simahawk/json.xsl
Created April 17, 2026 23:24
Show Gist options
  • Select an option

  • Save denzuko/2d007ba69afe3647899bd29f9d6b3598 to your computer and use it in GitHub Desktop.

Select an option

Save denzuko/2d007ba69afe3647899bd29f9d6b3598 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment