From d216ed4be7e7b05172b6c65e4e523716a6d3dce7 Mon Sep 17 00:00:00 2001 From: Smenus Date: Sat, 5 Apr 2014 23:32:47 +0100 Subject: [PATCH 1/6] Fixed incorrect config usage. --- DeleteSamples.py | 10 +++++----- ResetDateTime.py | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/DeleteSamples.py b/DeleteSamples.py index b1a917a5..d95aff58 100644 --- a/DeleteSamples.py +++ b/DeleteSamples.py @@ -62,13 +62,13 @@ if os.environ.has_key('NZBOP_SCRIPTDIR') and not os.environ['NZBOP_VERSION'][0:5 if os.environ['NZBOP_UNPACK'] != 'yes': print "Please enable option \"Unpack\" in nzbget configuration file, exiting." - sys.exit(config().POSTPROCESS_ERROR) + sys.exit(config.POSTPROCESS_ERROR) # Check par status if os.environ['NZBPP_PARSTATUS'] == '3': print "Par-check successful, but Par-repair disabled, exiting." print "Please check your Par-repair settings for future downloads." - sys.exit(config().POSTPROCESS_NONE) + sys.exit(config.POSTPROCESS_NONE) if os.environ['NZBPP_PARSTATUS'] == '1' or os.environ['NZBPP_PARSTATUS'] == '4': print "Par-repair failed, setting status \"failed\"." @@ -99,7 +99,7 @@ if os.environ.has_key('NZBOP_SCRIPTDIR') and not os.environ['NZBOP_VERSION'][0:5 # All checks done, now launching the script. if status == 1: - sys.exit(config().POSTPROCESS_NONE) + sys.exit(config.POSTPROCESS_NONE) mediaContainer = os.environ['NZBPO_MEDIAEXTENSIONS'].split(',') SampleIDs = os.environ['NZBPO_SAMPLEIDS'].split(',') @@ -116,8 +116,8 @@ if os.environ.has_key('NZBOP_SCRIPTDIR') and not os.environ['NZBOP_VERSION'][0:5 os.unlink(filePath) except: print "Error: unable to delete file", filePath - sys.exit(config().POSTPROCESS_ERROR) - sys.exit(config().POSTPROCESS_SUCCESS) + sys.exit(config.POSTPROCESS_ERROR) + sys.exit(config.POSTPROCESS_SUCCESS) else: print "This script can only be called from NZBGet (11.0 or later)." diff --git a/ResetDateTime.py b/ResetDateTime.py index 7d5b11ad..6c7fc7a6 100644 --- a/ResetDateTime.py +++ b/ResetDateTime.py @@ -29,13 +29,13 @@ if os.environ.has_key('NZBOP_SCRIPTDIR') and not os.environ['NZBOP_VERSION'][0:5 if os.environ['NZBOP_UNPACK'] != 'yes': print "Please enable option \"Unpack\" in nzbget configuration file, exiting." - sys.exit(config().POSTPROCESS_ERROR) + sys.exit(config.POSTPROCESS_ERROR) # Check par status if os.environ['NZBPP_PARSTATUS'] == '3': print "Par-check successful, but Par-repair disabled, exiting." print "Please check your Par-repair settings for future downloads." - sys.exit(config().POSTPROCESS_NONE) + sys.exit(config.POSTPROCESS_NONE) if os.environ['NZBPP_PARSTATUS'] == '1' or os.environ['NZBPP_PARSTATUS'] == '4': print "Par-repair failed, setting status \"failed\"." @@ -66,7 +66,7 @@ if os.environ.has_key('NZBOP_SCRIPTDIR') and not os.environ['NZBOP_VERSION'][0:5 # All checks done, now launching the script. if status == 1: - sys.exit(config().POSTPROCESS_NONE) + sys.exit(config.POSTPROCESS_NONE) directory = os.path.normpath(os.environ['NZBPP_DIRECTORY']) for dirpath, dirnames, filenames in os.walk(directory): @@ -78,8 +78,8 @@ if os.environ.has_key('NZBOP_SCRIPTDIR') and not os.environ['NZBOP_VERSION'][0:5 continue except: print "Error: unable to reset time for file", file - sys.exit(config().POSTPROCESS_ERROR) - sys.exit(config().POSTPROCESS_SUCCESS) + sys.exit(config.POSTPROCESS_ERROR) + sys.exit(config.POSTPROCESS_SUCCESS) else: print "This script can only be called from NZBGet (11.0 or later)." From 18aec92888cc5da1eb5d37f49373a62b06441517 Mon Sep 17 00:00:00 2001 From: Smenus Date: Sat, 5 Apr 2014 23:33:14 +0100 Subject: [PATCH 2/6] SB category for NZBGet got mangled. --- nzbToMedia.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nzbToMedia.py b/nzbToMedia.py index 214a52a3..bf2a9de9 100755 --- a/nzbToMedia.py +++ b/nzbToMedia.py @@ -79,7 +79,7 @@ sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), 'lib' # SickBeard script category. # # category that gets called for post-processing with SickBeard. -#config().sbCategory=tv +#sbCategory=tv # SickBeard host. #sbhost=localhost From c3b029f19b89583ee55bd3189fd038256b3fe1d2 Mon Sep 17 00:00:00 2001 From: Smenus Date: Sat, 5 Apr 2014 23:33:39 +0100 Subject: [PATCH 3/6] Correctly import NZBGet config values. --- nzbtomedia/migratecfg.py | 81 ++++++++++++++++++++++------------------ 1 file changed, 45 insertions(+), 36 deletions(-) diff --git a/nzbtomedia/migratecfg.py b/nzbtomedia/migratecfg.py index d1382a65..4aafbe3e 100644 --- a/nzbtomedia/migratecfg.py +++ b/nzbtomedia/migratecfg.py @@ -133,62 +133,71 @@ class migratecfg: envCatKey = 'NZBPO_CPSCATEGORY' envKeys = ['APIKEY', 'HOST', 'PORT', 'SSL', 'WEB_ROOT', 'DELAY', 'METHOD', 'DELETE_FAILED', 'REMOTECPS', 'WAIT_FOR', 'TIMEPERGIB'] cfgKeys = ['apikey', 'host', 'port', 'ssl', 'web_root', 'delay', 'method', 'delete_failed', 'remoteCPS', 'wait_for', 'TimePerGiB'] - for index in range(len(envKeys)): - key = 'NZBPO_CPS' + envKeys[index] - if os.environ.has_key(key): - option = cfgKeys[index] - value = os.environ[key] - if os.environ[envCatKey] in confignew[section].sections: - confignew[section][envCatKey][option] = value - + if os.environ.has_key(envCatKey): + for index in range(len(envKeys)): + key = 'NZBPO_CPS' + envKeys[index] + if os.environ.has_key(key): + option = cfgKeys[index] + value = os.environ[key] + if os.environ[envCatKey] not in confignew[section].sections: + confignew[section][os.environ[envCatKey]] = {} + confignew[section][os.environ[envCatKey]][option] = value section = "SickBeard" envCatKey = 'NZBPO_SBCATEGORY' envKeys = ['HOST', 'PORT', 'USERNAME', 'PASSWORD', 'SSL', 'WEB_ROOT', 'WATCH_DIR', 'FORK', 'DELETE_FAILED', 'DELAY', 'TIMEPERGIB', 'PROCESS_METHOD'] cfgKeys = ['host', 'port', 'username', 'password', 'ssl', 'web_root', 'watch_dir', 'fork', 'delete_failed', 'delay', 'TimePerGiB', 'process_method'] - for index in range(len(envKeys)): - key = 'NZBPO_SB' + envKeys[index] - if os.environ.has_key(key): - option = cfgKeys[index] - value = os.environ[key] - if os.environ[envCatKey] in confignew[section].sections: - confignew[section][envCatKey][option] = value + if os.environ.has_key(envCatKey): + for index in range(len(envKeys)): + key = 'NZBPO_SB' + envKeys[index] + if os.environ.has_key(key): + option = cfgKeys[index] + value = os.environ[key] + if os.environ[envCatKey] not in confignew[section].sections: + confignew[section][os.environ[envCatKey]] = {} + confignew[section][os.environ[envCatKey]][option] = value section = "HeadPhones" envCatKey = 'NZBPO_HPCATEGORY' envKeys = ['APIKEY', 'HOST', 'PORT', 'SSL', 'WEB_ROOT', 'DELAY', 'TIMEPERGIB'] cfgKeys = ['apikey', 'host', 'port', 'ssl', 'web_root', 'delay', 'TimePerGiB'] - for index in range(len(envKeys)): - key = 'NZBPO_HP' + envKeys[index] - if os.environ.has_key(key): - option = cfgKeys[index] - value = os.environ[key] - if os.environ[envCatKey] in confignew[section].sections: - confignew[section][envCatKey][option] = value + if os.environ.has_key(envCatKey): + for index in range(len(envKeys)): + key = 'NZBPO_HP' + envKeys[index] + if os.environ.has_key(key): + option = cfgKeys[index] + value = os.environ[key] + if os.environ[envCatKey] not in confignew[section].sections: + confignew[section][os.environ[envCatKey]] = {} + confignew[section][os.environ[envCatKey]][option] = value section = "Mylar" envCatKey = 'NZBPO_MYCATEGORY' envKeys = ['HOST', 'PORT', 'USERNAME', 'PASSWORD', 'SSL', 'WEB_ROOT'] cfgKeys = ['host', 'port', 'username', 'password', 'ssl', 'web_root'] - for index in range(len(envKeys)): - key = 'NZBPO_MY' + envKeys[index] - if os.environ.has_key(key): - option = cfgKeys[index] - value = os.environ[key] - if os.environ[envCatKey] in confignew[section].sections: - confignew[section][envCatKey][option] = value + if os.environ.has_key(envCatKey): + for index in range(len(envKeys)): + key = 'NZBPO_MY' + envKeys[index] + if os.environ.has_key(key): + option = cfgKeys[index] + value = os.environ[key] + if os.environ[envCatKey] not in confignew[section].sections: + confignew[section][os.environ[envCatKey]] = {} + confignew[section][os.environ[envCatKey]][option] = value section = "Gamez" envCatKey = 'NZBPO_GZCATEGORY' envKeys = ['APIKEY', 'HOST', 'PORT', 'SSL', 'WEB_ROOT'] cfgKeys = ['apikey', 'host', 'port', 'ssl', 'web_root'] - for index in range(len(envKeys)): - key = 'NZBPO_GZ' + envKeys[index] - if os.environ.has_key(key): - option = cfgKeys[index] - value = os.environ[key] - if os.environ[envCatKey] in confignew[section].sections: - confignew[section][envCatKey][option] = value + if os.environ.has_key(envCatKey): + for index in range(len(envKeys)): + key = 'NZBPO_GZ' + envKeys[index] + if os.environ.has_key(key): + option = cfgKeys[index] + value = os.environ[key] + if os.environ[envCatKey] not in confignew[section].sections: + confignew[section][os.environ[envCatKey]] = {} + confignew[section][os.environ[envCatKey]][option] = value section = "Extensions" envKeys = ['COMPRESSEDEXTENSIONS', 'MEDIAEXTENSIONS', 'METAEXTENSIONS'] From 46ffb894836afeb7264c1b15a2d3a65e097f4279 Mon Sep 17 00:00:00 2001 From: Smenus Date: Sat, 5 Apr 2014 23:40:34 +0100 Subject: [PATCH 4/6] Added new logging.cfg to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index d47fee77..a810d779 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ autoProcessMedia.cfg +logging.cfg *.pyc *.pyo From 08c3e3ad1b8d0c8f81385d20208de330098730c4 Mon Sep 17 00:00:00 2001 From: Smenus Date: Sat, 5 Apr 2014 23:51:08 +0100 Subject: [PATCH 5/6] Another attempt at a fix for DeleteSamples and ResetDateTime. --- DeleteSamples.py | 10 +++++----- ResetDateTime.py | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/DeleteSamples.py b/DeleteSamples.py index d95aff58..43592ad5 100644 --- a/DeleteSamples.py +++ b/DeleteSamples.py @@ -62,13 +62,13 @@ if os.environ.has_key('NZBOP_SCRIPTDIR') and not os.environ['NZBOP_VERSION'][0:5 if os.environ['NZBOP_UNPACK'] != 'yes': print "Please enable option \"Unpack\" in nzbget configuration file, exiting." - sys.exit(config.POSTPROCESS_ERROR) + sys.exit(config.NZBGET_POSTPROCESS_ERROR) # Check par status if os.environ['NZBPP_PARSTATUS'] == '3': print "Par-check successful, but Par-repair disabled, exiting." print "Please check your Par-repair settings for future downloads." - sys.exit(config.POSTPROCESS_NONE) + sys.exit(config.NZBGET_POSTPROCESS_NONE) if os.environ['NZBPP_PARSTATUS'] == '1' or os.environ['NZBPP_PARSTATUS'] == '4': print "Par-repair failed, setting status \"failed\"." @@ -99,7 +99,7 @@ if os.environ.has_key('NZBOP_SCRIPTDIR') and not os.environ['NZBOP_VERSION'][0:5 # All checks done, now launching the script. if status == 1: - sys.exit(config.POSTPROCESS_NONE) + sys.exit(config.NZBGET_POSTPROCESS_NONE) mediaContainer = os.environ['NZBPO_MEDIAEXTENSIONS'].split(',') SampleIDs = os.environ['NZBPO_SAMPLEIDS'].split(',') @@ -116,8 +116,8 @@ if os.environ.has_key('NZBOP_SCRIPTDIR') and not os.environ['NZBOP_VERSION'][0:5 os.unlink(filePath) except: print "Error: unable to delete file", filePath - sys.exit(config.POSTPROCESS_ERROR) - sys.exit(config.POSTPROCESS_SUCCESS) + sys.exit(config.NZBGET_POSTPROCESS_ERROR) + sys.exit(config.NZBGET_POSTPROCESS_SUCCESS) else: print "This script can only be called from NZBGet (11.0 or later)." diff --git a/ResetDateTime.py b/ResetDateTime.py index 6c7fc7a6..4965b8a9 100644 --- a/ResetDateTime.py +++ b/ResetDateTime.py @@ -29,13 +29,13 @@ if os.environ.has_key('NZBOP_SCRIPTDIR') and not os.environ['NZBOP_VERSION'][0:5 if os.environ['NZBOP_UNPACK'] != 'yes': print "Please enable option \"Unpack\" in nzbget configuration file, exiting." - sys.exit(config.POSTPROCESS_ERROR) + sys.exit(config.NZBGET_POSTPROCESS_ERROR) # Check par status if os.environ['NZBPP_PARSTATUS'] == '3': print "Par-check successful, but Par-repair disabled, exiting." print "Please check your Par-repair settings for future downloads." - sys.exit(config.POSTPROCESS_NONE) + sys.exit(config.NZBGET_POSTPROCESS_NONE) if os.environ['NZBPP_PARSTATUS'] == '1' or os.environ['NZBPP_PARSTATUS'] == '4': print "Par-repair failed, setting status \"failed\"." @@ -66,7 +66,7 @@ if os.environ.has_key('NZBOP_SCRIPTDIR') and not os.environ['NZBOP_VERSION'][0:5 # All checks done, now launching the script. if status == 1: - sys.exit(config.POSTPROCESS_NONE) + sys.exit(config.NZBGET_POSTPROCESS_NONE) directory = os.path.normpath(os.environ['NZBPP_DIRECTORY']) for dirpath, dirnames, filenames in os.walk(directory): @@ -78,8 +78,8 @@ if os.environ.has_key('NZBOP_SCRIPTDIR') and not os.environ['NZBOP_VERSION'][0:5 continue except: print "Error: unable to reset time for file", file - sys.exit(config.POSTPROCESS_ERROR) - sys.exit(config.POSTPROCESS_SUCCESS) + sys.exit(config.NZBGET_POSTPROCESS_ERROR) + sys.exit(config.NZBGET_POSTPROCESS_SUCCESS) else: print "This script can only be called from NZBGet (11.0 or later)." From 385285e718a5cd989be92378b112f5422b6f8384 Mon Sep 17 00:00:00 2001 From: Smenus Date: Sat, 5 Apr 2014 23:57:58 +0100 Subject: [PATCH 6/6] Fixed permissions. --- DeleteSamples.py | 0 ResetDateTime.py | 0 2 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 DeleteSamples.py mode change 100644 => 100755 ResetDateTime.py diff --git a/DeleteSamples.py b/DeleteSamples.py old mode 100644 new mode 100755 diff --git a/ResetDateTime.py b/ResetDateTime.py old mode 100644 new mode 100755