diff --git a/TorrentToMedia.py b/TorrentToMedia.py index b0e6effd..2b9b3dfd 100755 --- a/TorrentToMedia.py +++ b/TorrentToMedia.py @@ -266,6 +266,8 @@ def main(args): for section, subsections in nzbtomedia.SECTIONS.items(): for subsection in subsections: + if not nzbtomedia.CFG[section][subsection].isenabled(): + continue for dirName in nzbtomedia.getDirs(section, subsection, link='hard'): logger.info("Starting manual run for %s:%s - Folder:%s" % (section, subsection, dirName)) diff --git a/nzbToMedia.py b/nzbToMedia.py index 1d11d9a6..0497a91f 100755 --- a/nzbToMedia.py +++ b/nzbToMedia.py @@ -710,6 +710,8 @@ def main(args, section=None): for section, subsections in nzbtomedia.SECTIONS.items(): for subsection in subsections: + if not nzbtomedia.CFG[section][subsection].isenabled(): + continue for dirName in getDirs(section, subsection, link = 'move'): logger.info("Starting manual run for %s:%s - Folder:%s" % (section, subsection, dirName)) diff --git a/nzbtomedia/__init__.py b/nzbtomedia/__init__.py index cd4aa2ca..4be0df00 100644 --- a/nzbtomedia/__init__.py +++ b/nzbtomedia/__init__.py @@ -648,7 +648,8 @@ def initialize(section=None): # check for script-defied section and if None set to allow sections SECTIONS = CFG[tuple(x for x in CFG if CFG[x].sections and CFG[x].isenabled()) if not section else (section,)] - map(CATEGORIES.extend,([subsection.sections for section,subsection in SECTIONS.items()])) + for section,subsections in SECTIONS.items(): + CATEGORIES.extend([subsection for subsection in subsections if CFG[section][subsection].isenabled()]) CATEGORIES = list(set(CATEGORIES)) # create torrent class diff --git a/nzbtomedia/nzbToMediaUtil.py b/nzbtomedia/nzbToMediaUtil.py index 8b22d787..ac6e1873 100644 --- a/nzbtomedia/nzbToMediaUtil.py +++ b/nzbtomedia/nzbToMediaUtil.py @@ -99,13 +99,17 @@ def category_search(inputDirectory, inputName, inputCategory, root, categories): pathlist = os.path.normpath(inputDirectory).split(os.sep) - try: - inputCategory = list(set(pathlist) & set(categories))[-1] # assume last match is most relevant category. - logger.debug("SEARCH: Found Category: %s in directory structure" % (inputCategory)) - except IndexError: - inputCategory = "" - logger.debug("SEARCH: Could not find a category in the directory structure") - + if inputCategory and inputCategory in pathlist: + logger.debug("SEARCH: Found the Category: %s in directory structure" % (inputCategory)) + elif inputCategory: + logger.debug("SEARCH: Could not find the category: %s in the directory structure" % (inputCategory)) + else: + try: + inputCategory = list(set(pathlist) & set(categories))[-1] # assume last match is most relevant category. + logger.debug("SEARCH: Found Category: %s in directory structure" % (inputCategory)) + except IndexError: + inputCategory = "" + logger.debug("SEARCH: Could not find a category in the directory structure") if not os.path.isdir(inputDirectory) and os.path.isfile(inputDirectory): # If the input directory is a file if not inputName: inputName = os.path.split(os.path.normpath(inputDirectory))[1] return inputDirectory, inputName, inputCategory, root