From 39c75f058d5ed5a2b1b955b885fd72dec63f00d9 Mon Sep 17 00:00:00 2001 From: Valentin Samir Date: Sat, 21 Dec 2013 03:33:54 +0100 Subject: [PATCH] [tv/radio] Une instance de icecast pour les flux radio http MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ça permet de pouvoir aussi les écouter en wifi, comme la bande passante que prennent les flux audio est faible. --- tv/radio/__init__.py | 0 tv/radio/icecast.py | 25 +++++++++++++++++++++++++ tv/radio/radio.init | 2 ++ tv/radio/vlm.py | 8 +++++--- 4 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 tv/radio/__init__.py create mode 100755 tv/radio/icecast.py diff --git a/tv/radio/__init__.py b/tv/radio/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tv/radio/icecast.py b/tv/radio/icecast.py new file mode 100755 index 00000000..969c4692 --- /dev/null +++ b/tv/radio/icecast.py @@ -0,0 +1,25 @@ +#!/usr/bin/python +# -*- coding: utf8 -*- +import urlparse +import urllib +from config import * + +i=0 +for group in multicast.keys(): + for (title, (name,dst,port,sources)) in multicast[group].items(): + p=urlparse.urlparse(sources[0]) + if ':' in p.netloc: + host=p.netloc.split(':')[0] + port=p.netloc.split(':')[1] + else: + host=p.netloc + port = 80 + print """ + + %s + %s + %s + /%s + 1 + 1 +""" % (host, port, p.path, name) diff --git a/tv/radio/radio.init b/tv/radio/radio.init index eaa27769..2c4fb062 100755 --- a/tv/radio/radio.init +++ b/tv/radio/radio.init @@ -27,6 +27,8 @@ vlc_start() { fi fi ${DIR}vlm.py > ${TMP}vlm.vlm + ${DIR}icecast.py > /etc/icecast2/radio.xml + /etc/init.d/icecast2 restart /usr/bin/sudo -u www-data cvlc --extraintf telnet --ttl 12 --vlm-conf ${TMP}vlm.vlm --pidfile ${PIDFILE} --daemon >/dev/null } diff --git a/tv/radio/vlm.py b/tv/radio/vlm.py index c8fef351..b32fb0b7 100755 --- a/tv/radio/vlm.py +++ b/tv/radio/vlm.py @@ -1,14 +1,16 @@ #!/usr/bin/python # -*- coding: utf8 -*- +import urllib from config import * i=0 for group in multicast.keys(): - for (name,dst,port,sources) in multicast[group].values(): + for (title, (name,dst,port,sources)) in multicast[group].items(): #name="channel%s" % i print('new %s broadcast enabled loop' % name) - for source in sources: - print('setup %s input "%s"' % (name,source)) +# for source in sources: +# print('setup %s input "%s"' % (name,source)) + print('setup %s input "%s"' % (name,'http://tv.crans.org:8000/%s' % name)) print('setup %s output #udp{mux=ts,dst=%s:%s}' % (name,dst,port)) print('setup %s option network-caching=50' % name) print('setup %s option sout-all' % name)