[Icecast] Pyhton Class/library for Icecast 2.32 Stats and other info access?

Geoff Shang geoff at QuiteLikely.com
Fri Nov 14 21:45:03 UTC 2014


On Fri, 14 Nov 2014, Dean Sauer wrote:

> In a search for access to various ways to interact with Icecast via
> Python, I ran across this:
>
> http://xiph.org/~brendan/pyshout2/pyshout2-0.0.1.tar.gz
>
> Which is now dead (404).

I don't think this library would have helped.  I expect it would be useful 
for source clients to send media to a server.

> I have a need to be able to query an Icecast Server and get the number of
> listeners for a mount. I need to do this via Python, and preferably with
> out scraping the stats page of Icecast to do so. If there was access to
> other data that would be a plus, but a simple means to call a Python
> function and get an integer back with this value would be a plus.

First, I take it you know that you can get all the stats there are by 
querying http://<server>:<port>/admin/stats.xml (this requires the admin 
username and password of course).

If you don't want to go to these lengths, you could write an XSL transform 
to get you this info.   Something like this should do it:

<xsl:stylesheet xmlns:xsl = "http://www.w3.org/1999/XSL/Transform" version = "1.0" >
<xsl:output omit-xml-declaration="yes" method="text" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" indent="no" encoding="UTF-8" />
<xsl:template match = "/icestats" >
<xsl:for-each select="source">
<xsl:value-of select="listeners" />
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>

Note that if you call this without arguments, it will mash all the 
listener numbers together into one big integer, so you'll want to specify 
a mountpoint.  If you were to call it listeners.xsl, you could call it 
like so:

http://<server>:<port>/listeners.xsl?mount=/<mountname>

HTH,
Geoff.




More information about the Icecast mailing list