Old news
-=========
+========
See README.rst for last news.
Features
-=========
+========
* MP3, OGG Vorbis file and live streaming over Internet
* Full metadata encapsulation and management
self.conf_file = conf_file
self.conf = get_conf_dict(self.conf_file)
- if 'deefuzzer' not in self.conf.keys():
+ if 'deefuzzer' not in self.conf:
return
# Get the log setting first (if possible)
"""Scan a folder for subfolders containing media, and make stations from them all."""
options = self.watchfolder
- if 'folder' not in options.keys():
+ if 'folder' not in options:
# We have no folder specified. Bail.
return
if self.mainLoop:
- if 'livecreation' not in options.keys():
+ if 'livecreation' not in options:
# We have no folder specified. Bail.
return
# This makes the log file a lot more verbose. Commented out since we report on new stations anyway.
# self._info('Scanning folder ' + folder + ' for stations')
- if 'infos' not in options.keys():
+ if 'infos' not in options:
options['infos'] = {}
- if 'short_name' not in options['infos'].keys():
+ if 'short_name' not in options['infos']:
options['infos']['short_name'] = '[name]'
files = os.listdir(folder)
def station_exists(self, name):
try:
for s in self.station_settings:
- if 'infos' not in s.keys():
+ if 'infos' not in s:
continue
- if 'short_name' not in s['infos'].keys():
+ if 'short_name' not in s['infos']:
continue
if s['infos']['short_name'] == name:
return True
for i in options.keys():
if 'folder' not in i:
s[i] = replace_all(options[i], d)
- if 'media' not in s.keys():
+ if 'media' not in s:
s['media'] = {}
s['media']['source'] = folder
self._info('Loading station config file ' + file)
stationdef = get_conf_dict(file)
if isinstance(stationdef, dict):
- if 'station' in stationdef.keys():
+ if 'station' in stationdef:
if isinstance(stationdef['station'], dict):
self.add_station(stationdef['station'])
elif isinstance(stationdef['station'], list):
for i in range(0, ns_new):
name = ''
try:
- if 'station_name' in self.station_settings[i].keys():
+ if 'station_name' in self.station_settings[i]:
name = self.station_settings[i]['station_name']
- if 'retries' not in self.station_settings[i].keys():
+ if 'retries' not in self.station_settings[i]:
self.station_settings[i]['retries'] = 0
try:
- if 'station_instance' in self.station_settings[i].keys():
+ if 'station_instance' in self.station_settings[i]:
# Check for station running here
if self.station_settings[i]['station_instance'].isAlive():
# Station exists and is alive. Don't recreate.
if self.maxretry >= 0 and self.station_settings[i]['retries'] <= self.maxretry:
# Station passed the max retries count is will not be reloaded
- if 'station_stop_logged' not in self.station_settings[i].keys():
+ if 'station_stop_logged' not in self.station_settings[i]:
self._err('Station ' + name + ' is stopped and will not be restarted.')
self.station_settings[i]['station_stop_logged'] = True
continue
if name == '':
name = 'Station ' + str(i)
- if 'info' in self.station_settings[i].keys():
+ if 'info' in self.station_settings[i]:
if 'short_name' in self.station_settings[i]['infos']:
name = self.station_settings[i]['infos']['short_name']
y = 1
self.base_directory = self.station['base_dir'].strip()
# Media
- if 'm3u' in self.station['media'].keys():
+ if 'm3u' in self.station['media']:
if not self.station['media']['m3u'].strip() == '':
self.media_source = self._path_add_base(self.station['media']['m3u'])
- if 'dir' in self.station['media'].keys():
+ if 'dir' in self.station['media']:
if not self.station['media']['dir'].strip() == '':
self.media_source = self._path_add_base(self.station['media']['dir'])
- if 'source' in self.station['media'].keys():
+ if 'source' in self.station['media']:
if not self.station['media']['source'].strip() == '':
self.media_source = self._path_add_base(self.station['media']['source'])
self.voices = int(self.station['media']['voices'])
# Server
- if 'mountpoint' in self.station['server'].keys():
+ if 'mountpoint' in self.station['server']:
self.mountpoint = self.station['server']['mountpoint']
- elif 'short_name' in self.station['infos'].keys():
+ elif 'short_name' in self.station['infos']:
self.mountpoint = self.station['infos']['short_name']
else:
self.mountpoint = 'default'
self.short_name = self.mountpoint
- if 'appendtype' in self.station['server'].keys():
+ if 'appendtype' in self.station['server']:
self.appendtype = int(self.station['server']['appendtype'])
if 'type' in self.station['server']:
def update_twitter_current(self):
if not self.__twitter_should_update():
return
- artist_names = self.artist.split(' ')
+ # artist_names = self.artist.split(' ')
# artist_tags = ' #'.join(list(set(artist_names) - {'&', '-'}))
message = '%s %s on #%s' % (self.prefix, self.song, self.short_name)
tags = '#' + ' #'.join(self.twitter_tags)
if not isinstance(msg, dict):
self.logger.write_error(str(msg))
else:
- if 'msg' not in msg.keys():
+ if 'msg' not in msg:
continue
- if 'level' in msg.keys():
+ if 'level' in msg:
if msg['level'] == 'info':
self.logger.write_info(msg['msg'])
else:
'''
# media_id3 = id3.ID3(self.media)
# for tag in self.metadata.keys():
- # if tag in self.dub2id3_dict.keys():
+ # if tag in self.dub2id3_dict:
# frame_text = self.dub2id3_dict[tag]
# value = self.metadata[tag]
# frame = mutagen.id3.Frames[frame_text](3,value)
for tag in self.metadata.keys():
value = clean_word(self.metadata[tag])
args.append('-c %s="%s"' % (tag, value))
- if tag in self.dub2args_dict.keys():
+ if tag in self.dub2args_dict:
arg = self.dub2args_dict[tag]
args.append('-c %s="%s"' % (arg, value))
# This is code for the parent element
self._inCode = True
parent = self.nodeStack[-1]
- if not parent.has_key("code"):
+ if "code" not in parent:
parent["code"] = {}
self._codeDict = parent["code"]
self._propName = ""
self._propData = ""
parent = self.nodeStack[-1]
- if not parent.has_key("properties"):
+ if "properties" not in parent:
parent["properties"] = {}
self._propDict = parent["properties"]
element = {"name": name.encode()}
if len(attributes) > 0:
for att in self.attsToSkip:
- if attributes.has_key(att):
+ if att in attributes:
del attributes[att]
element["attributes"] = attributes
# Push element onto the stack and make it a child of parent
if len(self.nodeStack) > 0:
parent = self.nodeStack[-1]
- if not parent.has_key("children"):
+ if "children" not in parent:
parent["children"] = []
parent["children"].append(element)
else:
self._propData += data
else:
element = self.nodeStack[-1]
- if not element.has_key("cdata"):
+ if "cdata" not in element:
element["cdata"] = ""
element["cdata"] += data
att = ""
ret = ""
- if dct.has_key("attributes"):
+ if "attributes" in dct:
for key, val in dct["attributes"].items():
# Some keys are already handled.
noEscape = key in ("sizerInfo",)
att += " %s=%s" % (key, val)
ret += "%s<%s%s" % ("\t" * level, dct["name"], att)
- if (not dct.has_key("cdata") and not dct.has_key("children")
- and not dct.has_key("code") and not dct.has_key("properties")):
+ if ("cdata" not in dct and "children" not in dct
+ and "code" not in dct and "properties" not in dct):
ret += " />%s" % eol
else:
ret += ">"
- if dct.has_key("cdata"):
+ if "cdata" in dct:
ret += "%s" % dct["cdata"].replace("<", "<")
- if dct.has_key("code"):
+ if "code" in dct:
if len(dct["code"].keys()):
ret += "%s%s<code>%s" % (eol, "\t" * (level + 1), eol)
methodTab = "\t" * (level + 2)
)
ret += "%s</code>%s" % ("\t" * (level + 1), eol)
- if dct.has_key("properties"):
+ if "properties" in dct:
if len(dct["properties"].keys()):
ret += "%s%s<properties>%s" % (eol, "\t" * (level + 1), eol)
currTab = "\t" * (level + 2)
ret += "%s</%s>%s" % (currTab, prop, eol)
ret += "%s</properties>%s" % ("\t" * (level + 1), eol)
- if dct.has_key("children") and len(dct["children"]) > 0:
- ret += eol
- for child in dct["children"]:
- ret += dicttoxml(child, level + 1, linesep=linesep)
+ if "children" in dct:
+ if len(dct["children"]) > 0:
+ ret += eol
+ for child in dct["children"]:
+ ret += dicttoxml(child, level + 1, linesep=linesep)
indnt = ""
if ret.endswith(eol):
# Indent the closing tag