def get_conf_dict(self):
confile = open(self.conf_file,'r')
- conf_xml = confile.read()
+ filename, ext = os.path.splitext(self.conf_file)
+ data = confile.read()
confile.close()
- return xmltodict(conf_xml,'utf-8')
+
+ if 'xml' in ext:
+ return xmltodict(data,'utf-8')
+ elif 'yaml' in ext:
+ import yaml
+ return yaml.load(data)
def set_m3u_playlist(self):
m3u_dir = os.sep.join(self.m3u.split(os.sep)[:-1])
self.voices = self.station['media']['voices']
# Server
- self.short_name = self.station['infos']['short_name']
+ if 'mountpoint' in self.station['server'].keys():
+ self.mountpoint = self.station['server']['mountpoint']
+ elif 'short_name' in self.station['infos'].keys():
+ self.mountpoint = self.station['infos']['short_name']
+ else:
+ self.mountpoint = 'default'
+
+ self.short_name = self.mountpoint
if 'type' in self.station['server']:
self.type = self.station['server']['type'] # 'icecast' | 'stream-m'
- if self.type == 'stream-m':
- self.mount = '/publish/' + self.short_name
- elif self.type == 'icecast':
- self.mount = '/' + self.short_name
- else:
- self.mount = '/' + self.short_name
-
if 'stream-m' in self.type:
self.channel = HTTPStreamer()
- self.channel.mount = self.mount
- else:
+ self.channel.mount = '/publish/' + self.mountpoint
+ elif 'icecast' in self.type:
self.channel = shout.Shout()
- self.channel.mount = self.mount + '.' + self.media_format
+ self.channel.mount = '/' + self.mountpoint + '.' + self.media_format
+ else:
+ sys.exit('Not a compatible server type. Choose "stream-m" or "icecast".')
self.channel.url = self.station['infos']['url']
self.channel.name = self.station['infos']['name'] + ' : ' + self.channel.url
self.channel.public = int(self.station['server']['public'])
self.channel.genre = self.station['infos']['genre']
self.channel.description = self.station['infos']['description']
- self.channel.audio_info = { 'bitrate': self.bitrate,
- 'samplerate': self.samplerate,
- 'quality': self.ogg_quality,
- 'channels': self.voices,}
+ self.channel.audio_info = { 'bitrate': str(self.bitrate),
+ 'samplerate': str(self.samplerate),
+ 'quality': str(self.ogg_quality),
+ 'channels': str(self.voices),}
self.server_url = 'http://' + self.channel.host + ':' + str(self.channel.port)
self.channel_url = self.server_url + self.channel.mount
self.main_buffer_size = 0x100000
self.relay_queue_size = 0x100000
self.sub_buffer_size = 0x10000
-
+
def set_media(self, media):
self.media = media
class FileReader:
+
def __init__(self, fp):
self.fp = open(fp, 'r')
class URLReader:
+
def __init__(self, relay):
self.relay = urllib.urlopen(relay)
self.rec_mode = 0
--- /dev/null
+deefuzzer:
+ log: /var/log/telecaster/telecaster_audio_monitor.log
+ m3u: /var/www/m3u/telecaster_audio_monitor.m3u
+ station:
+ control: {mode: 0, port: 1236}
+ infos: {description: TeleCaster MP3 monitor,
+ genre: Vocal,
+ name: telecaster_mp3_monitor,
+ url: 'http://parisson.com.com'}
+ jingles: {dir: /path/to/jingles, mode: 0, shuffle: 1}
+ media: {bitrate: 96,
+ dir: /home/telecaster/media/mp3,
+ format: mp3, ogg_quality: 4,
+ samplerate: 48000, shuffle: 0, voices: '2'}
+ record: {dir: /home/telecaster/trash/mp3, mode: 1}
+ relay: {author: Inconnu, mode: 1,
+ url: 'http://127.0.0.1:8000/telecaster_live.mp3'}
+ rss: {dir: /var/www/rss, enclosure: 0,
+ media_url: 'http://my.domain.com/rss/'}
+ server: {host: 127.0.0.1, mountpoint: telecaster_mp3_monitor,
+ port: 8000, public: 0,
+ sourcepassword: source2parisson, type: icecast}
+ twitter: {key: 76728330-OjKgbHtn4II86Ad7pNUGEzfNAkGTW5Wvw38qUmLE,
+ mode: 0, secret: 4egZs1dSM37XVY8zXa016Yueku2fleXF2bx8k25V4,
+ tags: bla bla}
--- /dev/null
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2013 Guillaume Pellerin
+
+# <yomguy@parisson.com>
+
+# This software is a computer program whose purpose is to stream audio
+# and video data through icecast2 servers.
+
+# This software is governed by the CeCILL license under French law and
+# abiding by the rules of distribution of free software. You can use,
+# modify and/ or redistribute the software under the terms of the CeCILL
+# license as circulated by CEA, CNRS and INRIA at the following URL
+# "http://www.cecill.info".
+
+# As a counterpart to the access to the source code and rights to copy,
+# modify and redistribute granted by the license, users are provided only
+# with a limited warranty and the software's author, the holder of the
+# economic rights, and the successive licensors have only limited
+# liability.
+
+# In this respect, the user's attention is drawn to the risks associated
+# with loading, using, modifying and/or developing or reproducing the
+# software by the user in light of its specific status of free software,
+# that may mean that it is complicated to manipulate, and that also
+# therefore means that it is reserved for developers and experienced
+# professionals having in-depth computer knowledge. Users are therefore
+# encouraged to load and test the software's suitability as regards their
+# requirements in conditions enabling the security of their systems and/or
+# data to be ensured and, more generally, to use and operate it in the
+# same conditions as regards security.
+
+# The fact that you are presently reading this means that you have had
+# knowledge of the CeCILL license and that you accept its terms.
+
+# Author: Guillaume Pellerin <yomguy@parisson.com>
+
+
+import sys
+from deefuzzer.tools.xmltodict import *
+
+
+class XML2Various(object):
+
+ def __init__(self, xml_str):
+ self.dict = xmltodict(xml_str, 'utf-8')
+
+ def to_yaml(self):
+ import yaml
+ return yaml.dump(self.dict)
+
+
+if __name__ == '__main__':
+ xml_file = open(sys.argv[-2], 'r')
+ yaml_file = open(sys.argv[-1], 'w')
+ yaml_file.write(XML2Various(xml_file.read()).to_yaml())
+ xml_file.close()
+ yaml_file.close()
+
+