mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-20 13:23:18 -07:00
Re-coded config class to better handle multiple subsection conditionals.
This commit is contained in:
parent
8425e0f377
commit
57019ec21b
12 changed files with 95 additions and 113 deletions
|
@ -14,7 +14,8 @@ from nzbtomedia.autoProcess.autoProcessMovie import autoProcessMovie
|
|||
from nzbtomedia.autoProcess.autoProcessMusic import autoProcessMusic
|
||||
from nzbtomedia.autoProcess.autoProcessTV import autoProcessTV
|
||||
from nzbtomedia.extractor import extractor
|
||||
from nzbtomedia.nzbToMediaUtil import category_search, safeName, is_sample, copy_link, parse_args, flatten, get_dirnames
|
||||
from nzbtomedia.nzbToMediaUtil import category_search, safeName, is_sample, copy_link, parse_args, flatten, get_dirnames, \
|
||||
remove_read_only
|
||||
from nzbtomedia.synchronousdeluge.client import DelugeClient
|
||||
from nzbtomedia.utorrent.client import UTorrentClient
|
||||
from nzbtomedia.transmissionrpc.client import Client as TransmissionClient
|
||||
|
@ -46,7 +47,7 @@ def main(inputDirectory, inputName, inputCategory, inputHash, inputID):
|
|||
outputDestination = os.path.normpath(os.path.join(nzbtomedia.OUTPUTDIRECTORY, inputCategory, safeName(inputName)))
|
||||
logger.postprocess("Output directory set to: %s", outputDestination)
|
||||
|
||||
if nzbtomedia.CFG["SickBeard"].issubsection(inputCategory):
|
||||
if nzbtomedia.CFG["SickBeard"][inputCategory]:
|
||||
Torrent_NoLink = int(nzbtomedia.CFG["SickBeard"][inputCategory]["Torrent_NoLink"]) # 0
|
||||
if Torrent_NoLink == 1:
|
||||
logger.postprocess("Calling autoProcessTV to post-process: %s",inputName)
|
||||
|
@ -71,7 +72,7 @@ def main(inputDirectory, inputName, inputCategory, inputHash, inputID):
|
|||
|
||||
logger.debug("Scanning files in directory: %s", inputDirectory)
|
||||
|
||||
if nzbtomedia.CFG["HeadPhones"].issubsection(inputCategory):
|
||||
if nzbtomedia.CFG["HeadPhones"][inputCategory]:
|
||||
nzbtomedia.NOFLATTEN.extend(nzbtomedia.CFG["HeadPhones"].sections) # Make sure we preserve folder structure for HeadPhones.
|
||||
|
||||
outputDestinationMaster = outputDestination # Save the original, so we can change this within the loop below, and reset afterwards.
|
||||
|
@ -118,12 +119,12 @@ def main(inputDirectory, inputName, inputCategory, inputHash, inputID):
|
|||
continue # This file has not been recently moved or created, skip it
|
||||
|
||||
if fileExtension in nzbtomedia.MEDIACONTAINER and is_sample(filePath, inputName, nzbtomedia.MINSAMPLESIZE,
|
||||
nzbtomedia.SAMPLEIDS) and not nzbtomedia.CFG["HeadPhones"].issubsection(inputCategory): # Ignore samples
|
||||
nzbtomedia.SAMPLEIDS) and not nzbtomedia.CFG["HeadPhones"][inputCategory]: # Ignore samples
|
||||
logger.postprocess("Ignoring sample file: %s ", filePath)
|
||||
continue
|
||||
|
||||
if fileExtension in nzbtomedia.COMPRESSEDCONTAINER:
|
||||
if (nzbtomedia.CFG["SickBeard"].issubsection(inputCategory) and nzbtomedia.CFG["SickBeard"][inputCategory]["nzbExtractionBy"] == "Destination"):
|
||||
if (nzbtomedia.CFG["SickBeard"][inputCategory] and nzbtomedia.CFG["SickBeard"][inputCategory]["nzbExtractionBy"] == "Destination"):
|
||||
# find part numbers in second "extension" from right, if we have more than 1 compressed file in the same directory.
|
||||
if re.search(r'\d+', os.path.splitext(fileName)[1]) and os.path.dirname(filePath) in extracted_folder and not any(item in os.path.splitext(fileName)[1] for item in ['.720p','.1080p','.x264']):
|
||||
part = int(re.search(r'\d+', os.path.splitext(fileName)[1]).group())
|
||||
|
@ -155,7 +156,7 @@ def main(inputDirectory, inputName, inputCategory, inputHash, inputID):
|
|||
remove_read_only(outputDestination)
|
||||
|
||||
# Now check if video files exist in destination:
|
||||
if nzbtomedia.CFG["SickBeard","NzbDrone", "CouchPotato"].issubsection(inputCategory):
|
||||
if nzbtomedia.CFG["SickBeard","NzbDrone", "CouchPotato"][inputCategory]:
|
||||
for dirpath, dirnames, filenames in os.walk(outputDestination):
|
||||
for file in filenames:
|
||||
filePath = os.path.join(dirpath, file)
|
||||
|
@ -168,7 +169,7 @@ def main(inputDirectory, inputName, inputCategory, inputHash, inputID):
|
|||
if video > int(0): # Check that media files exist
|
||||
logger.debug("Found %s media files", str(video))
|
||||
status = int(0)
|
||||
elif not (nzbtomedia.CFG["SickBeard"].issubsection(inputCategory) and nzbtomedia.CFG["SickBeard"][inputCategory]["nzbExtractionBy"] == "Destination") and archive > int(0):
|
||||
elif not (nzbtomedia.CFG["SickBeard"][inputCategory] and nzbtomedia.CFG["SickBeard"][inputCategory]["nzbExtractionBy"] == "Destination") and archive > int(0):
|
||||
logger.debug("Found %s archive files to be extracted by SickBeard", str(archive))
|
||||
status = int(0)
|
||||
else:
|
||||
|
@ -177,7 +178,7 @@ def main(inputDirectory, inputName, inputCategory, inputHash, inputID):
|
|||
if (inputCategory in nzbtomedia.USER_SCRIPT_CATEGORIES and not "NONE" in nzbtomedia.USER_SCRIPT_CATEGORIES) or ("ALL" in nzbtomedia.USER_SCRIPT_CATEGORIES and not inputCategory in processCategories):
|
||||
logger.postprocess("Processing user script %s.", user_script)
|
||||
result = external_script(outputDestination,inputName,inputCategory)
|
||||
elif status == int(0) or (nzbtomedia.CFG['HeadPhones','Mylar','Gamez'].issubsection(inputCategory)): # if movies linked/extracted or for other categories.
|
||||
elif status == int(0) or (nzbtomedia.CFG['HeadPhones','Mylar','Gamez'][inputCategory]): # if movies linked/extracted or for other categories.
|
||||
logger.debug("Calling autoProcess script for successful download.")
|
||||
status = int(0) # hp, my, gz don't support failed.
|
||||
else:
|
||||
|
@ -185,23 +186,23 @@ def main(inputDirectory, inputName, inputCategory, inputHash, inputID):
|
|||
sys.exit(-1)
|
||||
|
||||
result = 0
|
||||
if nzbtomedia.CFG['CouchPotato'].issubsection(inputCategory):
|
||||
if nzbtomedia.CFG['CouchPotato'][inputCategory]:
|
||||
logger.postprocess("Calling CouchPotato:" + inputCategory + " to post-process: %s", inputName)
|
||||
download_id = inputHash
|
||||
result = autoProcessMovie().process(outputDestination, inputName, status, nzbtomedia.CLIENTAGENT, download_id, inputCategory)
|
||||
elif nzbtomedia.CFG['SickBeard'].issubsection(inputCategory):
|
||||
elif nzbtomedia.CFG['SickBeard'][inputCategory]:
|
||||
logger.postprocess("Calling Sick-Beard:" + inputCategory + " to post-process: %s", inputName)
|
||||
result = autoProcessTV().processEpisode(outputDestination, inputName, status, nzbtomedia.CLIENTAGENT, inputCategory)
|
||||
elif nzbtomedia.CFG['NzbDrone'].issubsection(inputCategory):
|
||||
elif nzbtomedia.CFG['NzbDrone'][inputCategory]:
|
||||
logger.postprocess("Calling NzbDrone:" + inputCategory + " to post-process: %s", inputName)
|
||||
result = autoProcessTV().processEpisode(outputDestination, inputName, status, nzbtomedia.CLIENTAGENT, inputCategory)
|
||||
elif nzbtomedia.CFG['HeadPhones'].issubsection(inputCategory):
|
||||
elif nzbtomedia.CFG['HeadPhones'][inputCategory]:
|
||||
logger.postprocess("Calling HeadPhones:" + inputCategory + " to post-process: %s", inputName)
|
||||
result = autoProcessMusic().process(inputDirectory, inputName, status, nzbtomedia.CLIENTAGENT, inputCategory)
|
||||
elif nzbtomedia.CFG['Mylar'].issubsection(inputCategory):
|
||||
elif nzbtomedia.CFG['Mylar'][inputCategory]:
|
||||
logger.postprocess("Calling Mylar:" + inputCategory + " to post-process: %s", inputName)
|
||||
result = autoProcessComics().processEpisode(outputDestination, inputName, status, nzbtomedia.CLIENTAGENT, inputCategory)
|
||||
elif nzbtomedia.CFG['Gamez'].issubsection(inputCategory):
|
||||
elif nzbtomedia.CFG['Gamez'][inputCategory]:
|
||||
logger.postprocess("Calling Gamez:" + inputCategory + " to post-process: %s", inputName)
|
||||
result = autoProcessGames().process(outputDestination, inputName, status, nzbtomedia.CLIENTAGENT, inputCategory)
|
||||
|
||||
|
@ -401,7 +402,7 @@ if __name__ == "__main__":
|
|||
if inputDirectory is None:
|
||||
for section, subsection in nzbtomedia.SUBSECTIONS.items():
|
||||
for category in subsection:
|
||||
if nzbtomedia.CFG[section].isenabled(category):
|
||||
if nzbtomedia.CFG[section][category].isenabled():
|
||||
dirNames = get_dirnames(section, category)
|
||||
for dirName in dirNames:
|
||||
logger.postprocess("Running %s:%s as a manual run for folder %s ...", section, category, dirName)
|
||||
|
|
|
@ -216,7 +216,7 @@ else:
|
|||
logger.warning("Invalid number of arguments received from client.")
|
||||
for section, subsection in nzbtomedia.SUBSECTIONS['CouchPotato'].items():
|
||||
for category in subsection:
|
||||
if nzbtomedia.CFG[section].isenabled(category):
|
||||
if nzbtomedia.CFG[section][category].isenabled():
|
||||
dirNames = get_dirnames(section, category)
|
||||
for dirName in dirNames:
|
||||
logger.postprocess("Running %s:%s as a manual run on folder %s ...", section, category, dirName)
|
||||
|
|
|
@ -148,7 +148,7 @@ else:
|
|||
logger.warning("Invalid number of arguments received from client.")
|
||||
for section, subsection in nzbtomedia.SUBSECTIONS['Gamez'].items():
|
||||
for category in subsection:
|
||||
if nzbtomedia.CFG[section].isenabled(category):
|
||||
if nzbtomedia.CFG[section][category].isenabled():
|
||||
dirNames = get_dirnames(section, category)
|
||||
for dirName in dirNames:
|
||||
logger.postprocess("Running %s:%s as a manual run on folder %s ...", section, category, dirName)
|
||||
|
|
|
@ -158,7 +158,7 @@ else:
|
|||
logger.warning("Invalid number of arguments received from client.")
|
||||
for section, subsection in nzbtomedia.SUBSECTIONS['HeadPhones'].items():
|
||||
for category in subsection:
|
||||
if nzbtomedia.CFG[section].isenabled(category):
|
||||
if nzbtomedia.CFG[section][category].isenabled():
|
||||
dirNames = get_dirnames(section, category)
|
||||
for dirName in dirNames:
|
||||
logger.postprocess("nzbToHeadPhones running %s:%s as a manual run on folder %s ...", section, category, dirName)
|
||||
|
|
|
@ -313,19 +313,19 @@ from nzbtomedia import logger
|
|||
# post-processing
|
||||
def process(nzbDir, inputName=None, status=0, clientAgent='manual', download_id=None, inputCategory=None):
|
||||
|
||||
if nzbtomedia.CFG["CouchPotato"].issubsection(inputCategory):
|
||||
if nzbtomedia.CFG["CouchPotato"][inputCategory]:
|
||||
logger.postprocess("Calling CouchPotatoServer to post-process: %s", logger.MESSAGE), inputName
|
||||
return autoProcessMovie().process(nzbDir, inputName, status, clientAgent, download_id, inputCategory)
|
||||
elif nzbtomedia.CFG["SickBeard", "NzbDrone"].issubsection(inputCategory):
|
||||
elif nzbtomedia.CFG["SickBeard", "NzbDrone"][inputCategory]:
|
||||
logger.postprocess("Calling Sick-Beard to post-process: %s",logger.MESSAGE), inputName
|
||||
return autoProcessTV().processEpisode(nzbDir, inputName, status, clientAgent, inputCategory)
|
||||
elif nzbtomedia.CFG["HeadPhones"].issubsection(inputCategory):
|
||||
elif nzbtomedia.CFG["HeadPhones"][inputCategory]:
|
||||
logger.postprocess("Calling HeadPhones to post-process: %s", logger.MESSAGE), inputName
|
||||
return autoProcessMusic().process(nzbDir, inputName, status, clientAgent, inputCategory)
|
||||
elif nzbtomedia.CFG["Mylar"].issubsection(inputCategory):
|
||||
elif nzbtomedia.CFG["Mylar"][inputCategory]:
|
||||
logger.postprocess("Calling Mylar to post-process: %s",logger.MESSAGE), inputName
|
||||
return autoProcessComics().processEpisode(nzbDir, inputName, status, clientAgent, inputCategory)
|
||||
elif nzbtomedia.CFG["Gamez"].issubsection(inputCategory):
|
||||
elif nzbtomedia.CFG["Gamez"][inputCategory]:
|
||||
logger.postprocess("Calling Gamez to post-process: %s",logger.MESSAGE), inputName
|
||||
return autoProcessGames().process(nzbDir, inputName, status, clientAgent, inputCategory)
|
||||
else:
|
||||
|
@ -427,7 +427,7 @@ else:
|
|||
logger.warning("Invalid number of arguments received from client.")
|
||||
for section, subsection in nzbtomedia.SUBSECTIONS.items():
|
||||
for category in subsection:
|
||||
if nzbtomedia.CFG[section].isenabled(category):
|
||||
if nzbtomedia.CFG[section][category].isenabled():
|
||||
dirNames = get_dirnames(section, category)
|
||||
for dirName in dirNames:
|
||||
logger.postprocess("nzbToMedia running %s:%s as a manual run on folder %s ...", section, category, dirName)
|
||||
|
|
|
@ -153,18 +153,18 @@ else:
|
|||
result = 0
|
||||
|
||||
logger.warning("Invalid number of arguments received from client.")
|
||||
for section, subsection in nzbtomedia.SUBSECTIONS['Mylar'].items():
|
||||
for category in subsection:
|
||||
if nzbtomedia.CFG[section].isenabled(category):
|
||||
dirNames = get_dirnames(section, category)
|
||||
for dirName in dirNames:
|
||||
logger.postprocess("nzbToMylar running %s:%s as a manual run on folder %s ...", section, category, dirName)
|
||||
results = autoProcessComics().processEpisode(dirName, os.path.basename(dirName), 0, inputCategory=category)
|
||||
if results != 0:
|
||||
result = results
|
||||
logger.error("A problem was reported when trying to manually run %s:%s on folder %s ...", section, category, dirName)
|
||||
else:
|
||||
logger.postprocess("nzbToMylar %s:%s is DISABLED, you can enable this in autoProcessMedia.cfg ...", section, category)
|
||||
section = "Mylar"
|
||||
for category in nzbtomedia.SUBSECTIONS[section]:
|
||||
if nzbtomedia.SUBSECTIONS[section][category].isenabled():
|
||||
dirNames = get_dirnames(section, category)
|
||||
for dirName in dirNames:
|
||||
logger.postprocess("nzbToMylar running %s:%s as a manual run on folder %s ...", section, category, dirName)
|
||||
results = autoProcessComics().processEpisode(dirName, os.path.basename(dirName), 0, inputCategory=category)
|
||||
if results != 0:
|
||||
result = results
|
||||
logger.error("A problem was reported when trying to manually run %s:%s on folder %s ...", section, category, dirName)
|
||||
else:
|
||||
logger.postprocess("nzbToMylar %s:%s is DISABLED, you can enable this in autoProcessMedia.cfg ...", section, category)
|
||||
|
||||
if result == 0:
|
||||
logger.postprocess("The autoProcessComics script completed successfully.")
|
||||
|
|
|
@ -185,7 +185,7 @@ else:
|
|||
logger.warning("Invalid number of arguments received from client.")
|
||||
for section, subsection in nzbtomedia.SUBSECTIONS['NzbDrone'].items():
|
||||
for category in subsection:
|
||||
if nzbtomedia.CFG[section].isenabled(category):
|
||||
if nzbtomedia.CFG[section][category].isenabled():
|
||||
dirNames = get_dirnames(section, category)
|
||||
for dirName in dirNames:
|
||||
logger.postprocess("nzbToNzbDrone running %s:%s as a manual run on folder %s ...", section, category, dirName)
|
||||
|
|
|
@ -218,7 +218,7 @@ else:
|
|||
logger.warning("Invalid number of arguments received from client.")
|
||||
for section, subsection in nzbtomedia.SUBSECTIONS['SickBeard'].items():
|
||||
for category in subsection:
|
||||
if nzbtomedia.CFG[section].isenabled(category):
|
||||
if nzbtomedia.CFG[section][category].isenabled():
|
||||
dirNames = get_dirnames(section, category)
|
||||
for dirName in dirNames:
|
||||
logger.postprocess("nzbToSickBeard running %s:%s as a manual run on folder %s ...", section, category, dirName)
|
||||
|
|
|
@ -114,7 +114,6 @@ def initialize():
|
|||
# init logging
|
||||
logger.ntm_log_instance.initLogging()
|
||||
|
||||
|
||||
# run migrate to convert old cfg to new style cfg plus fix any cfg missing values/options.
|
||||
if not config.migrate():
|
||||
logger.error("Unable to load config from %s", CONFIG_FILE)
|
||||
|
@ -123,7 +122,9 @@ def initialize():
|
|||
if os.environ.has_key('NZBOP_SCRIPTDIR'):
|
||||
config.addnzbget()
|
||||
|
||||
# load newly migrated config
|
||||
logger.info("Loading config from %s", CONFIG_FILE)
|
||||
CFG = config()
|
||||
|
||||
# check for newer version
|
||||
versionCheck.CheckVersion().find_installed_version()
|
||||
|
@ -159,8 +160,8 @@ def initialize():
|
|||
SAMPLEIDS = (CFG["Extensions"]["SampleIDs"]) # sample,-s.
|
||||
|
||||
SECTIONS = ("CouchPotato", "SickBeard", "NzbDrone", "HeadPhones", "Mylar", "Gamez")
|
||||
SUBSECTIONS = CFG[SECTIONS].subsections
|
||||
CATEGORIES += CFG[SECTIONS].sections
|
||||
SUBSECTIONS = CFG[SECTIONS]
|
||||
CATEGORIES += SUBSECTIONS.sections
|
||||
|
||||
USER_SCRIPT_CATEGORIES = CFG["UserScript"]["user_script_categories"] # NONE
|
||||
|
||||
|
|
|
@ -5,67 +5,61 @@ import lib.configobj
|
|||
from itertools import chain
|
||||
|
||||
class Sections(dict):
|
||||
def issubsection(sections, subsection, checkenabled=True):
|
||||
# checks sections for subsection, returns true/false in {}
|
||||
def isenabled(sections):
|
||||
# checks if subsection enabled, returns true/false if subsection specified otherwise returns true/false in {}
|
||||
to_return = False
|
||||
for section in sections.values():
|
||||
to_return = section.issubsection(subsection, checkenabled)
|
||||
return to_return
|
||||
|
||||
def isenabled(sections, subsection):
|
||||
# checks if subsections are enabled, returns true/false in {}
|
||||
to_return = False
|
||||
for section in sections.values():
|
||||
to_return = section.isenabled(subsection)
|
||||
for section, subsection in sections.items():
|
||||
for item in subsection:
|
||||
if int(subsection[item]['enabled']) == 1:
|
||||
to_return = True
|
||||
return to_return
|
||||
|
||||
@property
|
||||
def sections(sections):
|
||||
# returns [subsections]
|
||||
to_return = []
|
||||
for section in sections:
|
||||
to_return.append(sections[section].sections)
|
||||
for section, subsection in sections.items():
|
||||
to_return.append(subsection)
|
||||
return list(set(chain.from_iterable(to_return)))
|
||||
|
||||
@property
|
||||
def subsections(sections):
|
||||
# returns {section name:[subsections]}
|
||||
to_return = {}
|
||||
for section in sections:
|
||||
to_return.update({section:sections[section].subsections})
|
||||
def __getitem__(self, key):
|
||||
# check for key in sections
|
||||
if key in self:
|
||||
return dict.__getitem__(self, key)
|
||||
|
||||
# check for key in subsections
|
||||
to_return = Sections()
|
||||
for section, subsection in self.items():
|
||||
if key in subsection:
|
||||
to_return.update({section:{key:dict.__getitem__(subsection, key)}})
|
||||
return to_return
|
||||
|
||||
class Section(lib.configobj.Section):
|
||||
def issubsection(section, subsection, checkenabled=True):
|
||||
# checks section for subsection, returns true/false
|
||||
to_return = False
|
||||
if subsection in section:
|
||||
if checkenabled and section.isenabled(subsection):
|
||||
to_return = True
|
||||
else:
|
||||
to_return = True
|
||||
return to_return
|
||||
|
||||
def isenabled(section, subsection):
|
||||
def isenabled(section):
|
||||
# checks if subsection enabled, returns true/false if subsection specified otherwise returns true/false in {}
|
||||
to_return = False
|
||||
if subsection in section and int(section[subsection]['enabled']) == 1:
|
||||
to_return = True
|
||||
return to_return
|
||||
|
||||
@property
|
||||
def subsections(section):
|
||||
# returns {section name:[subsections]}
|
||||
to_return = {}
|
||||
for subsection in section:
|
||||
to_return.update({subsection:section[subsection]})
|
||||
return to_return
|
||||
if section:
|
||||
if int(section['enabled']) == 1:
|
||||
return True
|
||||
return False
|
||||
|
||||
def findsection(section, key):
|
||||
for subsection in section:
|
||||
if key in section[subsection]:
|
||||
return subsection
|
||||
|
||||
def __getitem__(self, key):
|
||||
# check for key in section
|
||||
if key in self.keys():
|
||||
return dict.__getitem__(self, key)
|
||||
|
||||
# check for key in subsection
|
||||
result = Sections()
|
||||
for section in key:
|
||||
if section in self:
|
||||
subsection = dict.__getitem__(self, section)
|
||||
result.update({section: subsection})
|
||||
return result
|
||||
|
||||
class ConfigObj(lib.configobj.ConfigObj, Section):
|
||||
def __init__(self, *args, **kw):
|
||||
if len(args) == 0:
|
||||
|
@ -73,18 +67,6 @@ class ConfigObj(lib.configobj.ConfigObj, Section):
|
|||
super(lib.configobj.ConfigObj, self).__init__(*args, **kw)
|
||||
self.interpolation = False
|
||||
|
||||
def __getitem__(self, key):
|
||||
result = Sections()
|
||||
if isinstance(key, tuple):
|
||||
for item in key:
|
||||
val = dict.__getitem__(self, item)
|
||||
result.update({item: val})
|
||||
return result
|
||||
else:
|
||||
val = dict.__getitem__(self, key)
|
||||
#result.update({key: val})
|
||||
return val
|
||||
|
||||
@staticmethod
|
||||
def migrate():
|
||||
global CFG_NEW, CFG_OLD
|
||||
|
@ -211,9 +193,6 @@ class ConfigObj(lib.configobj.ConfigObj, Section):
|
|||
with open(nzbtomedia.CONFIG_FILE, 'wb') as configFile:
|
||||
CFG_NEW.write(configFile)
|
||||
|
||||
# reload config
|
||||
nzbtomedia.CFG = CFG_NEW
|
||||
|
||||
return True
|
||||
|
||||
@staticmethod
|
||||
|
@ -350,9 +329,6 @@ class ConfigObj(lib.configobj.ConfigObj, Section):
|
|||
with open(nzbtomedia.CONFIG_FILE, 'wb') as configFile:
|
||||
CFG_NEW.write(configFile)
|
||||
|
||||
# reload config
|
||||
nzbtomedia.CFG = CFG_NEW
|
||||
|
||||
lib.configobj.Section = Section
|
||||
lib.configobj.ConfigObj = ConfigObj
|
||||
config = ConfigObj
|
||||
|
|
|
@ -381,7 +381,7 @@ def get_dirnames(section, subsections=None):
|
|||
dirNames = []
|
||||
|
||||
if subsections is None:
|
||||
subsections = nzbtomedia.CFG[section].subsections.values()
|
||||
subsections = nzbtomedia.SUBSECTIONS[section].sections
|
||||
|
||||
if not isinstance(subsections, list):
|
||||
subsections = [subsections]
|
||||
|
|
|
@ -4,25 +4,29 @@ from nzbtomedia import logger
|
|||
|
||||
# Initialize the config
|
||||
nzbtomedia.initialize()
|
||||
print nzbtomedia.CFG['SickBear','NzbDrone']['tv'].isenabled()
|
||||
print nzbtomedia.CFG['SickBeard','NzbDrone']['tv'].isenabled()
|
||||
|
||||
print nzbtomedia.SUBSECTIONS["SickBeard"].items()
|
||||
if nzbtomedia.CFG['SickBeard', 'NzbDrone', 'CouchPotato']['tv']:
|
||||
print True
|
||||
else:
|
||||
print False
|
||||
|
||||
if nzbtomedia.CFG['SickBeard']['tv']:
|
||||
print True
|
||||
else:
|
||||
print False
|
||||
|
||||
print
|
||||
print nzbtomedia.SUBSECTIONS["SickBeard"]
|
||||
print
|
||||
print nzbtomedia.CFG.findsection('tv')
|
||||
print
|
||||
print nzbtomedia.CFG.sections
|
||||
print
|
||||
sections = ("CouchPotato", "SickBeard", "NzbDrone", "HeadPhones", "Mylar", "Gamez")
|
||||
print nzbtomedia.CFG[sections].subsections
|
||||
print nzbtomedia.CFG['SickBeard'].subsections
|
||||
print
|
||||
print nzbtomedia.CFG[sections].sections
|
||||
print nzbtomedia.CFG['SickBeard'].sections
|
||||
print
|
||||
print nzbtomedia.CFG['SickBeard','NzbDrone']
|
||||
print nzbtomedia.CFG['SickBeard']
|
||||
print
|
||||
print nzbtomedia.CFG['SickBeard','NzbDrone','CouchPotato'].issubsection('tv', True)
|
||||
print nzbtomedia.CFG['SickBeard'].issubsection('tv', True)
|
||||
print
|
||||
print nzbtomedia.CFG['SickBeard','NzbDrone'].isenabled('tv')
|
||||
print nzbtomedia.CFG['SickBeard'].isenabled('tv')
|
||||
print nzbtomedia.CFG['SickBeard']
|
Loading…
Add table
Add a link
Reference in a new issue