recordingprocessing/libsettings.py

129 lines
3.5 KiB
Python
Raw Normal View History

2013-07-05 21:27:53 +10:00
# -*- coding: utf-8 -*-
"""
Created on Fri Jul 5 20:14:15 2013
@author: shanef
"""
2013-07-08 17:21:42 +10:00
from configobj import ConfigObj
2013-07-05 21:30:01 +10:00
2013-07-11 00:30:00 +10:00
#==============================================================================
# class ShowSettings:
# """
# Container for the settings for a show
# """
#
# def __init__(self, name, inputdirectory, outputdirectory):
# self.name = name
# self.inputdirectory = inputdirectory
# self.outputdirectory = outputdirectory
#==============================================================================
2013-07-06 21:10:16 +10:00
2013-07-08 17:21:42 +10:00
2013-07-05 21:30:01 +10:00
class Settings:
2013-07-11 00:30:00 +10:00
"""
Accessor for the configuration file
"""
def __init__(self, settingsfile):
self.__config = ConfigObj(settingsfile)
def tvrecordingdirectory(self):
2013-07-08 17:21:42 +10:00
return self.__config["TVRecordings"]
2013-07-11 00:30:00 +10:00
def handbrakecommand(self):
2013-07-08 17:21:42 +10:00
return self.__config["HandbrakeCommand"]
2013-07-11 00:30:00 +10:00
def mythtvaddress(self):
2013-07-08 17:21:42 +10:00
return self.__config["MythTV"]["address"]
2013-07-11 00:30:00 +10:00
def mythtvuser(self):
return self.__config["MythTV"]["user"]
def mythtvpassword(self):
2013-07-08 17:21:42 +10:00
return self.__config["MythTV"]["password"]
2013-07-05 21:30:01 +10:00
2013-07-11 00:30:00 +10:00
def mythtvdatabase(self):
2013-07-08 17:21:42 +10:00
return self.__config["MythTV"]["database"]
2013-07-11 00:30:00 +10:00
def sickbeardaddress(self):
2013-07-08 17:21:42 +10:00
return self.__config["Sickbeard"]["address"]
2013-07-11 00:30:00 +10:00
def sickbeardport(self):
2013-07-08 17:21:42 +10:00
return int(self.__config["Sickbeard"]["port"])
2013-07-11 00:30:00 +10:00
def sickbeardapikey(self):
2013-07-08 17:21:42 +10:00
return self.__config["Sickbeard"]["APIKey"]
2013-07-11 00:30:00 +10:00
def unknowndirectory(self):
2013-07-08 17:21:42 +10:00
return self.__config["Shows"]["UnknownInput"]
2013-07-11 00:30:00 +10:00
def getshownames(self, includealias=False):
2013-07-08 17:21:42 +10:00
shows = self.__config["Shows"].sections
result = shows[:]
2013-07-11 00:30:00 +10:00
if includealias:
2013-07-08 17:21:42 +10:00
for show in shows:
for alias in self.__config["Shows"][show]["alias"]:
result.append(alias)
return result
2013-07-11 00:30:00 +10:00
def getshowinputdirectory(self, showname):
show = self.__getshowsubsection(showname)
2013-07-08 17:21:42 +10:00
if show is None:
return ""
else:
return show["InputDirectory"]
2013-07-08 17:40:55 +10:00
2013-07-11 00:30:00 +10:00
def getshowunknowndirectory(self, showname):
show = self.__getshowsubsection(showname)
2013-07-08 17:40:55 +10:00
if show is None:
return ""
else:
return show["UnknownDirectory"]
2013-07-11 00:30:00 +10:00
def getshowoutputdirectory(self, showname):
show = self.__getshowsubsection(showname)
2013-07-08 17:21:42 +10:00
if show is None:
return ""
else:
return show["OutputDirectory"]
2013-07-11 00:30:00 +10:00
def getshowalias(self, showname):
show = self.__getshowsubsection(showname)
2013-07-08 17:21:42 +10:00
if show is None:
return ""
else:
return show["alias"]
2013-07-11 00:30:00 +10:00
def getshowmythtvepisodeprefix(self, showname):
show = self.__getshowsubsection(showname)
2013-07-08 17:21:42 +10:00
if show is None:
return ""
else:
return show["MythTvEpisodePrefix"]
2013-07-11 00:30:00 +10:00
def getshowsickbearsepisodeprefix(self, showname):
show = self.__getshowsubsection(showname)
2013-07-08 17:21:42 +10:00
if show is None:
return ""
else:
return show["SickbeardPrefix"]
2013-07-11 00:30:00 +10:00
def getshow(self, showname):
showsection = self.__getshowsubsection(showname)
if showsection is None:
2013-07-08 17:21:42 +10:00
return None
else:
2013-07-11 00:30:00 +10:00
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"]:
2013-07-08 17:21:42 +10:00
return self.__config["Shows"][show]
2013-07-11 00:30:00 +10:00
return None