added settings file
This commit is contained in:
101
libsettings.py
101
libsettings.py
@@ -5,7 +5,7 @@ Created on Fri Jul 5 20:14:15 2013
|
||||
@author: shanef
|
||||
"""
|
||||
|
||||
from xml.etree import ElementTree
|
||||
from configobj import ConfigObj
|
||||
|
||||
class ShowSettings:
|
||||
def __init__(self, name, inputDirectory, outputDirectory):
|
||||
@@ -13,15 +13,98 @@ class ShowSettings:
|
||||
self.inputDirectory = inputDirectory
|
||||
self.outputDirectory = outputDirectory
|
||||
|
||||
|
||||
class Settings:
|
||||
def __init__(self, settingsFile):
|
||||
self.shows = self.LoadSettings(settingsFile)
|
||||
self.__config = ConfigObj(settingsFile)
|
||||
|
||||
def LoadSettings(self, source):
|
||||
shows = []
|
||||
settingsXml = ElementTree.parse(source).getroot()
|
||||
def TVRecordingDirectory(self):
|
||||
return self.__config["TVRecordings"]
|
||||
|
||||
for show in settingsXml.findall('show'):
|
||||
newShow = ShowSettings(show[0].text, show[1].text, show[2].text)
|
||||
shows.append(newShow)
|
||||
return shows
|
||||
def HandbrakeCommand(self):
|
||||
return self.__config["HandbrakeCommand"]
|
||||
|
||||
def MythTVAddress(self):
|
||||
return self.__config["MythTV"]["address"]
|
||||
|
||||
def MythTVUser(self):
|
||||
return self.__config["MythTV"]["user"]
|
||||
|
||||
def MythTVPassword(self):
|
||||
return self.__config["MythTV"]["password"]
|
||||
|
||||
def MythTVDatabase(self):
|
||||
return self.__config["MythTV"]["database"]
|
||||
|
||||
def SickbeardAddress(self):
|
||||
return self.__config["Sickbeard"]["address"]
|
||||
|
||||
def SickbeardPort(self):
|
||||
return int(self.__config["Sickbeard"]["port"])
|
||||
|
||||
def SickbeardAPIKey(self):
|
||||
return self.__config["Sickbeard"]["APIKey"]
|
||||
|
||||
def UnknownDirectory(self):
|
||||
return self.__config["Shows"]["UnknownInput"]
|
||||
|
||||
def GetShowNames(self, includeAlias=False):
|
||||
shows = self.__config["Shows"].sections
|
||||
result = shows[:]
|
||||
if includeAlias:
|
||||
for show in shows:
|
||||
for alias in self.__config["Shows"][show]["alias"]:
|
||||
result.append(alias)
|
||||
return result
|
||||
|
||||
def GetShowInputDirectory(self, showName):
|
||||
show = self.__GetShowSubsection(showName)
|
||||
if show is None:
|
||||
return ""
|
||||
else:
|
||||
return show["InputDirectory"]
|
||||
|
||||
def GetShowOutputDirectory(self, showName):
|
||||
show = self.__GetShowSubsection(showName)
|
||||
if show is None:
|
||||
return ""
|
||||
else:
|
||||
return show["OutputDirectory"]
|
||||
|
||||
def GetShowAlias(self, showName):
|
||||
show = self.__GetShowSubsection(showName)
|
||||
if show is None:
|
||||
return ""
|
||||
else:
|
||||
return show["alias"]
|
||||
|
||||
def GetShowMythTVEpisodePrefix(self, showName):
|
||||
show = self.__GetShowSubsection(showName)
|
||||
if show is None:
|
||||
return ""
|
||||
else:
|
||||
return show["MythTvEpisodePrefix"]
|
||||
|
||||
def GetShowSickbeardEpisodePrefix(self, showName):
|
||||
show = self.__GetShowSubsection(showName)
|
||||
if show is None:
|
||||
return ""
|
||||
else:
|
||||
return show["SickbeardPrefix"]
|
||||
|
||||
def GetShow(self, showName):
|
||||
showSection = self.__GetShowSubsection(showName)
|
||||
if showSection is None:
|
||||
return None
|
||||
else:
|
||||
return showSection.name
|
||||
|
||||
def __GetShowSubsection(self, showName):
|
||||
if showName in self.GetShowNames():
|
||||
return self.__config["Shows"][showName]
|
||||
else: # check liases
|
||||
for show in self.GetShowNames():
|
||||
if showName in self.__config["Shows"][show]["alias"]:
|
||||
return self.__config["Shows"][show]
|
||||
|
||||
return None
|
||||
Reference in New Issue
Block a user