diff --git a/NZBGetPostProcess.py b/NZBGetPostProcess.py index 44d7be32..077394b9 100755 --- a/NZBGetPostProcess.py +++ b/NZBGetPostProcess.py @@ -31,6 +31,9 @@ # Category for bypassing any further processing but still converting #BYPASS_CAT=Bypass +# Custom output_directory setting +#OUTPUT_DIR= + ### NZBGET POST-PROCESSING SCRIPT ### ############################################################################## @@ -49,6 +52,18 @@ MP4folder += "/" #DEBUG#print MP4folder+" the original is "+os.environ['NZBPO_MP4_FOLDER'] +output_dir = os.environment['NZBPO_OUTPUT_DIR'].stip() +if len(output_dir) > 0: + output_dir = os.environ['NZBPO_MP4_FOLDER'].strip() + output_dir = MP4folder.replace('"', '') + output_dir = MP4folder.replace("'", "") + output_dir = MP4folder.replace("\\", "/") + if not(output_dir.endswith("/")): + output_dir += "/" + #DEBUG#print Overriding output directory +else: + output_dir = None + sys.path.append(MP4folder) try: from readSettings import ReadSettings @@ -161,6 +176,8 @@ settings = ReadSettings(MP4folder, "autoProcess.ini") if shouldConvert: + if output_dir: + settings.output_dir = output_dir converter = MkvtoMp4(settings, logger=log) for r, d, f in os.walk(path): for files in f: diff --git a/SABPostProcess.py b/SABPostProcess.py index f63501f6..86323340 100644 --- a/SABPostProcess.py +++ b/SABPostProcess.py @@ -47,6 +47,11 @@ if settings.SAB['convert']: log.info("Performing conversion") + # Check for custom uTorrent output_dir + if settings.SAB['output_dir']: + settings.output_dir = settings.SAB['output_dir'] + log.debug("Overriding output_dir to %s." % settings.SAB['output_dir']) + converter = MkvtoMp4(settings) for r, d, f in os.walk(path): for files in f: diff --git a/autoProcess.ini.sample b/autoProcess.ini.sample index fa28c28e..03235223 100644 --- a/autoProcess.ini.sample +++ b/autoProcess.ini.sample @@ -81,6 +81,7 @@ action_after = removedata host = http://localhost:8080/ username = password = +output_directory = [Deluge] host = localhost @@ -93,6 +94,7 @@ sickbeard-label = sickbeard port = 58846 sickrage-label = sickrage couchpotato-label = couchpotato +output_directory = [SABNZBD] convert = True @@ -101,6 +103,7 @@ sonarr-category = sonarr bypass-category = bypass couchpotato-category = couchpotato sickbeard-category = sickbeard +output_directory = [Sickrage] host = localhost diff --git a/delugePostProcess.py b/delugePostProcess.py index f8dcff0d..cfd124bf 100644 --- a/delugePostProcess.py +++ b/delugePostProcess.py @@ -58,6 +58,11 @@ sys.exit() if settings.deluge['convert']: + # Check for custom Deluge output_dir + if settings.deluge['output_dir']: + settings.output_dir = settings.deluge['output_dir'] + log.debug("Overriding output_dir to %s." % settings.deluge['output_dir']) + # Perform conversion. settings.delete = False if not settings.output_dir: diff --git a/readSettings.py b/readSettings.py index bc36d546..55f111f3 100644 --- a/readSettings.py +++ b/readSettings.py @@ -125,14 +125,16 @@ def __init__(self, directory, filename, logger=None): 'action_after': 'removedata', 'host': 'http://localhost:8080/', 'username': '', - 'password': ''} + 'password': '', + 'output_directory': ''} # Default SAB settings sab_defaults = {'convert': 'True', 'Sickbeard-category': 'sickbeard', 'Sickrage-category': 'sickrage', 'Couchpotato-category': 'couchpotato', 'Sonarr-category': 'sonarr', - 'Bypass-category': 'bypass'} + 'Bypass-category': 'bypass', + 'output_directory': ''} # Default Sickrage Settings sr_defaults = {'host': 'localhost', 'port': '8081', @@ -152,7 +154,8 @@ def __init__(self, directory, filename, logger=None): 'host': 'localhost', 'port': '58846', 'username': '', - 'password': ''} + 'password': '', + 'output_directory': ''} # Default Plex Settings plex_defaults = {'host': 'localhost', @@ -489,6 +492,11 @@ def __init__(self, directory, filename, logger=None): self.uTorrent['convert'] = config.getboolean(section, "convert") except: self.uTorrent['convert'] = False + self.uTorrent['output_dir'] = config.get(section, "output_directory") + if self.uTorrent['output_dir'] == '': + self.uTorrent['output_dir'] = None + else: + self.uTorrent['output_dir'] = os.path.normpath(self.raw(self.uTorrent['output_dir'])) # Output directory self.uTorrentWebUI = config.getboolean(section, "webui") self.uTorrentActionBefore = config.get(section, "action_before").lower() self.uTorrentActionAfter = config.get(section, "action_after").lower() @@ -512,6 +520,11 @@ def __init__(self, directory, filename, logger=None): self.deluge['port'] = config.get(section, "port") self.deluge['user'] = config.get(section, "username") self.deluge['pass'] = config.get(section, "password") + self.deluge['output_dir'] = config.get(section, "output_directory") + if self.deluge['output_dir'] == '': + self.deluge['output_dir'] = None + else: + self.deluge['output_dir'] = os.path.normpath(self.raw(self.deluge['output_dir'])) # Output directory # Read relevant Sonarr section information section = "Sonarr" @@ -556,6 +569,11 @@ def __init__(self, directory, filename, logger=None): self.SAB['sr'] = config.get(section, "Sickrage-category").lower() self.SAB['sonarr'] = config.get(section, "Sonarr-category").lower() self.SAB['bypass'] = config.get(section, "Bypass-category").lower() + self.SAB['output_dir'] = config.get(section, "output_directory") + if self.SAB['output_dir'] == '': + self.SAB['output_dir'] = None + else: + self.SAB['output_dir'] = os.path.normpath(self.raw(self.SAB['output_dir'])) # Output directory # Read Plex section information section = "Plex" diff --git a/uTorrentPostProcess.py b/uTorrentPostProcess.py index adfce141..35fa38c5 100644 --- a/uTorrentPostProcess.py +++ b/uTorrentPostProcess.py @@ -101,6 +101,11 @@ def _sendRequest(session, host='http://localhost:8080/', username=None, password log.debug("Sending action %s to uTorrent" % settings.uTorrentActionBefore) if settings.uTorrent['convert']: + # Check for custom uTorrent output_dir + if settings.uTorrent['output_dir']: + settings.output_dir = settings.uTorrent['output_dir'] + log.debug("Overriding output_dir to %s." % settings.uTorrent['output_dir']) + # Perform conversion. log.info("Performing conversion") settings.delete = False