diff --git a/.gitignore b/.gitignore index cde13c94..ad36f2d5 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ autoProcessMedia.cfg *.pyo postprocess.log +/.idea/ diff --git a/autoProcess/autoProcessTV.py b/autoProcess/autoProcessTV.py index 9e4653c0..bdccdb24 100644 --- a/autoProcess/autoProcessTV.py +++ b/autoProcess/autoProcessTV.py @@ -1,18 +1,13 @@ -import sys import urllib -import os -import ConfigParser import logging -import shutil -import time -import socket import copy import Transcoder from nzbToMediaEnv import * from nzbToMediaUtil import * from nzbToMediaSceneExceptions import process_all_exceptions -from autoSickBeardFork import autoFork +from autoProcess.autoSickBeardFork import autoFork + Logger = logging.getLogger() @@ -69,22 +64,18 @@ def processEpisode(dirName, nzbName=None, failed=False, clientAgent=None, inputC ssl = int(config.get(section, "ssl")) except (ConfigParser.NoOptionError, ValueError): ssl = 0 - try: web_root = config.get(section, "web_root") except ConfigParser.NoOptionError: web_root = "" - try: watch_dir = config.get(section, "watch_dir") except ConfigParser.NoOptionError: watch_dir = "" - try: transcode = int(config.get("Transcoder", "transcode")) except (ConfigParser.NoOptionError, ValueError): transcode = 0 - try: delete_failed = int(config.get(section, "delete_failed")) except (ConfigParser.NoOptionError, ValueError): @@ -105,7 +96,6 @@ def processEpisode(dirName, nzbName=None, failed=False, clientAgent=None, inputC nzbExtractionBy = config.get(section, "nzbExtractionBy") except (ConfigParser.NoOptionError, ValueError): nzbExtractionBy = "Downloader" - try: process_method = config.get(section, "process_method") except ConfigParser.NoOptionError: @@ -163,10 +153,7 @@ def processEpisode(dirName, nzbName=None, failed=False, clientAgent=None, inputC if param is "failed": params[param] = failed - if param is "dirName": - params[param] = dirName - - if param is "dir": + if param is "dirName" or param is "dir": params[param] = dirName if param is "process_method": @@ -175,12 +162,6 @@ def processEpisode(dirName, nzbName=None, failed=False, clientAgent=None, inputC else: del params[param] - if param is "process": - params["process"] = None - - if param is "process_method": - params["process_method"] = None - if nzbName != None: params['nzbName'] = nzbName diff --git a/autoSickBeardFork.py b/autoProcess/autoSickBeardFork.py similarity index 74% rename from autoSickBeardFork.py rename to autoProcess/autoSickBeardFork.py index bfaef381..f4d6d18c 100644 --- a/autoSickBeardFork.py +++ b/autoProcess/autoSickBeardFork.py @@ -49,12 +49,9 @@ def autoFork(fork=None): web_root = "" try: - fork = config.get(section, "fork") - if not fork in "auto": - fork = forks[fork] \ - if fork in SICKBEARD_FAILED or SICKBEARD_TORRENT else forks[fork_default] - except ConfigParser.NoOptionError: - fork = forks[fork_default] + fork = forks.items()[forks.keys().index(config.get(section, "fork"))] + except: + fork = forks.items()[forks.keys().index(fork_default)] myOpener = AuthURLOpener(username, password) @@ -63,20 +60,24 @@ def autoFork(fork=None): else: protocol = "http://" - if fork in "auto": + detected = False + if fork is "auto": Logger.info("Attempting to auto-detect SickBeard fork") - for f in forks.iteritems(): - url = protocol + host + ":" + port + web_root + "/home/postprocess/processEpisode?" + urllib.urlencode(f[1]) + for fork in sorted(forks.iteritems()): + url = protocol + host + ":" + port + web_root + "/home/postprocess/processEpisode?" + urllib.urlencode(fork[1]) # attempting to auto-detect fork urlObj = myOpener.openit(url) if urlObj.getcode() == 200: - Logger.info("SickBeard fork auto-detection successful. Fork set to %s", f[0]) - return f[0], f[1] + detected = True + break - # failed to auto-detect fork - Logger.info("SickBeard fork auto-detection failed") + if detected: + Logger.info("SickBeard fork auto-detection successful ...") + else: + Logger.info("SickBeard fork auto-detection failed") + fork = forks.items()[forks.keys().index(fork_default)] Logger.info("SickBeard fork set to %s", fork[0]) return fork[0], fork[1] \ No newline at end of file diff --git a/autoProcess/nzbToMediaEnv.py b/autoProcess/nzbToMediaEnv.py index b613e52a..7846c595 100644 --- a/autoProcess/nzbToMediaEnv.py +++ b/autoProcess/nzbToMediaEnv.py @@ -14,7 +14,8 @@ fork_failed = "failed" fork_failed_torrent = "failed-torrent" forks = {} -forks[fork_default] = {"dir": None, "process": None} + +forks[fork_default] = {"dir": None, "method": None} forks[fork_failed] = {"dirName": None, "failed": None} forks[fork_failed_torrent] = {"dir": None, "failed": None, "process_method": None} diff --git a/autoProcessMedia.cfg.sample b/autoProcessMedia.cfg.sample index d1e13582..f6570b17 100644 --- a/autoProcessMedia.cfg.sample +++ b/autoProcessMedia.cfg.sample @@ -39,6 +39,7 @@ nzbExtractionBy = Downloader Torrent_ForceLink = 1 process_method = + [HeadPhones] #### autoProcessing for Music #### hpCategory - category that gets called for post-processing with HP diff --git a/nzbToMedia.py b/nzbToMedia.py index 1a50a5e3..fadcee68 100755 --- a/nzbToMedia.py +++ b/nzbToMedia.py @@ -117,6 +117,11 @@ # set to 1 to delete failed, or 0 to leave files in place. #sbdelete_failed=0 +# SickBeard process method. +# +# set this to move, copy, hardlin, symlink as appropriate if you want to over-ride SB defaults. Leave blank to use SB default. +#sbprocess_method= + ## HeadPhones # HeadPhones script category. diff --git a/nzbToSickBeard.py b/nzbToSickBeard.py index 1c554fe1..78792076 100755 --- a/nzbToSickBeard.py +++ b/nzbToSickBeard.py @@ -66,6 +66,11 @@ # set to 1 to delete failed, or 0 to leave files in place. #sbdelete_failed=0 +# SickBeard process method. +# +# set this to move, copy, hardlin, symlink as appropriate if you want to over-ride SB defaults. Leave blank to use SB default. +#sbprocess_method= + ## Extensions # Media Extensions diff --git a/test.py b/test.py new file mode 100644 index 00000000..f22f0de3 --- /dev/null +++ b/test.py @@ -0,0 +1,24 @@ +import copy + +from autoProcess.autoSickBeardFork import autoFork + +fork, params = autoFork() +print fork + +failed = True +for param in copy.copy(params): + if param is "failed": + params["failed"] = failed + + if param is "dirName": + params["dirName"] = "dirName" + + if param is "dir": + params["dir"] = "dirName" + + if param is "process_method": + del param + +params['nzbName'] = "test" + +print params \ No newline at end of file