]> git.parisson.com Git - telecaster-cgi.git/commitdiff
add dicttoxml methods, prepare deefuzzer integration
authoryomguy <yomguy@parisson.com>
Fri, 2 Jul 2010 16:01:24 +0000 (16:01 +0000)
committeryomguy <yomguy@parisson.com>
Fri, 2 Jul 2010 16:01:24 +0000 (16:01 +0000)
README
conf/etc/telecaster/deefuzzer.xml [new file with mode: 0644]
conf/etc/telecaster/telecaster.xml
tools/xmltodict.py

diff --git a/README b/README
index 09f3ad3029da5e6721eadf4b5393f621513ca525..92390fc7d53d6bbbeeb1998375bd1ef365b3d0bd 100644 (file)
--- a/README
+++ b/README
@@ -1,5 +1,6 @@
-TELECASTER
-==========
+===================
+README - TELECASTER
+===================
 
 LICENCE
 =======
@@ -35,17 +36,23 @@ LICENCE
 
 # Author: Guillaume Pellerin <yomguy@parisson.com>
 
+
 ARCHITECTURE
 ============
 Builds well on Debian GNU/Linux 5.0.4
 
+
 DEPENDS
 ========
 
-required : python, icecast2, jackd, edcast-jack (=3.1.7), vorbis-tools, python-mutagen, streamrippper, procps
+required : python, icecast2, apache2, jackd, edcast-jack (=3.1.7), vorbis-tools,
+           python-mutagen, streamrippper, procps
+
 optional : lame
 
+
 MORE INFOS
 ==========
+
 See http://svn.parisson.org/telecaster/
 
diff --git a/conf/etc/telecaster/deefuzzer.xml b/conf/etc/telecaster/deefuzzer.xml
new file mode 100644 (file)
index 0000000..bb38824
--- /dev/null
@@ -0,0 +1,57 @@
+<deefuzzer>
+    <log>/var/log/deefuzzer/deefuzzer.log</log>
+    <m3u>/var/www/m3u/deefuzzer.m3u</m3u>
+    <station>
+        <infos>
+            <short_name>TeleCaster</short_name>
+            <name>TeleCaster Live Session</name>
+            <description>LIVE Talk and Music</description>
+            <url>http://parisson.com</url>
+            <genre>Various Funk Groove</genre>
+        </infos>
+        <server>
+            <host>parisson.com</host>
+            <port>8000</port>
+            <sourcepassword>source2parisson</sourcepassword>
+            <public>0</public>
+        </server>
+        <media>
+            <dir>/path/to/mp3/</dir>
+            <format>mp3</format>
+            <bitrate>192</bitrate>
+            <ogg_quality>7</ogg_quality>
+            <samplerate>44100</samplerate>
+            <voices>1</voices>
+            <shuffle>1</shuffle>
+        </media>
+        <rss>
+            <dir>/var/www/rss/</dir>
+            <enclosure>1</enclosure>
+        </rss>
+        <twitter>
+            <mode>0</mode>
+            <user>my_twitter_user</user>
+            <pass>my_twitter_password</pass>
+            <tags>bla bla</tags>
+        </twitter>
+        <jingles>
+            <mode>0</mode>
+            <dir>/path/to/jingles</dir>
+            <shuffle>1</shuffle>
+        </jingles>
+        <control>
+            <mode>0</mode>
+            <port>1234</port>
+        </control>
+        <relay>
+            <mode>0</mode>
+            <url>http://localhost:8000/telecaster_live.mp3</url>
+        </relay>
+        <record>
+            <mode>0</mode>
+            <dir>/path/to/archives</dir>
+        </record>
+    </station>
+</deefuzzer>
+
+
index d4d1bd0a6d517359cf7b9f1e3eb86e12f02c52c4..aae79ea51c5364958ec038e3a0379bbae3f7f317 100644 (file)
@@ -3,31 +3,27 @@
         <short_name>Pre-Barreau</short_name>
         <name>Pre-Barreau</name>
         <description>La preparation au Barreau de Paris</description>
-        <url>http:///telecaster-04.parisson.com</url>
+        <url>http://telecaster-04.parisson.com</url>
         <genre>Other</genre>
     </infos>
     <server>
-        <host>localhost</host>
+        <host>stream.pre-barreau.com</host>
         <port>8000</port>
         <sourcepassword>source2parisson</sourcepassword>
         <public>0</public>
         <root_dir>/var/www/telecaster/</root_dir>
-        <odd_conf_file>/etc/telecaster/telecaster_edcast_mp3.cfg</odd_conf_file>
-        <lock_file>lock/telecaster.lock</lock_file>
-        <rsync_host>localhost/tmp/</rsync_host>
         <rss>
             <dir>/var/www/rss/</dir>
         </rss>
     </server>
     <media>
         <record>true</record>
-        <dir>/home/pre-barreau/media</dir>
-        <raw_dir>/home/pre-barreau/backup</raw_dir>
+        <dir>/home/prebarreau/media</dir>
         <format>mp3</format>
-        <bitrate>96</bitrate>
+        <bitrate>48</bitrate>
         <channels>1</channels>
         <ogg_quality>3</ogg_quality>
-        <samplerate>44100</samplerate>
+        <samplerate>48000</samplerate>
     </media>
     <jack>
         <input>
index b85d556d294bd1ab43b6bca763e66420673350bc..90db081d6df51ab389551b8eb8c26b5065125bcc 100644 (file)
@@ -1,9 +1,13 @@
 #!/usr/bin/env python
+# -*- coding: utf-8 -*-
 
 # Easily import simple XML data to Python dictionary
 # http://www.gmta.info/publications/parsing-simple-xml-structure-to-a-python-dictionary
 
 import xml.dom.minidom
+import xml.dom.ext
+from xml.sax.saxutils import escape
+
 
 def haschilds(dom):
     # Checks whether an element has any childs
@@ -14,6 +18,7 @@ def haschilds(dom):
             return True
     return False
 
+
 def indexchilds(dom, enc):
     childsdict = dict()
     for childnode in dom.childNodes:
@@ -34,8 +39,38 @@ def indexchilds(dom, enc):
             childsdict[name] = v
     return childsdict
 
+
 def xmltodict(data, enc=None):
     dom = xml.dom.minidom.parseString(data.strip())
     return indexchilds(dom, enc)
 
 
+def dicttoxml(d):
+
+    def unicodify(o):
+        if o is None:
+            return u'';
+        return unicode(o)
+
+    lines = []
+    def addDict(node, offset):
+        for name, value in node.iteritems():
+            if isinstance(value, dict):
+                lines.append(offset + u"<%s>" % name)
+                addDict(value, offset + u" " * 4)
+                lines.append(offset + u"</%s>" % name)
+            elif isinstance(value, list):
+                for item in value:
+                    if isinstance(item, dict):
+                        lines.append(offset + u"<%s>" % name)
+                        addDict(item, offset + u" " * 4)
+                        lines.append(offset + u"</%s>" % name)
+                    else:
+                        lines.append(offset + u"<%s>%s</%s>" % (name, escape(unicodify(item)), name))
+            else:
+                lines.append(offset + u"<%s>%s</%s>" % (name, escape(unicodify(value)), name))
+
+    addDict(d, u"")
+    lines.append(u"")
+    return u"\n".join(lines)
+