mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-19 21:03:14 -07:00
Monkey Patched our config class.
Fixed code for enabled check. Tweaked a few things here and there.
This commit is contained in:
parent
cd0eb9a83a
commit
0ca0e43752
14 changed files with 72 additions and 82 deletions
|
@ -48,7 +48,7 @@ def main(inputDirectory, inputName, inputCategory, inputHash, inputID):
|
||||||
|
|
||||||
Logger.debug("MAIN: Determined Directory: %s | Name: %s | Category: %s", inputDirectory, inputName, inputCategory)
|
Logger.debug("MAIN: Determined Directory: %s | Name: %s | Category: %s", inputDirectory, inputName, inputCategory)
|
||||||
|
|
||||||
if config.issubsection(inputCategory,["SickBeard","NzbDrone"]):
|
if config().issubsection(inputCategory,["SickBeard","NzbDrone"]):
|
||||||
Logger.info("MAIN: Calling autoProcessTV to post-process: %s",inputName)
|
Logger.info("MAIN: Calling autoProcessTV to post-process: %s",inputName)
|
||||||
result = autoProcessTV().processEpisode(inputDirectory, inputName, 0, clientAgent=clientAgent, inputCategory=inputCategory)
|
result = autoProcessTV().processEpisode(inputDirectory, inputName, 0, clientAgent=clientAgent, inputCategory=inputCategory)
|
||||||
if result != 0:
|
if result != 0:
|
||||||
|
@ -128,8 +128,8 @@ def main(inputDirectory, inputName, inputCategory, inputHash, inputID):
|
||||||
|
|
||||||
Logger.debug("MAIN: Scanning files in directory: %s", inputDirectory)
|
Logger.debug("MAIN: Scanning files in directory: %s", inputDirectory)
|
||||||
|
|
||||||
if config.issubsection(inputCategory, "HeadPhones"):
|
if config().issubsection(inputCategory, "HeadPhones"):
|
||||||
noFlatten.extend(list(chain.from_iterable(config.get_subsections("HeadPhones")))) # Make sure we preserve folder structure for HeadPhones.
|
noFlatten.extend(list(chain.from_iterable(config().get_subsections("HeadPhones")))) # 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.
|
outputDestinationMaster = outputDestination # Save the original, so we can change this within the loop below, and reset afterwards.
|
||||||
now = datetime.datetime.now()
|
now = datetime.datetime.now()
|
||||||
|
@ -170,7 +170,7 @@ def main(inputDirectory, inputName, inputCategory, inputHash, inputID):
|
||||||
continue # This file has not been recently moved or created, skip it
|
continue # This file has not been recently moved or created, skip it
|
||||||
|
|
||||||
if fileExtension in mediaContainer: # If the file is a video file
|
if fileExtension in mediaContainer: # If the file is a video file
|
||||||
if is_sample(filePath, inputName, minSampleSize, SampleIDs) and not config.issubsection(inputCategory, ["HeadPhones"]): # Ignore samples
|
if is_sample(filePath, inputName, minSampleSize, SampleIDs) and not config().issubsection(inputCategory, ["HeadPhones"]): # Ignore samples
|
||||||
Logger.info("MAIN: Ignoring sample file: %s ", filePath)
|
Logger.info("MAIN: Ignoring sample file: %s ", filePath)
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
|
@ -206,7 +206,7 @@ def main(inputDirectory, inputName, inputCategory, inputHash, inputID):
|
||||||
except:
|
except:
|
||||||
Logger.exception("MAIN: Extraction failed for: %s", file)
|
Logger.exception("MAIN: Extraction failed for: %s", file)
|
||||||
continue
|
continue
|
||||||
elif not config.issubsection(inputCategory,['CouchPotato','SickBeard','NzbDrone']): #process all for non-video categories.
|
elif not config().issubsection(inputCategory,['CouchPotato','SickBeard','NzbDrone']): #process all for non-video categories.
|
||||||
Logger.info("MAIN: Found file %s for category %s", filePath, inputCategory)
|
Logger.info("MAIN: Found file %s for category %s", filePath, inputCategory)
|
||||||
copy_link(filePath, targetDirectory, useLink, outputDestination)
|
copy_link(filePath, targetDirectory, useLink, outputDestination)
|
||||||
copy_list.append([filePath, os.path.join(outputDestination, file)])
|
copy_list.append([filePath, os.path.join(outputDestination, file)])
|
||||||
|
@ -220,7 +220,7 @@ def main(inputDirectory, inputName, inputCategory, inputHash, inputID):
|
||||||
flatten(outputDestination)
|
flatten(outputDestination)
|
||||||
|
|
||||||
# Now check if video files exist in destination:
|
# Now check if video files exist in destination:
|
||||||
if config.issubsection(inputCategory,["SickBeard","NzbDrone"]):
|
if config().issubsection(inputCategory,["SickBeard","NzbDrone"]):
|
||||||
for dirpath, dirnames, filenames in os.walk(outputDestination):
|
for dirpath, dirnames, filenames in os.walk(outputDestination):
|
||||||
for file in filenames:
|
for file in filenames:
|
||||||
filePath = os.path.join(dirpath, file)
|
filePath = os.path.join(dirpath, file)
|
||||||
|
@ -245,7 +245,7 @@ def main(inputDirectory, inputName, inputCategory, inputHash, inputID):
|
||||||
if (inputCategory in user_script_categories and not "NONE" in user_script_categories) or ("ALL" in user_script_categories and not inputCategory in processCategories):
|
if (inputCategory in user_script_categories and not "NONE" in user_script_categories) or ("ALL" in user_script_categories and not inputCategory in processCategories):
|
||||||
Logger.info("MAIN: Processing user script %s.", user_script)
|
Logger.info("MAIN: Processing user script %s.", user_script)
|
||||||
result = external_script(outputDestination,inputName,inputCategory)
|
result = external_script(outputDestination,inputName,inputCategory)
|
||||||
elif status == int(0) or (config.issubsection(inputCategory,['HeadPhones','Mylar','Gamez'])): # if movies linked/extracted or for other categories.
|
elif status == int(0) or (config().issubsection(inputCategory,['HeadPhones','Mylar','Gamez'])): # if movies linked/extracted or for other categories.
|
||||||
Logger.debug("MAIN: Calling autoProcess script for successful download.")
|
Logger.debug("MAIN: Calling autoProcess script for successful download.")
|
||||||
status = int(0) # hp, my, gz don't support failed.
|
status = int(0) # hp, my, gz don't support failed.
|
||||||
else:
|
else:
|
||||||
|
@ -253,23 +253,23 @@ def main(inputDirectory, inputName, inputCategory, inputHash, inputID):
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
|
|
||||||
result = 0
|
result = 0
|
||||||
if config.issubsection(inputCategory,['CouchPotato']):
|
if config().issubsection(inputCategory,['CouchPotato']):
|
||||||
Logger.info("MAIN: Calling CouchPotato:" + inputCategory + " to post-process: %s", inputName)
|
Logger.info("MAIN: Calling CouchPotato:" + inputCategory + " to post-process: %s", inputName)
|
||||||
download_id = inputHash
|
download_id = inputHash
|
||||||
result = autoProcessMovie().process(outputDestination, inputName, status, clientAgent, download_id, inputCategory)
|
result = autoProcessMovie().process(outputDestination, inputName, status, clientAgent, download_id, inputCategory)
|
||||||
elif config.issubsection(inputCategory,['SickBeard']):
|
elif config().issubsection(inputCategory,['SickBeard']):
|
||||||
Logger.info("MAIN: Calling Sick-Beard:" + inputCategory + " to post-process: %s", inputName)
|
Logger.info("MAIN: Calling Sick-Beard:" + inputCategory + " to post-process: %s", inputName)
|
||||||
result = autoProcessTV().processEpisode(outputDestination, inputName, status, clientAgent, inputCategory)
|
result = autoProcessTV().processEpisode(outputDestination, inputName, status, clientAgent, inputCategory)
|
||||||
elif config.issubsection(inputCategory,['NzbDrone']):
|
elif config().issubsection(inputCategory,['NzbDrone']):
|
||||||
Logger.info("MAIN: Calling NzbDrone:" + inputCategory + " to post-process: %s", inputName)
|
Logger.info("MAIN: Calling NzbDrone:" + inputCategory + " to post-process: %s", inputName)
|
||||||
result = autoProcessTV().processEpisode(outputDestination, inputName, status, clientAgent, inputCategory)
|
result = autoProcessTV().processEpisode(outputDestination, inputName, status, clientAgent, inputCategory)
|
||||||
elif config.issubsection(inputCategory,['HeadPhones']):
|
elif config().issubsection(inputCategory,['HeadPhones']):
|
||||||
Logger.info("MAIN: Calling HeadPhones:" + inputCategory + " to post-process: %s", inputName)
|
Logger.info("MAIN: Calling HeadPhones:" + inputCategory + " to post-process: %s", inputName)
|
||||||
result = autoProcessMusic().process(inputDirectory, inputName, status, clientAgent, inputCategory)
|
result = autoProcessMusic().process(inputDirectory, inputName, status, clientAgent, inputCategory)
|
||||||
elif config.issubsection(inputCategory,['Mylar']):
|
elif config().issubsection(inputCategory,['Mylar']):
|
||||||
Logger.info("MAIN: Calling Mylar:" + inputCategory + " to post-process: %s", inputName)
|
Logger.info("MAIN: Calling Mylar:" + inputCategory + " to post-process: %s", inputName)
|
||||||
result = autoProcessComics().processEpisode(outputDestination, inputName, status, clientAgent, inputCategory)
|
result = autoProcessComics().processEpisode(outputDestination, inputName, status, clientAgent, inputCategory)
|
||||||
elif config.issubsection(inputCategory,['Gamez']):
|
elif config().issubsection(inputCategory,['Gamez']):
|
||||||
Logger.info("MAIN: Calling Gamez:" + inputCategory + " to post-process: %s", inputName)
|
Logger.info("MAIN: Calling Gamez:" + inputCategory + " to post-process: %s", inputName)
|
||||||
result = autoProcessGames().process(outputDestination, inputName, status, clientAgent, inputCategory)
|
result = autoProcessGames().process(outputDestination, inputName, status, clientAgent, inputCategory)
|
||||||
|
|
||||||
|
@ -393,7 +393,7 @@ def external_script(outputDestination,torrentName,torrentLabel):
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
# run migrate to convert old cfg to new style cfg plus fix any cfg missing values/options.
|
# run migrate to convert old cfg to new style cfg plus fix any cfg missing values/options.
|
||||||
if config.migrate():
|
if config().migrate():
|
||||||
nzbtomedia_configure_logging(config.LOG_FILE)
|
nzbtomedia_configure_logging(config.LOG_FILE)
|
||||||
Logger = logging.getLogger(__name__)
|
Logger = logging.getLogger(__name__)
|
||||||
Logger.info("====================") # Seperate old from new log
|
Logger.info("====================") # Seperate old from new log
|
||||||
|
@ -435,7 +435,7 @@ if __name__ == "__main__":
|
||||||
minSampleSize = int(config()["Extensions"]["minSampleSize"]) # 200 (in MB)
|
minSampleSize = int(config()["Extensions"]["minSampleSize"]) # 200 (in MB)
|
||||||
SampleIDs = (config()["Extensions"]["SampleIDs"]) # sample,-s.
|
SampleIDs = (config()["Extensions"]["SampleIDs"]) # sample,-s.
|
||||||
|
|
||||||
subsections = config.get_subsections(["CouchPotato", "SickBeard", "NzbDrone", "HeadPhones", "Mylar", "Gamez"])
|
subsections = config().get_subsections(["CouchPotato", "SickBeard", "NzbDrone", "HeadPhones", "Mylar", "Gamez"])
|
||||||
categories += list(chain.from_iterable(subsections.values()))
|
categories += list(chain.from_iterable(subsections.values()))
|
||||||
|
|
||||||
user_script_categories = config()["UserScript"]["user_script_categories"] # NONE
|
user_script_categories = config()["UserScript"]["user_script_categories"] # NONE
|
||||||
|
@ -465,7 +465,7 @@ if __name__ == "__main__":
|
||||||
if inputDirectory is None:
|
if inputDirectory is None:
|
||||||
for section, subsection in subsections.iteritems():
|
for section, subsection in subsections.iteritems():
|
||||||
for category in subsection:
|
for category in subsection:
|
||||||
if config.isenabled(section, category):
|
if config().isenabled(section, category):
|
||||||
dirNames = get_dirnames(section, category)
|
dirNames = get_dirnames(section, category)
|
||||||
Logger.info("MAIN: TorrentToMedia running %s:%s as a manual run...", section, category)
|
Logger.info("MAIN: TorrentToMedia running %s:%s as a manual run...", section, category)
|
||||||
for dirName in dirNames:
|
for dirName in dirNames:
|
||||||
|
|
|
@ -133,10 +133,10 @@ from nzbtomedia.nzbToMediaConfig import config
|
||||||
from nzbtomedia.nzbToMediaUtil import nzbtomedia_configure_logging, WakeUp, get_dirnames
|
from nzbtomedia.nzbToMediaUtil import nzbtomedia_configure_logging, WakeUp, get_dirnames
|
||||||
|
|
||||||
# run migrate to convert old cfg to new style cfg plus fix any cfg missing values/options.
|
# run migrate to convert old cfg to new style cfg plus fix any cfg missing values/options.
|
||||||
if config.migrate():
|
if config().migrate():
|
||||||
# check to write settings from nzbGet UI to autoProcessMedia.cfg.
|
# check to write settings from nzbGet UI to autoProcessMedia.cfg.
|
||||||
if os.environ.has_key('NZBOP_SCRIPTDIR'):
|
if os.environ.has_key('NZBOP_SCRIPTDIR'):
|
||||||
config.addnzbget()
|
config().addnzbget()
|
||||||
|
|
||||||
nzbtomedia_configure_logging(config.LOG_FILE)
|
nzbtomedia_configure_logging(config.LOG_FILE)
|
||||||
Logger = logging.getLogger(__name__)
|
Logger = logging.getLogger(__name__)
|
||||||
|
@ -233,12 +233,12 @@ else:
|
||||||
result = 0
|
result = 0
|
||||||
|
|
||||||
# init sub-sections
|
# init sub-sections
|
||||||
subsections = config.get_subsections(["CouchPotato"])
|
subsections = config().get_subsections(["CouchPotato"])
|
||||||
|
|
||||||
Logger.warn("MAIN: Invalid number of arguments received from client.")
|
Logger.warn("MAIN: Invalid number of arguments received from client.")
|
||||||
for section, subsection in subsections.items():
|
for section, subsection in subsections.items():
|
||||||
for category in subsection:
|
for category in subsection:
|
||||||
if config.isenabled(section, category):
|
if config().isenabled(section, category):
|
||||||
dirNames = get_dirnames(section, category)
|
dirNames = get_dirnames(section, category)
|
||||||
for dirName in dirNames:
|
for dirName in dirNames:
|
||||||
Logger.info("MAIN: nzbToCouchPotato running %s:%s as a manual run...", section, subsection)
|
Logger.info("MAIN: nzbToCouchPotato running %s:%s as a manual run...", section, subsection)
|
||||||
|
|
|
@ -68,10 +68,10 @@ from nzbtomedia.nzbToMediaConfig import config
|
||||||
from nzbtomedia.nzbToMediaUtil import WakeUp, nzbtomedia_configure_logging, get_dirnames
|
from nzbtomedia.nzbToMediaUtil import WakeUp, nzbtomedia_configure_logging, get_dirnames
|
||||||
|
|
||||||
# run migrate to convert old cfg to new style cfg plus fix any cfg missing values/options.
|
# run migrate to convert old cfg to new style cfg plus fix any cfg missing values/options.
|
||||||
if config.migrate():
|
if config().migrate():
|
||||||
# check to write settings from nzbGet UI to autoProcessMedia.cfg.
|
# check to write settings from nzbGet UI to autoProcessMedia.cfg.
|
||||||
if os.environ.has_key('NZBOP_SCRIPTDIR'):
|
if os.environ.has_key('NZBOP_SCRIPTDIR'):
|
||||||
config.addnzbget()
|
config().addnzbget()
|
||||||
|
|
||||||
nzbtomedia_configure_logging(config.LOG_FILE)
|
nzbtomedia_configure_logging(config.LOG_FILE)
|
||||||
Logger = logging.getLogger(__name__)
|
Logger = logging.getLogger(__name__)
|
||||||
|
@ -83,7 +83,7 @@ else:
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
|
|
||||||
# gamez category
|
# gamez category
|
||||||
sections = config.get_subsections(['Gamez'])
|
sections = config().get_subsections(['Gamez'])
|
||||||
|
|
||||||
WakeUp()
|
WakeUp()
|
||||||
|
|
||||||
|
@ -163,12 +163,12 @@ else:
|
||||||
result = 0
|
result = 0
|
||||||
|
|
||||||
# init sub-sections
|
# init sub-sections
|
||||||
subsections = config.get_subsections(["Gamez"])
|
subsections = config().get_subsections(["Gamez"])
|
||||||
|
|
||||||
Logger.warn("MAIN: Invalid number of arguments received from client.")
|
Logger.warn("MAIN: Invalid number of arguments received from client.")
|
||||||
for section, subsection in subsections.items():
|
for section, subsection in subsections.items():
|
||||||
for category in subsection:
|
for category in subsection:
|
||||||
if config.isenabled(section, category):
|
if config().isenabled(section, category):
|
||||||
dirNames = get_dirnames(section, category)
|
dirNames = get_dirnames(section, category)
|
||||||
for dirName in dirNames:
|
for dirName in dirNames:
|
||||||
Logger.info("MAIN: nzbToGamez running %s:%s as a manual run...", section, category)
|
Logger.info("MAIN: nzbToGamez running %s:%s as a manual run...", section, category)
|
||||||
|
|
|
@ -81,10 +81,10 @@ from nzbtomedia.nzbToMediaConfig import config
|
||||||
from nzbtomedia.nzbToMediaUtil import get_dirnames, WakeUp, nzbtomedia_configure_logging
|
from nzbtomedia.nzbToMediaUtil import get_dirnames, WakeUp, nzbtomedia_configure_logging
|
||||||
|
|
||||||
# run migrate to convert old cfg to new style cfg plus fix any cfg missing values/options.
|
# run migrate to convert old cfg to new style cfg plus fix any cfg missing values/options.
|
||||||
if config.migrate():
|
if config().migrate():
|
||||||
# check to write settings from nzbGet UI to autoProcessMedia.cfg.
|
# check to write settings from nzbGet UI to autoProcessMedia.cfg.
|
||||||
if os.environ.has_key('NZBOP_SCRIPTDIR'):
|
if os.environ.has_key('NZBOP_SCRIPTDIR'):
|
||||||
config.addnzbget()
|
config().addnzbget()
|
||||||
|
|
||||||
nzbtomedia_configure_logging(config.LOG_FILE)
|
nzbtomedia_configure_logging(config.LOG_FILE)
|
||||||
Logger = logging.getLogger(__name__)
|
Logger = logging.getLogger(__name__)
|
||||||
|
@ -173,12 +173,12 @@ else:
|
||||||
result = 0
|
result = 0
|
||||||
|
|
||||||
# init sub-sections
|
# init sub-sections
|
||||||
subsections = config.get_subsections(["HeadPhones"])
|
subsections = config().get_subsections(["HeadPhones"])
|
||||||
|
|
||||||
Logger.warn("MAIN: Invalid number of arguments received from client.")
|
Logger.warn("MAIN: Invalid number of arguments received from client.")
|
||||||
for section, subsection in subsections.items():
|
for section, subsection in subsections.items():
|
||||||
for category in subsection:
|
for category in subsection:
|
||||||
if config.isenabled(section, category):
|
if config().isenabled(section, category):
|
||||||
dirNames = get_dirnames(section, category)
|
dirNames = get_dirnames(section, category)
|
||||||
for dirName in dirNames:
|
for dirName in dirNames:
|
||||||
Logger.info("MAIN: nzbToHeadPhones running %s:%s as a manual run...", section, category)
|
Logger.info("MAIN: nzbToHeadPhones running %s:%s as a manual run...", section, category)
|
||||||
|
|
|
@ -339,10 +339,10 @@ def process(nzbDir, inputName=None, status=0, clientAgent='manual', download_id=
|
||||||
########################################################################################################################
|
########################################################################################################################
|
||||||
|
|
||||||
# run migrate to convert old cfg to new style cfg plus fix any cfg missing values/options.
|
# run migrate to convert old cfg to new style cfg plus fix any cfg missing values/options.
|
||||||
if config.migrate():
|
if config().migrate():
|
||||||
# check to write settings from nzbGet UI to autoProcessMedia.cfg.
|
# check to write settings from nzbGet UI to autoProcessMedia.cfg.
|
||||||
if os.environ.has_key('NZBOP_SCRIPTDIR'):
|
if os.environ.has_key('NZBOP_SCRIPTDIR'):
|
||||||
config.addnzbget()
|
config().addnzbget()
|
||||||
|
|
||||||
nzbtomedia_configure_logging(config.LOG_FILE)
|
nzbtomedia_configure_logging(config.LOG_FILE)
|
||||||
|
|
||||||
|
@ -443,12 +443,12 @@ else:
|
||||||
result = 0
|
result = 0
|
||||||
|
|
||||||
# init sub-sections
|
# init sub-sections
|
||||||
subsections = config.get_subsections(["CouchPotato", "SickBeard", "NzbDrone", "HeadPhones", "Mylar", "Gamez"])
|
subsections = config().get_subsections(["CouchPotato", "SickBeard", "NzbDrone", "HeadPhones", "Mylar", "Gamez"])
|
||||||
|
|
||||||
Logger.warn("MAIN: Invalid number of arguments received from client.")
|
Logger.warn("MAIN: Invalid number of arguments received from client.")
|
||||||
for section, subsection in subsections.items():
|
for section, subsection in subsections.items():
|
||||||
for category in subsection:
|
for category in subsection:
|
||||||
if config.isenabled(section, category):
|
if config().isenabled(section, category):
|
||||||
dirNames = get_dirnames(section, category)
|
dirNames = get_dirnames(section, category)
|
||||||
for dirName in dirNames:
|
for dirName in dirNames:
|
||||||
Logger.info("MAIN: nzbToMedia running %s:%s as a manual run...", section, category)
|
Logger.info("MAIN: nzbToMedia running %s:%s as a manual run...", section, category)
|
||||||
|
|
|
@ -73,10 +73,10 @@ from nzbtomedia.nzbToMediaConfig import config
|
||||||
from nzbtomedia.nzbToMediaUtil import nzbtomedia_configure_logging, WakeUp, get_dirnames
|
from nzbtomedia.nzbToMediaUtil import nzbtomedia_configure_logging, WakeUp, get_dirnames
|
||||||
|
|
||||||
# run migrate to convert old cfg to new style cfg plus fix any cfg missing values/options.
|
# run migrate to convert old cfg to new style cfg plus fix any cfg missing values/options.
|
||||||
if config.migrate():
|
if config().migrate():
|
||||||
# check to write settings from nzbGet UI to autoProcessMedia.cfg.
|
# check to write settings from nzbGet UI to autoProcessMedia.cfg.
|
||||||
if os.environ.has_key('NZBOP_SCRIPTDIR'):
|
if os.environ.has_key('NZBOP_SCRIPTDIR'):
|
||||||
config.addnzbget()
|
config().addnzbget()
|
||||||
|
|
||||||
nzbtomedia_configure_logging(config.LOG_FILE)
|
nzbtomedia_configure_logging(config.LOG_FILE)
|
||||||
Logger = logging.getLogger(__name__)
|
Logger = logging.getLogger(__name__)
|
||||||
|
@ -165,12 +165,12 @@ else:
|
||||||
result = 0
|
result = 0
|
||||||
|
|
||||||
# init sub-sections
|
# init sub-sections
|
||||||
subsections = config.get_subsections(["Mylar"])
|
subsections = config().get_subsections(["Mylar"])
|
||||||
|
|
||||||
Logger.warn("MAIN: Invalid number of arguments received from client.")
|
Logger.warn("MAIN: Invalid number of arguments received from client.")
|
||||||
for section, subsection in subsections.items():
|
for section, subsection in subsections.items():
|
||||||
for category in subsection:
|
for category in subsection:
|
||||||
if config.isenabled(section, category):
|
if config().isenabled(section, category):
|
||||||
dirNames = get_dirnames(section, category)
|
dirNames = get_dirnames(section, category)
|
||||||
for dirName in dirNames:
|
for dirName in dirNames:
|
||||||
Logger.info("MAIN: nzbToMylar running %s:%s as a manual run...", section, category)
|
Logger.info("MAIN: nzbToMylar running %s:%s as a manual run...", section, category)
|
||||||
|
|
|
@ -102,10 +102,10 @@ from nzbtomedia.nzbToMediaConfig import config
|
||||||
from nzbtomedia.nzbToMediaUtil import nzbtomedia_configure_logging, WakeUp, get_dirnames
|
from nzbtomedia.nzbToMediaUtil import nzbtomedia_configure_logging, WakeUp, get_dirnames
|
||||||
|
|
||||||
# run migrate to convert old cfg to new style cfg plus fix any cfg missing values/options.
|
# run migrate to convert old cfg to new style cfg plus fix any cfg missing values/options.
|
||||||
if config.migrate():
|
if config().migrate():
|
||||||
# check to write settings from nzbGet UI to autoProcessMedia.cfg.
|
# check to write settings from nzbGet UI to autoProcessMedia.cfg.
|
||||||
if os.environ.has_key('NZBOP_SCRIPTDIR'):
|
if os.environ.has_key('NZBOP_SCRIPTDIR'):
|
||||||
config.addnzbget()
|
config().addnzbget()
|
||||||
|
|
||||||
nzbtomedia_configure_logging(config.LOG_FILE)
|
nzbtomedia_configure_logging(config.LOG_FILE)
|
||||||
Logger = logging.getLogger(__name__)
|
Logger = logging.getLogger(__name__)
|
||||||
|
@ -197,12 +197,12 @@ else:
|
||||||
result = 0
|
result = 0
|
||||||
|
|
||||||
# init sub-sections
|
# init sub-sections
|
||||||
subsections = config.get_subsections(["NzbDrone"])
|
subsections = config().get_subsections(["NzbDrone"])
|
||||||
|
|
||||||
Logger.warn("MAIN: Invalid number of arguments received from client.")
|
Logger.warn("MAIN: Invalid number of arguments received from client.")
|
||||||
for section, subsection in subsections.items():
|
for section, subsection in subsections.items():
|
||||||
for category in subsection:
|
for category in subsection:
|
||||||
if config.isenabled(section, category):
|
if config().isenabled(section, category):
|
||||||
dirNames = get_dirnames(section, category)
|
dirNames = get_dirnames(section, category)
|
||||||
for dirName in dirNames:
|
for dirName in dirNames:
|
||||||
Logger.info("MAIN: nzbToNzbDrone running %s:%s as a manual run...", section, category)
|
Logger.info("MAIN: nzbToNzbDrone running %s:%s as a manual run...", section, category)
|
||||||
|
|
|
@ -135,10 +135,10 @@ from nzbtomedia.nzbToMediaConfig import config
|
||||||
from nzbtomedia.nzbToMediaUtil import nzbtomedia_configure_logging, WakeUp, get_dirnames
|
from nzbtomedia.nzbToMediaUtil import nzbtomedia_configure_logging, WakeUp, get_dirnames
|
||||||
|
|
||||||
# run migrate to convert old cfg to new style cfg plus fix any cfg missing values/options.
|
# run migrate to convert old cfg to new style cfg plus fix any cfg missing values/options.
|
||||||
if config.migrate():
|
if config().migrate():
|
||||||
# check to write settings from nzbGet UI to autoProcessMedia.cfg.
|
# check to write settings from nzbGet UI to autoProcessMedia.cfg.
|
||||||
if os.environ.has_key('NZBOP_SCRIPTDIR'):
|
if os.environ.has_key('NZBOP_SCRIPTDIR'):
|
||||||
config.addnzbget()
|
config().addnzbget()
|
||||||
|
|
||||||
nzbtomedia_configure_logging(config.LOG_FILE)
|
nzbtomedia_configure_logging(config.LOG_FILE)
|
||||||
Logger = logging.getLogger(__name__)
|
Logger = logging.getLogger(__name__)
|
||||||
|
@ -230,12 +230,12 @@ else:
|
||||||
result = 0
|
result = 0
|
||||||
|
|
||||||
# init sub-sections
|
# init sub-sections
|
||||||
subsections = config.get_subsections(["SickBeard"])
|
subsections = config().get_subsections(["SickBeard"])
|
||||||
|
|
||||||
Logger.warn("MAIN: Invalid number of arguments received from client.")
|
Logger.warn("MAIN: Invalid number of arguments received from client.")
|
||||||
for section, subsection in subsections.items():
|
for section, subsection in subsections.items():
|
||||||
for category in subsection:
|
for category in subsection:
|
||||||
if config.isenabled(section,category):
|
if config().isenabled(section,category):
|
||||||
dirNames = get_dirnames(section, category)
|
dirNames = get_dirnames(section, category)
|
||||||
for dirName in dirNames:
|
for dirName in dirNames:
|
||||||
Logger.info("MAIN: nzbTo%s running %s:%s as a manual run...", section, section, category)
|
Logger.info("MAIN: nzbTo%s running %s:%s as a manual run...", section, section, category)
|
||||||
|
|
|
@ -15,7 +15,7 @@ class autoProcessComics:
|
||||||
return 1 # failure
|
return 1 # failure
|
||||||
|
|
||||||
# auto-detect correct section
|
# auto-detect correct section
|
||||||
section = config.issubsection(inputCategory, checkenabled=True)[0]
|
section = ''.join(map(str, config().issubsection(inputCategory, checkenabled=True)))
|
||||||
if not section:
|
if not section:
|
||||||
Logger.error(
|
Logger.error(
|
||||||
"MAIN: We were unable to find a processor for category %s that was enabled, please check your autoProcessMedia.cfg file.", inputCategory)
|
"MAIN: We were unable to find a processor for category %s that was enabled, please check your autoProcessMedia.cfg file.", inputCategory)
|
||||||
|
|
|
@ -14,7 +14,7 @@ class autoProcessGames:
|
||||||
return 1 # failure
|
return 1 # failure
|
||||||
|
|
||||||
# auto-detect correct section
|
# auto-detect correct section
|
||||||
section = config.issubsection(inputCategory, checkenabled=True)[0]
|
section = ''.join(map(str, config().issubsection(inputCategory, checkenabled=True)))
|
||||||
if not section:
|
if not section:
|
||||||
Logger.error(
|
Logger.error(
|
||||||
"MAIN: We were unable to find a processor for category %s that was enabled, please check your autoProcessMedia.cfg file.", inputCategory)
|
"MAIN: We were unable to find a processor for category %s that was enabled, please check your autoProcessMedia.cfg file.", inputCategory)
|
||||||
|
|
|
@ -166,7 +166,7 @@ class autoProcessMovie:
|
||||||
return 1 # failure
|
return 1 # failure
|
||||||
|
|
||||||
# auto-detect correct section
|
# auto-detect correct section
|
||||||
section = config.issubsection(inputCategory, checkenabled=True)[0]
|
section = ''.join(map(str, config().issubsection(inputCategory, checkenabled=True)))
|
||||||
if not section:
|
if not section:
|
||||||
Logger.error(
|
Logger.error(
|
||||||
"MAIN: We were unable to find a processor for category %s that was enabled, please check your autoProcessMedia.cfg file.", inputCategory)
|
"MAIN: We were unable to find a processor for category %s that was enabled, please check your autoProcessMedia.cfg file.", inputCategory)
|
||||||
|
|
|
@ -15,7 +15,7 @@ class autoProcessMusic:
|
||||||
return 1 # failure
|
return 1 # failure
|
||||||
|
|
||||||
# auto-detect correct section
|
# auto-detect correct section
|
||||||
section = config.issubsection(inputCategory,checkenabled=True)[0]
|
section = config().issubsection(inputCategory,checkenabled=True)[0]
|
||||||
if len(section) == 0:
|
if len(section) == 0:
|
||||||
Logger.error(
|
Logger.error(
|
||||||
"MAIN: We were unable to find a processor for category %s that was enabled, please check your autoProcessMedia.cfg file.", inputCategory)
|
"MAIN: We were unable to find a processor for category %s that was enabled, please check your autoProcessMedia.cfg file.", inputCategory)
|
||||||
|
|
|
@ -21,7 +21,7 @@ class autoProcessTV:
|
||||||
return 1 # failure
|
return 1 # failure
|
||||||
|
|
||||||
# auto-detect correct section
|
# auto-detect correct section
|
||||||
section = config.issubsection(inputCategory, checkenabled=True)[0]
|
section = ''.join(map(str, config().issubsection(inputCategory, checkenabled=True)))
|
||||||
if not section:
|
if not section:
|
||||||
Logger.error(
|
Logger.error(
|
||||||
"MAIN: We were unable to find a processor for category %s that was enabled, please check your autoProcessMedia.cfg file.", inputCategory)
|
"MAIN: We were unable to find a processor for category %s that was enabled, please check your autoProcessMedia.cfg file.", inputCategory)
|
||||||
|
|
|
@ -12,9 +12,6 @@ class config(original_ConfigObj):
|
||||||
super(lib.configobj.ConfigObj, self).__init__(*args, **kw)
|
super(lib.configobj.ConfigObj, self).__init__(*args, **kw)
|
||||||
self.interpolation = False
|
self.interpolation = False
|
||||||
|
|
||||||
def __call__(self, *args, **kwargs):
|
|
||||||
print()
|
|
||||||
|
|
||||||
# constants for nzbtomedia
|
# constants for nzbtomedia
|
||||||
NZBTOMEDIA_VERSION = 'V9.3'
|
NZBTOMEDIA_VERSION = 'V9.3'
|
||||||
NZBTOMEDIA_TIMEOUT = 60
|
NZBTOMEDIA_TIMEOUT = 60
|
||||||
|
@ -50,29 +47,26 @@ class config(original_ConfigObj):
|
||||||
LOG_CONFIG = os.path.join(PROGRAM_DIR, "logging.cfg")
|
LOG_CONFIG = os.path.join(PROGRAM_DIR, "logging.cfg")
|
||||||
SAMPLE_LOG_CONFIG = os.path.join(PROGRAM_DIR, "logging.cfg.sample")
|
SAMPLE_LOG_CONFIG = os.path.join(PROGRAM_DIR, "logging.cfg.sample")
|
||||||
|
|
||||||
|
def issubsection(self, inputCategory, sections=None, checkenabled=False):
|
||||||
@staticmethod
|
|
||||||
def issubsection(inputCategory, sections=None, checkenabled=False):
|
|
||||||
# checks if the inputCategory belongs to the section
|
# checks if the inputCategory belongs to the section
|
||||||
# or returns sections with subsections matching the inputCategoryu
|
# or returns sections with subsections matching the inputCategoryu
|
||||||
if not sections:
|
if not sections:
|
||||||
sections = config.get_sections(inputCategory)
|
sections = self.get_sections(inputCategory)
|
||||||
|
|
||||||
if not isinstance(sections, list):
|
if not isinstance(sections, list):
|
||||||
sections = [sections]
|
sections = [sections]
|
||||||
|
|
||||||
results = []
|
results = []
|
||||||
for section in sections:
|
for section in sections:
|
||||||
if config()[section].has_key(inputCategory):
|
if self[section].has_key(inputCategory):
|
||||||
if checkenabled:
|
if checkenabled:
|
||||||
if config.isenabled(section, inputCategory):
|
if self.isenabled(section, inputCategory):
|
||||||
results.append(section)
|
results.append(section)
|
||||||
else:
|
else:
|
||||||
results.append(section)
|
results.append(section)
|
||||||
return results if list(set(results).intersection(set(sections))) else False
|
return results if list(set(results).intersection(set(sections))) else []
|
||||||
|
|
||||||
@staticmethod
|
def get_sections(self, subsections):
|
||||||
def get_sections(subsections):
|
|
||||||
# finds all sections belonging to the subsection and returns them
|
# finds all sections belonging to the subsection and returns them
|
||||||
if not isinstance(subsections, list):
|
if not isinstance(subsections, list):
|
||||||
subsections = [subsections]
|
subsections = [subsections]
|
||||||
|
@ -80,51 +74,48 @@ class config(original_ConfigObj):
|
||||||
to_return = []
|
to_return = []
|
||||||
for subsection in subsections:
|
for subsection in subsections:
|
||||||
for section in config().sections:
|
for section in config().sections:
|
||||||
if config()[section].has_key(subsection):
|
if self[section].has_key(subsection):
|
||||||
to_return.append(section)
|
to_return.append(section)
|
||||||
return to_return
|
return to_return
|
||||||
|
|
||||||
@staticmethod
|
def get_subsections(self, sections):
|
||||||
def get_subsections(sections):
|
|
||||||
# finds all subsections belonging to the section and returns them
|
# finds all subsections belonging to the section and returns them
|
||||||
if not isinstance(sections, list):
|
if not isinstance(sections, list):
|
||||||
sections = [sections]
|
sections = [sections]
|
||||||
|
|
||||||
to_return = {}
|
to_return = {}
|
||||||
for section in sections:
|
for section in sections:
|
||||||
if section in config().sections:
|
if section in self.sections:
|
||||||
for subsection in config()[section].sections:
|
for subsection in self[section].sections:
|
||||||
if not isinstance(subsection, list):
|
if not isinstance(subsection, list):
|
||||||
subsection = [subsection]
|
subsection = [subsection]
|
||||||
to_return.update({section: subsection})
|
to_return.update({section: subsection})
|
||||||
return to_return
|
return to_return
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def isenabled(section, inputCategory):
|
def isenabled(self, section, inputCategory):
|
||||||
# checks if the subsection is enabled/disabled
|
# checks if the subsection is enabled/disabled
|
||||||
if int(config()[section][inputCategory]['enabled']) == 1:
|
if int(self[section][inputCategory]['enabled']) == 1:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@staticmethod
|
def search(self, key, section, subsection=None):
|
||||||
def search(key, section, subsection=None):
|
|
||||||
# searches for data in sections and subsections and returns it
|
# searches for data in sections and subsections and returns it
|
||||||
if subsection:
|
if subsection:
|
||||||
if key in config()[section][subsection].keys():
|
if key in self[section][subsection].keys():
|
||||||
return config()[section][subsection][key]
|
return self[section][subsection][key]
|
||||||
else:
|
else:
|
||||||
if key in config()[section].keys():
|
if key in self[section].keys():
|
||||||
return config()[section][key]
|
return self[section][key]
|
||||||
|
|
||||||
@staticmethod
|
def migrate(self):
|
||||||
def migrate():
|
|
||||||
global config_new, config_old
|
global config_new, config_old
|
||||||
config_new = config_old = None
|
config_new = config_old = None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# check for autoProcessMedia.cfg and create if it does not exist
|
# check for autoProcessMedia.cfg and create if it does not exist
|
||||||
if not config(config.CONFIG_FILE):
|
if not config():
|
||||||
shutil.copyfile(config.SAMPLE_CONFIG_FILE, config.CONFIG_FILE)
|
shutil.copyfile(config.SAMPLE_CONFIG_FILE, config.CONFIG_FILE)
|
||||||
config_old = config(config.CONFIG_FILE)
|
config_old = config()
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -243,8 +234,7 @@ class config(original_ConfigObj):
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@staticmethod
|
def addnzbget(self):
|
||||||
def addnzbget():
|
|
||||||
config_new = config()
|
config_new = config()
|
||||||
section = "CouchPotato"
|
section = "CouchPotato"
|
||||||
envCatKey = 'NZBPO_CPSCATEGORY'
|
envCatKey = 'NZBPO_CPSCATEGORY'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue