station = self.conf['deefuzzer']['station']
else:
station = self.conf['deefuzzer']['station'][i]
+
+ # Apply station defaults if they exist
+ if 'stationdefaults' in self.conf['deefuzzer']:
+ if isinstance(self.conf['deefuzzer']['stationdefaults'], dict):
+ station = merge_defaults(station, self.conf['deefuzzer']['stationdefaults'])
self.stations.append(Station(station, q, self.logger, self.m3u))
if self.m3u:
import os
import re
import string
+from itertools import chain
+from deefuzzer.tools import *
def clean_word(word) :
""" Return the word without excessive blank spaces, underscores and
def is_absolute_path(path):
return os.sep == path[0]
+
+def merge_defaults(setting, default):
+ combined = {}
+ for key in set(chain(setting, default)):
+ if key in setting:
+ if key in default:
+ if isinstance(setting[key], dict) and isinstance(default[key], dict):
+ combined[key] = merge_defaults(setting[key], default[key])
+ else:
+ combined[key] = setting[key]
+ else:
+ combined[key] = setting[key]
+ else:
+ combined[key] = default[key]
+ return combined
"deefuzzer": {
"log": "/path/to/station.log",
"m3u": "/path/to/station.m3u",
+ "station": {
+ "control": {
+ "mode": 0,
+ "port": 16001
+ },
+ "jingles": {
+ "dir": "/path/to/jingles",
+ "mode": 0,
+ "shuffle": 1
+ }
+ },
"station": {
"control": {
"mode": 0,
<deefuzzer>
<log>/path/to/station.log</log>
<m3u>/path/to/station.m3u</m3u>
+ <stationdefaults>
+ <control>
+ <mode>0</mode>
+ <port>16001</port>
+ </control>
+ <jingles>
+ <dir>/path/to/jingles</dir>
+ <mode>0</mode>
+ <shuffle>1</shuffle>
+ </jingles>
+ </stationdefaults>
<station>
<control>
<mode>0</mode>
log: /path/to/station.log
m3u: /path/to/station.m3u
+ stationdefaults:
+ control: {mode: 0,
+ port: 16001}
+
+ jingles: {dir: /path/to/jingles,
+ mode: 0,
+ shuffle: 1}
+
station:
control: {mode: 0,
port: 16001}
The file is preferably accessible behind an url,
for example, http://mydomain.com/m3u/mystation.m3u -->
<m3u>/path/to/station.m3u</m3u>
+ <stationdefaults>
+ <!-- This tag allows a common default configuration to be set for all stations. This
+ is useful when defining many stations that will share many common configuration
+ settings. If a setting is specified here and in a station tag, the station tag
+ will override this one. Available options are the same as the station tag. -->
+ <control>
+ <!-- If '1', an OSC controller thread is started to allow external commands
+ See README for more info -->
+ <mode>0</mode>
+ <!-- The port of the OSC server -->
+ <port>16001</port>
+ </control>
+ <jingles>
+ <!-- A path to the directory containing jingles media files.
+ The files have to be of the same type of the main media files. -->
+ <dir>/path/to/jingles</dir>
+ <!-- If '1', some media will be played between each main track of the playlist. '0' does nothing. -->
+ <mode>0</mode>
+ <!-- If '1', the jingle playlist will be randomized. '0' for aphanumeric order -->
+ <shuffle>1</shuffle>
+ </jingles>
+ </stationdefaults>
<station>
<control>
<!-- If '1', an OSC controller thread is started to allow external commands