From: Jean-Philippe Orsini Date: Mon, 18 Jan 2016 14:59:02 +0000 (+0100) Subject: first release X-Git-Url: http://git.wpitchoune.net/gitweb/?p=radio.git;a=commitdiff_plain;h=97d1ea7c728d4b043daccb2d76619de30e9e88b2 first release --- diff --git a/cgi-bin/icecast_last_songs.cgi b/cgi-bin/icecast_last_songs.cgi new file mode 100755 index 0000000..7b2cb15 --- /dev/null +++ b/cgi-bin/icecast_last_songs.cgi @@ -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 "]"