mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-20 13:23:18 -07:00
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:
commit
369f69c140
8 changed files with 55 additions and 36 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -4,3 +4,4 @@ autoProcessMedia.cfg
|
||||||
*.pyo
|
*.pyo
|
||||||
|
|
||||||
postprocess.log
|
postprocess.log
|
||||||
|
/.idea/
|
||||||
|
|
|
@ -1,18 +1,13 @@
|
||||||
import sys
|
|
||||||
import urllib
|
import urllib
|
||||||
import os
|
|
||||||
import ConfigParser
|
|
||||||
import logging
|
import logging
|
||||||
import shutil
|
|
||||||
import time
|
|
||||||
import socket
|
|
||||||
import copy
|
import copy
|
||||||
|
|
||||||
import Transcoder
|
import Transcoder
|
||||||
from nzbToMediaEnv import *
|
from nzbToMediaEnv import *
|
||||||
from nzbToMediaUtil import *
|
from nzbToMediaUtil import *
|
||||||
from nzbToMediaSceneExceptions import process_all_exceptions
|
from nzbToMediaSceneExceptions import process_all_exceptions
|
||||||
from autoSickBeardFork import autoFork
|
from autoProcess.autoSickBeardFork import autoFork
|
||||||
|
|
||||||
|
|
||||||
Logger = logging.getLogger()
|
Logger = logging.getLogger()
|
||||||
|
|
||||||
|
@ -69,22 +64,18 @@ def processEpisode(dirName, nzbName=None, failed=False, clientAgent=None, inputC
|
||||||
ssl = int(config.get(section, "ssl"))
|
ssl = int(config.get(section, "ssl"))
|
||||||
except (ConfigParser.NoOptionError, ValueError):
|
except (ConfigParser.NoOptionError, ValueError):
|
||||||
ssl = 0
|
ssl = 0
|
||||||
|
|
||||||
try:
|
try:
|
||||||
web_root = config.get(section, "web_root")
|
web_root = config.get(section, "web_root")
|
||||||
except ConfigParser.NoOptionError:
|
except ConfigParser.NoOptionError:
|
||||||
web_root = ""
|
web_root = ""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
watch_dir = config.get(section, "watch_dir")
|
watch_dir = config.get(section, "watch_dir")
|
||||||
except ConfigParser.NoOptionError:
|
except ConfigParser.NoOptionError:
|
||||||
watch_dir = ""
|
watch_dir = ""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
transcode = int(config.get("Transcoder", "transcode"))
|
transcode = int(config.get("Transcoder", "transcode"))
|
||||||
except (ConfigParser.NoOptionError, ValueError):
|
except (ConfigParser.NoOptionError, ValueError):
|
||||||
transcode = 0
|
transcode = 0
|
||||||
|
|
||||||
try:
|
try:
|
||||||
delete_failed = int(config.get(section, "delete_failed"))
|
delete_failed = int(config.get(section, "delete_failed"))
|
||||||
except (ConfigParser.NoOptionError, ValueError):
|
except (ConfigParser.NoOptionError, ValueError):
|
||||||
|
@ -105,7 +96,6 @@ def processEpisode(dirName, nzbName=None, failed=False, clientAgent=None, inputC
|
||||||
nzbExtractionBy = config.get(section, "nzbExtractionBy")
|
nzbExtractionBy = config.get(section, "nzbExtractionBy")
|
||||||
except (ConfigParser.NoOptionError, ValueError):
|
except (ConfigParser.NoOptionError, ValueError):
|
||||||
nzbExtractionBy = "Downloader"
|
nzbExtractionBy = "Downloader"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
process_method = config.get(section, "process_method")
|
process_method = config.get(section, "process_method")
|
||||||
except ConfigParser.NoOptionError:
|
except ConfigParser.NoOptionError:
|
||||||
|
@ -163,10 +153,7 @@ def processEpisode(dirName, nzbName=None, failed=False, clientAgent=None, inputC
|
||||||
if param is "failed":
|
if param is "failed":
|
||||||
params[param] = failed
|
params[param] = failed
|
||||||
|
|
||||||
if param is "dirName":
|
if param is "dirName" or param is "dir":
|
||||||
params[param] = dirName
|
|
||||||
|
|
||||||
if param is "dir":
|
|
||||||
params[param] = dirName
|
params[param] = dirName
|
||||||
|
|
||||||
if param is "process_method":
|
if param is "process_method":
|
||||||
|
@ -175,12 +162,6 @@ def processEpisode(dirName, nzbName=None, failed=False, clientAgent=None, inputC
|
||||||
else:
|
else:
|
||||||
del params[param]
|
del params[param]
|
||||||
|
|
||||||
if param is "process":
|
|
||||||
params["process"] = None
|
|
||||||
|
|
||||||
if param is "process_method":
|
|
||||||
params["process_method"] = None
|
|
||||||
|
|
||||||
if nzbName != None:
|
if nzbName != None:
|
||||||
params['nzbName'] = nzbName
|
params['nzbName'] = nzbName
|
||||||
|
|
||||||
|
|
|
@ -49,12 +49,9 @@ def autoFork(fork=None):
|
||||||
web_root = ""
|
web_root = ""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
fork = config.get(section, "fork")
|
fork = forks.items()[forks.keys().index(config.get(section, "fork"))]
|
||||||
if not fork in "auto":
|
except:
|
||||||
fork = forks[fork] \
|
fork = forks.items()[forks.keys().index(fork_default)]
|
||||||
if fork in SICKBEARD_FAILED or SICKBEARD_TORRENT else forks[fork_default]
|
|
||||||
except ConfigParser.NoOptionError:
|
|
||||||
fork = forks[fork_default]
|
|
||||||
|
|
||||||
myOpener = AuthURLOpener(username, password)
|
myOpener = AuthURLOpener(username, password)
|
||||||
|
|
||||||
|
@ -63,20 +60,24 @@ def autoFork(fork=None):
|
||||||
else:
|
else:
|
||||||
protocol = "http://"
|
protocol = "http://"
|
||||||
|
|
||||||
if fork in "auto":
|
detected = False
|
||||||
|
if fork is "auto":
|
||||||
Logger.info("Attempting to auto-detect SickBeard fork")
|
Logger.info("Attempting to auto-detect SickBeard fork")
|
||||||
for f in forks.iteritems():
|
for fork in sorted(forks.iteritems()):
|
||||||
url = protocol + host + ":" + port + web_root + "/home/postprocess/processEpisode?" + urllib.urlencode(f[1])
|
url = protocol + host + ":" + port + web_root + "/home/postprocess/processEpisode?" + urllib.urlencode(fork[1])
|
||||||
|
|
||||||
# attempting to auto-detect fork
|
# attempting to auto-detect fork
|
||||||
urlObj = myOpener.openit(url)
|
urlObj = myOpener.openit(url)
|
||||||
|
|
||||||
if urlObj.getcode() == 200:
|
if urlObj.getcode() == 200:
|
||||||
Logger.info("SickBeard fork auto-detection successful. Fork set to %s", f[0])
|
detected = True
|
||||||
return f[0], f[1]
|
break
|
||||||
|
|
||||||
# failed to auto-detect fork
|
if detected:
|
||||||
Logger.info("SickBeard fork auto-detection failed")
|
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])
|
Logger.info("SickBeard fork set to %s", fork[0])
|
||||||
return fork[0], fork[1]
|
return fork[0], fork[1]
|
|
@ -14,7 +14,8 @@ fork_failed = "failed"
|
||||||
fork_failed_torrent = "failed-torrent"
|
fork_failed_torrent = "failed-torrent"
|
||||||
|
|
||||||
forks = {}
|
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] = {"dirName": None, "failed": None}
|
||||||
forks[fork_failed_torrent] = {"dir": None, "failed": None, "process_method": None}
|
forks[fork_failed_torrent] = {"dir": None, "failed": None, "process_method": None}
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,7 @@ nzbExtractionBy = Downloader
|
||||||
Torrent_ForceLink = 1
|
Torrent_ForceLink = 1
|
||||||
process_method =
|
process_method =
|
||||||
|
|
||||||
|
|
||||||
[HeadPhones]
|
[HeadPhones]
|
||||||
#### autoProcessing for Music
|
#### autoProcessing for Music
|
||||||
#### hpCategory - category that gets called for post-processing with HP
|
#### hpCategory - category that gets called for post-processing with HP
|
||||||
|
|
|
@ -117,6 +117,11 @@
|
||||||
# set to 1 to delete failed, or 0 to leave files in place.
|
# set to 1 to delete failed, or 0 to leave files in place.
|
||||||
#sbdelete_failed=0
|
#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
|
||||||
|
|
||||||
# HeadPhones script category.
|
# HeadPhones script category.
|
||||||
|
|
|
@ -66,6 +66,11 @@
|
||||||
# set to 1 to delete failed, or 0 to leave files in place.
|
# set to 1 to delete failed, or 0 to leave files in place.
|
||||||
#sbdelete_failed=0
|
#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
|
## Extensions
|
||||||
|
|
||||||
# Media Extensions
|
# Media Extensions
|
||||||
|
|
24
test.py
Normal file
24
test.py
Normal 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
|
Loading…
Add table
Add a link
Reference in a new issue