mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-19 21:03:14 -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))
|
||||
|
||||
# auto-detect section
|
||||
section = nzbtomedia.CFG.findsection(inputCategory)
|
||||
section = nzbtomedia.CFG.findsection(inputCategory).isenabled()
|
||||
if len(section) > 1:
|
||||
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.' % (
|
||||
|
|
|
@ -303,7 +303,7 @@ def process(inputDirectory, inputName=None, status=0, clientAgent='manual', down
|
|||
myDB.upsert("downloads", newValueDict, controlValueDict)
|
||||
|
||||
# auto-detect section
|
||||
section = nzbtomedia.CFG.findsection(inputCategory)
|
||||
section = nzbtomedia.CFG.findsection(inputCategory).isenabled()
|
||||
if len(section) > 1:
|
||||
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.' % (
|
||||
|
@ -485,7 +485,7 @@ def main(args, section=None):
|
|||
except:
|
||||
download_id = None
|
||||
|
||||
if not clientAgent.lower() in (nzbtomedia.NZB_CLIENTS or 'manual'):
|
||||
if not clientAgent.lower() in (nzbtomedia.NZB_CLIENTS, 'manual'):
|
||||
continue
|
||||
|
||||
results = process(dirName, os.path.basename(dirName), 0, clientAgent=clientAgent,
|
||||
|
|
|
@ -12,7 +12,7 @@ from nzbtomedia.transcoder import transcoder
|
|||
class autoProcessTV:
|
||||
def processEpisode(self, section, dirName, inputName=None, failed=False, clientAgent = "manual", inputCategory=None):
|
||||
# auto-detect correct fork
|
||||
fork, fork_params = autoFork(inputCategory)
|
||||
fork, fork_params = autoFork(section, inputCategory)
|
||||
|
||||
# Check video files for corruption
|
||||
status = int(failed)
|
||||
|
|
|
@ -3,14 +3,8 @@ import nzbtomedia
|
|||
import requests
|
||||
from nzbtomedia import logger
|
||||
|
||||
def autoFork(inputCategory):
|
||||
def autoFork(section, inputCategory):
|
||||
# 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
|
||||
try:
|
||||
host = nzbtomedia.CFG[section][inputCategory]["host"]
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import os
|
||||
import shutil
|
||||
import copy
|
||||
import nzbtomedia
|
||||
from configobj import *
|
||||
|
||||
|
@ -9,33 +10,36 @@ class Section(configobj.Section):
|
|||
def isenabled(section):
|
||||
# checks if subsection enabled, returns true/false if subsection specified otherwise returns true/false in {}
|
||||
if not section.sections:
|
||||
if not int(section['enabled']) == 1:
|
||||
return
|
||||
if int(section['enabled']) == 1:
|
||||
return section
|
||||
else:
|
||||
for section_name, subsections in section.items():
|
||||
to_return = copy.deepcopy(section)
|
||||
for section_name, subsections in to_return.items():
|
||||
if subsections.sections:
|
||||
for subsection in subsections:
|
||||
if not int(subsections[subsection]['enabled']) == 1:
|
||||
subsections.pop(subsection)
|
||||
del subsections[subsection]
|
||||
else:
|
||||
if not int(subsections['enabled']) == 1:
|
||||
section.pop(section_name)
|
||||
del to_return[section_name]
|
||||
|
||||
if len(section[section_name]) == 0:
|
||||
section.pop(section_name)
|
||||
return section
|
||||
if len(to_return[section_name]) == 0:
|
||||
del to_return[section_name]
|
||||
return to_return
|
||||
|
||||
def findsection(section, key):
|
||||
for subsection in section:
|
||||
if key not in section[subsection]:
|
||||
section.pop(subsection)
|
||||
return section
|
||||
to_return = copy.deepcopy(section)
|
||||
for subsection in to_return:
|
||||
if key not in to_return[subsection]:
|
||||
del to_return[subsection]
|
||||
return to_return
|
||||
|
||||
def __getitem__(self, key):
|
||||
if key in self.keys():
|
||||
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:
|
||||
continue
|
||||
if isinstance(subsections, Section) and subsections.sections:
|
||||
|
@ -45,15 +49,15 @@ class Section(configobj.Section):
|
|||
if key in options:
|
||||
return options[key]
|
||||
|
||||
subsections.pop(subsection)
|
||||
del subsections[subsection]
|
||||
else:
|
||||
if section not in key:
|
||||
self.pop(section)
|
||||
del to_return[section]
|
||||
|
||||
if len(subsections) == 0:
|
||||
self.pop(section)
|
||||
del to_return[section]
|
||||
|
||||
return self
|
||||
return to_return
|
||||
|
||||
class ConfigObj(configobj.ConfigObj, Section):
|
||||
def __init__(self, *args, **kw):
|
||||
|
|
|
@ -8,11 +8,6 @@ from nzbtomedia.nzbToMediaUtil import get_downloadInfo
|
|||
# Initialize the config
|
||||
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']
|
||||
section = nzbtomedia.CFG.findsection('tv').isenabled()
|
||||
print section
|
Loading…
Add table
Add a link
Reference in a new issue