mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-19 12:59:36 -07:00
Fixed issue with config class code, The new method I implemented to return our data from our config stored in memory was actually removing the items we were getting so I implemented a copy of the data so the original data is no longer touched other then for lookups
This commit is contained in:
parent
a9b13881a3
commit
e20becd41c
6 changed files with 26 additions and 33 deletions
|
@ -39,7 +39,7 @@ def processTorrent(inputDirectory, inputName, inputCategory, inputHash, inputID,
|
||||||
logger.debug("Determined Directory: %s | Name: %s | Category: %s" % (inputDirectory, inputName, inputCategory))
|
logger.debug("Determined Directory: %s | Name: %s | Category: %s" % (inputDirectory, inputName, inputCategory))
|
||||||
|
|
||||||
# auto-detect section
|
# auto-detect section
|
||||||
section = nzbtomedia.CFG.findsection(inputCategory)
|
section = nzbtomedia.CFG.findsection(inputCategory).isenabled()
|
||||||
if len(section) > 1:
|
if len(section) > 1:
|
||||||
logger.error(
|
logger.error(
|
||||||
'Category:[%s] is not unique, %s are using it. Please rename it or disable all other sections using the same category name in your autoProcessMedia.cfg and try again.' % (
|
'Category:[%s] is not unique, %s are using it. Please rename it or disable all other sections using the same category name in your autoProcessMedia.cfg and try again.' % (
|
||||||
|
|
|
@ -303,7 +303,7 @@ def process(inputDirectory, inputName=None, status=0, clientAgent='manual', down
|
||||||
myDB.upsert("downloads", newValueDict, controlValueDict)
|
myDB.upsert("downloads", newValueDict, controlValueDict)
|
||||||
|
|
||||||
# auto-detect section
|
# auto-detect section
|
||||||
section = nzbtomedia.CFG.findsection(inputCategory)
|
section = nzbtomedia.CFG.findsection(inputCategory).isenabled()
|
||||||
if len(section) > 1:
|
if len(section) > 1:
|
||||||
logger.error(
|
logger.error(
|
||||||
'Category:[%s] is not unique, %s are using it. Please rename it or disable all other sections using the same category name in your autoProcessMedia.cfg and try again.' % (
|
'Category:[%s] is not unique, %s are using it. Please rename it or disable all other sections using the same category name in your autoProcessMedia.cfg and try again.' % (
|
||||||
|
@ -485,7 +485,7 @@ def main(args, section=None):
|
||||||
except:
|
except:
|
||||||
download_id = None
|
download_id = None
|
||||||
|
|
||||||
if not clientAgent.lower() in (nzbtomedia.NZB_CLIENTS or 'manual'):
|
if not clientAgent.lower() in (nzbtomedia.NZB_CLIENTS, 'manual'):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
results = process(dirName, os.path.basename(dirName), 0, clientAgent=clientAgent,
|
results = process(dirName, os.path.basename(dirName), 0, clientAgent=clientAgent,
|
||||||
|
|
|
@ -12,7 +12,7 @@ from nzbtomedia.transcoder import transcoder
|
||||||
class autoProcessTV:
|
class autoProcessTV:
|
||||||
def processEpisode(self, section, dirName, inputName=None, failed=False, clientAgent = "manual", inputCategory=None):
|
def processEpisode(self, section, dirName, inputName=None, failed=False, clientAgent = "manual", inputCategory=None):
|
||||||
# auto-detect correct fork
|
# auto-detect correct fork
|
||||||
fork, fork_params = autoFork(inputCategory)
|
fork, fork_params = autoFork(section, inputCategory)
|
||||||
|
|
||||||
# Check video files for corruption
|
# Check video files for corruption
|
||||||
status = int(failed)
|
status = int(failed)
|
||||||
|
|
|
@ -3,14 +3,8 @@ import nzbtomedia
|
||||||
import requests
|
import requests
|
||||||
from nzbtomedia import logger
|
from nzbtomedia import logger
|
||||||
|
|
||||||
def autoFork(inputCategory):
|
def autoFork(section, inputCategory):
|
||||||
# auto-detect correct section
|
# auto-detect correct section
|
||||||
section = nzbtomedia.CFG.findsection(inputCategory)
|
|
||||||
if not section:
|
|
||||||
logger.error(
|
|
||||||
"We were unable to find a section for category %s, please check your autoProcessMedia.cfg file." % inputCategory)
|
|
||||||
return 1
|
|
||||||
|
|
||||||
# config settings
|
# config settings
|
||||||
try:
|
try:
|
||||||
host = nzbtomedia.CFG[section][inputCategory]["host"]
|
host = nzbtomedia.CFG[section][inputCategory]["host"]
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
|
import copy
|
||||||
import nzbtomedia
|
import nzbtomedia
|
||||||
from configobj import *
|
from configobj import *
|
||||||
|
|
||||||
|
@ -9,33 +10,36 @@ class Section(configobj.Section):
|
||||||
def isenabled(section):
|
def isenabled(section):
|
||||||
# checks if subsection enabled, returns true/false if subsection specified otherwise returns true/false in {}
|
# checks if subsection enabled, returns true/false if subsection specified otherwise returns true/false in {}
|
||||||
if not section.sections:
|
if not section.sections:
|
||||||
if not int(section['enabled']) == 1:
|
if int(section['enabled']) == 1:
|
||||||
return
|
return section
|
||||||
else:
|
else:
|
||||||
for section_name, subsections in section.items():
|
to_return = copy.deepcopy(section)
|
||||||
|
for section_name, subsections in to_return.items():
|
||||||
if subsections.sections:
|
if subsections.sections:
|
||||||
for subsection in subsections:
|
for subsection in subsections:
|
||||||
if not int(subsections[subsection]['enabled']) == 1:
|
if not int(subsections[subsection]['enabled']) == 1:
|
||||||
subsections.pop(subsection)
|
del subsections[subsection]
|
||||||
else:
|
else:
|
||||||
if not int(subsections['enabled']) == 1:
|
if not int(subsections['enabled']) == 1:
|
||||||
section.pop(section_name)
|
del to_return[section_name]
|
||||||
|
|
||||||
if len(section[section_name]) == 0:
|
if len(to_return[section_name]) == 0:
|
||||||
section.pop(section_name)
|
del to_return[section_name]
|
||||||
return section
|
return to_return
|
||||||
|
|
||||||
def findsection(section, key):
|
def findsection(section, key):
|
||||||
for subsection in section:
|
to_return = copy.deepcopy(section)
|
||||||
if key not in section[subsection]:
|
for subsection in to_return:
|
||||||
section.pop(subsection)
|
if key not in to_return[subsection]:
|
||||||
return section
|
del to_return[subsection]
|
||||||
|
return to_return
|
||||||
|
|
||||||
def __getitem__(self, key):
|
def __getitem__(self, key):
|
||||||
if key in self.keys():
|
if key in self.keys():
|
||||||
return dict.__getitem__(self, key)
|
return dict.__getitem__(self, key)
|
||||||
|
|
||||||
for section, subsections in self.items():
|
to_return = copy.deepcopy(self)
|
||||||
|
for section, subsections in to_return.items():
|
||||||
if section in key:
|
if section in key:
|
||||||
continue
|
continue
|
||||||
if isinstance(subsections, Section) and subsections.sections:
|
if isinstance(subsections, Section) and subsections.sections:
|
||||||
|
@ -45,15 +49,15 @@ class Section(configobj.Section):
|
||||||
if key in options:
|
if key in options:
|
||||||
return options[key]
|
return options[key]
|
||||||
|
|
||||||
subsections.pop(subsection)
|
del subsections[subsection]
|
||||||
else:
|
else:
|
||||||
if section not in key:
|
if section not in key:
|
||||||
self.pop(section)
|
del to_return[section]
|
||||||
|
|
||||||
if len(subsections) == 0:
|
if len(subsections) == 0:
|
||||||
self.pop(section)
|
del to_return[section]
|
||||||
|
|
||||||
return self
|
return to_return
|
||||||
|
|
||||||
class ConfigObj(configobj.ConfigObj, Section):
|
class ConfigObj(configobj.ConfigObj, Section):
|
||||||
def __init__(self, *args, **kw):
|
def __init__(self, *args, **kw):
|
||||||
|
|
|
@ -8,11 +8,6 @@ from nzbtomedia.nzbToMediaUtil import get_downloadInfo
|
||||||
# Initialize the config
|
# Initialize the config
|
||||||
nzbtomedia.initialize()
|
nzbtomedia.initialize()
|
||||||
|
|
||||||
EXTENSIONS = [re.compile('.r\d{2}$', re.I),
|
|
||||||
re.compile('.part\d+.rar$', re.I),
|
|
||||||
re.compile('.rar$', re.I)]
|
|
||||||
EXTENSIONS += [re.compile('%s$' % ext, re.I) for ext in nzbtomedia.COMPRESSEDCONTAINER]
|
|
||||||
|
|
||||||
test = nzbtomedia.CFG['HeadPhones']['music']
|
test = nzbtomedia.CFG['HeadPhones']['music']
|
||||||
section = nzbtomedia.CFG.findsection('tv').isenabled()
|
section = nzbtomedia.CFG.findsection('tv').isenabled()
|
||||||
print section
|
print section
|
Loading…
Add table
Add a link
Reference in a new issue