first release
authorJean-Philippe Orsini <jeanfi@gmail.com>
Mon, 18 Jan 2016 14:59:02 +0000 (15:59 +0100)
committerJean-Philippe Orsini <jeanfi@gmail.com>
Mon, 18 Jan 2016 14:59:02 +0000 (15:59 +0100)
cgi-bin/icecast_last_songs.cgi [new file with mode: 0755]

diff --git a/cgi-bin/icecast_last_songs.cgi b/cgi-bin/icecast_last_songs.cgi
new file mode 100755 (executable)
index 0000000..7b2cb15
--- /dev/null
@@ -0,0 +1,25 @@
+#!/usr/bin/python
+
+import re
+import sys
+
+print "Content-type: application/json"
+print ""
+
+f = open("/var/log/icecast2/playlist.log", 'r')
+
+print "["
+
+first = True
+for line in f:
+       p = re.compile("([^|]+)\|(.+)\|([0-9]+)\|(.+)")
+        m = p.match(line)
+        
+        if first:
+            first = False
+       else:
+               print ','
+
+        sys.stdout.write("{ \"date\": \"" + m.group(1) + "\", \"listeners\": " + m.group(3) + ", \"song\": \"" + m.group(4) + "\" }")
+
+print "]"