Fixed bug in autoSickBeardFork where it was improperly returning values.

Fixed constants for default fork as it has no process param but does have method.
This commit is contained in:
echel0n 2014-03-31 00:22:36 -07:00
commit 369f69c140
8 changed files with 55 additions and 36 deletions

1
.gitignore vendored
View file

@ -4,3 +4,4 @@ autoProcessMedia.cfg
*.pyo
postprocess.log
/.idea/

View file

@ -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

View file

@ -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]

View file

@ -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}

View file

@ -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

View file

@ -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.

View file

@ -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

24
test.py Normal file
View file

@ -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