mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-19 21:03:14 -07:00
Added new helper functionc to config class.
Fixed code to reflect the changes made to config class. Merged in changes from dev-ch
This commit is contained in:
commit
d8a3bdb7dc
2 changed files with 17 additions and 4 deletions
|
@ -10,7 +10,6 @@ import logging
|
||||||
import re
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
from subprocess import Popen
|
from subprocess import Popen
|
||||||
from itertools import chain
|
|
||||||
from nzbtomedia.autoProcess.autoProcessComics import autoProcessComics
|
from nzbtomedia.autoProcess.autoProcessComics import autoProcessComics
|
||||||
from nzbtomedia.autoProcess.autoProcessGames import autoProcessGames
|
from nzbtomedia.autoProcess.autoProcessGames import autoProcessGames
|
||||||
from nzbtomedia.autoProcess.autoProcessMovie import autoProcessMovie
|
from nzbtomedia.autoProcess.autoProcessMovie import autoProcessMovie
|
||||||
|
@ -30,6 +29,7 @@ def main(inputDirectory, inputName, inputCategory, inputHash, inputID):
|
||||||
status = int(1) # 1 = failed | 0 = success
|
status = int(1) # 1 = failed | 0 = success
|
||||||
root = int(0)
|
root = int(0)
|
||||||
video = int(0)
|
video = int(0)
|
||||||
|
archive = int(0)
|
||||||
foundFile = int(0)
|
foundFile = int(0)
|
||||||
extracted_folder = []
|
extracted_folder = []
|
||||||
extractionSuccess = False
|
extractionSuccess = False
|
||||||
|
@ -45,7 +45,7 @@ def main(inputDirectory, inputName, inputCategory, inputHash, inputID):
|
||||||
TorrentClass = create_torrent_class(clientAgent, inputHash)
|
TorrentClass = create_torrent_class(clientAgent, inputHash)
|
||||||
pause_torrent(clientAgent, TorrentClass, inputHash, inputID, inputName)
|
pause_torrent(clientAgent, TorrentClass, inputHash, inputID, inputName)
|
||||||
|
|
||||||
processCategories = list(chain.from_iterable(subsections.values()))
|
processCategories = config()[sections].sections
|
||||||
|
|
||||||
outputDestination = ""
|
outputDestination = ""
|
||||||
if inputCategory == "":
|
if inputCategory == "":
|
||||||
|
@ -65,7 +65,7 @@ def main(inputDirectory, inputName, inputCategory, inputHash, inputID):
|
||||||
Logger.info("MAIN: All done.")
|
Logger.info("MAIN: All done.")
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
processOnly = list(set(chain.from_iterable(subsections.values())))
|
processOnly = config()[sections].sections
|
||||||
if not "NONE" in user_script_categories: # if None, we only process the 5 listed.
|
if not "NONE" in user_script_categories: # if None, we only process the 5 listed.
|
||||||
if "ALL" in user_script_categories: # All defined categories
|
if "ALL" in user_script_categories: # All defined categories
|
||||||
processOnly = categories
|
processOnly = categories
|
||||||
|
@ -166,11 +166,16 @@ def main(inputDirectory, inputName, inputCategory, inputHash, inputID):
|
||||||
if fileExtension in mediaContainer: # If the file is a video file
|
if fileExtension in mediaContainer: # If the file is a video file
|
||||||
Logger.debug("MAIN: Found media file: %s", filePath)
|
Logger.debug("MAIN: Found media file: %s", filePath)
|
||||||
video += 1
|
video += 1
|
||||||
|
if fileExtension in compressedContainer: # If the file is an archive file
|
||||||
|
archive += 1
|
||||||
if video > int(0): # Check that media files exist
|
if video > int(0): # Check that media files exist
|
||||||
Logger.debug("MAIN: Found %s media files", str(video))
|
Logger.debug("MAIN: Found %s media files", str(video))
|
||||||
status = int(0)
|
status = int(0)
|
||||||
|
elif not (config()["SickBeard"].issubsection(inputCategory) and config()["SickBeard"][inputCategory]["nzbExtractionBy"] == "Destination") and archive > int(0):
|
||||||
|
Logger.debug("MAIN: Found %s archive files to be extracted by SickBeard", str(archive))
|
||||||
|
status = int(0)
|
||||||
else:
|
else:
|
||||||
Logger.warning("MAIN: Found no media files in output.", str(video))
|
Logger.warning("MAIN: Found no media files in output.")
|
||||||
|
|
||||||
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)
|
||||||
|
|
|
@ -101,6 +101,14 @@ class ConfigObj(lib.configobj.ConfigObj, Section):
|
||||||
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")
|
||||||
|
|
||||||
|
try:
|
||||||
|
repo = check_output(["git", "config", "--get", "remote.origin.url"]).splitlines()[0]
|
||||||
|
branch = check_output(["git", "rev-parse", "--abbrev-ref", "HEAD"]).splitlines()[0]
|
||||||
|
hash = check_output(["git", "rev-parse", "--short", "HEAD"]).splitlines()[0]
|
||||||
|
NZBTOMEDIA_VERSION = 'repo:' + repo + ' branch:' + branch + ' hash: ' + hash
|
||||||
|
except CalledProcessError:
|
||||||
|
pass
|
||||||
|
|
||||||
def __init__(self, *args, **kw):
|
def __init__(self, *args, **kw):
|
||||||
if len(args) == 0:
|
if len(args) == 0:
|
||||||
args = (self.CONFIG_FILE,)
|
args = (self.CONFIG_FILE,)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue