<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" xmlns:js="http://muttmansion.com"> <xsl:output method="text" /> <xsl:template match="/icestats">var sources = [<xsl:for-each select="source"> <xsl:if test="position() > 1">,</xsl:if> {mount:'<xsl:value-of select="@mount" />',<xsl:if test="name">name:'<xsl:value-of select="name" />',</xsl:if> <xsl:if test="server_type">content_type:'<xsl:value-of select="server_type" />',</xsl:if> <xsl:if test="stream_start">stream_start:'<xsl:value-of select="stream_start" />',</xsl:if> <xsl:if test="bitrate">bitrate:'<xsl:value-of select="bitrate" />',</xsl:if> <xsl:if test="quality">quality:'<xsl:value-of select="quality" />',</xsl:if> <xsl:if test="listener_peak">listener_peak:'<xsl:value-of select="listener_peak" />',</xsl:if> <xsl:if test="genre">genre:'<xsl:value-of select="genre" />',</xsl:if> <xsl:if test="description">description:'<xsl:value-of select="description" />',</xsl:if> <xsl:if test="server_url">server_url:'<xsl:value-of select="server_url" />',</xsl:if> <xsl:if test="artist">artist:'<xsl:value-of select="artist" />',</xsl:if> <xsl:if test="title">title:'<xsl:value-of select="title" />',</xsl:if> <xsl:if test="url">url:'<xsl:value-of select="url" />'</xsl:if>listeners:'<xsl:value-of select="listeners" />'}</xsl:for-each> ];</xsl:template></xsl:stylesheet>
void logging_playlist (const char *mount, const char *metadata, long listeners) { char datebuf[128]; struct tm thetime; time_t now; char buff[5000]; int len = strnlen (metadata, 5000); if (len < 5000) { strncpy (buff, metadata, len + 1); int i; for (i = len; i >= 0; i--) { if (buff[i] == '"') { memmove (buff + i + 1, buff + i, len - i + 1); buff[i] = '\\'; } } ice_config_t *conf = config_get_config (); char fn_json[FILENAME_MAX]; snprintf (fn_json, FILENAME_MAX, "%s%sstat.js", conf != NULL ? conf->webroot_dir : ".", PATH_SEPARATOR); FILE *json = fopen (fn_json, "w"); fprintf (json, "play_callback(\"%s\",%ld);", buff, listeners); fclose (json); }