Skip to content

Commit

Permalink
custom output directories for downloaders
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Higgins committed Dec 9, 2016
1 parent fa916c5 commit 2ff6547
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 3 deletions.
17 changes: 17 additions & 0 deletions NZBGetPostProcess.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ###
##############################################################################

Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand Down
5 changes: 5 additions & 0 deletions SABPostProcess.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 3 additions & 0 deletions autoProcess.ini.sample
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ action_after = removedata
host = http://localhost:8080/
username =
password =
output_directory =

[Deluge]
host = localhost
Expand All @@ -93,6 +94,7 @@ sickbeard-label = sickbeard
port = 58846
sickrage-label = sickrage
couchpotato-label = couchpotato
output_directory =

[SABNZBD]
convert = True
Expand All @@ -101,6 +103,7 @@ sonarr-category = sonarr
bypass-category = bypass
couchpotato-category = couchpotato
sickbeard-category = sickbeard
output_directory =

[Sickrage]
host = localhost
Expand Down
5 changes: 5 additions & 0 deletions delugePostProcess.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
24 changes: 21 additions & 3 deletions readSettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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',
Expand Down Expand Up @@ -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()
Expand All @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
5 changes: 5 additions & 0 deletions uTorrentPostProcess.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2ff6547

Please sign in to comment.