diff --git a/autoProcessMedia.cfg.spec b/autoProcessMedia.cfg.spec index 1dfe2327..fb92cb3b 100644 --- a/autoProcessMedia.cfg.spec +++ b/autoProcessMedia.cfg.spec @@ -45,8 +45,8 @@ minSize = 0 # Enable/Disable deleteing ignored files (samples and invalid media files) delete_ignored = 0 - ##### Set to path where completed downloads are found on remote server for this category - remote_path = + ##### Enable if Couchpotato is on a remote server for this category + remote_path = 0 ##### Set to path where download client places completed downloads locally for this category watch_dir = @@ -73,8 +73,8 @@ minSize = 0 # Enable/Disable deleteing ignored files (samples and invalid media files) delete_ignored = 0 - ##### Set to path where completed downloads are found on remote server for this category - remote_path = + ##### Enable if SickBeard is on a remote server for this category + remote_path = 0 ##### Set to path where download client places completed downloads locally for this category watch_dir = @@ -101,8 +101,8 @@ minSize = 0 # Enable/Disable deleteing ignored files (samples and invalid media files) delete_ignored = 0 - ##### Set to path where completed downloads are found on remote server for this category - remote_path = + ##### Enable if NzbDrone is on a remote server for this category + remote_path = 0 ##### Set to path where download client places completed downloads locally for this category watch_dir = @@ -125,8 +125,8 @@ minSize = 0 # Enable/Disable deleteing ignored files (samples and invalid media files) delete_ignored = 0 - ##### Set to path where completed downloads are found on remote server for this category - remote_path = + ##### Enable if HeadPhones is on a remote server for this category + remote_path = 0 ##### Set to path where download client places completed downloads locally for this category watch_dir = @@ -149,8 +149,8 @@ minSize = 0 # Enable/Disable deleteing ignored files (samples and invalid media files) delete_ignored = 0 - ##### Set to path where completed downloads are found on remote server for this category - remote_path = + ##### Enable if Mylar is on a remote server for this category + remote_path = 0 ##### Set to path where download client places completed downloads locally for this category watch_dir = @@ -174,11 +174,16 @@ minSize = 0 # Enable/Disable deleteing ignored files (samples and invalid media files) delete_ignored = 0 - ##### Set to path where completed downloads are found on remote server for this category - remote_path = + ##### Enable if Gamez is on a remote server for this category + remote_path = 0 ##### Set to path where download client places completed downloads locally for this category watch_dir = +[Network] + # Enter Mount points as LocalPath,RemotePath and separate each pair with '|' + # e.g. MountPoints = /volume1/Public/,E:\|/volume2/share/,\\NAS\ + mount_points = + [Nzb] ###### clientAgent - Supported clients: sabnzbd, nzbget clientAgent = sabnzbd diff --git a/nzbToCouchPotato.py b/nzbToCouchPotato.py index 6bb87e03..c37d82ee 100755 --- a/nzbToCouchPotato.py +++ b/nzbToCouchPotato.py @@ -77,8 +77,16 @@ # CouchPotatoServer and NZBGet are a different system (0, 1). # -# Set to path where completed downloads go on the remote CouchPotatoServer. -#cpsremote_path = +# Enable to replace local path with the path as per the mountPoints below. +#cpsremote_path=0 + +## Network + +# Network Mount Points (Needed for remote path above) +# +# Enter Mount points as LocalPath,RemotePath and separate each pair with '|' +# e.g. mountPoints=/volume1/Public/,E:\|/volume2/share/,\\NAS\ +#mountPoints= ## Extensions diff --git a/nzbToHeadPhones.py b/nzbToHeadPhones.py index c96e2e8c..ce7b654a 100755 --- a/nzbToHeadPhones.py +++ b/nzbToHeadPhones.py @@ -60,6 +60,19 @@ # Set the number of minutes to wait after initiating HeadPhones post-processing to check if the album status has changed. #hpwait_for=2 +# HeadPhones and NZBGet are a different system (0, 1). +# +# Enable to replace local path with the path as per the mountPoints below. +#hpremote_path=0 + +## Network + +# Network Mount Points (Needed for remote path above) +# +# Enter Mount points as LocalPath,RemotePath and separate each pair with '|' +# e.g. mountPoints=/volume1/Public/,E:\|/volume2/share/,\\NAS\ +#mountPoints= + ## WakeOnLan # use WOL (0, 1). diff --git a/nzbToMedia.py b/nzbToMedia.py index 5dfcde53..e0e2332c 100755 --- a/nzbToMedia.py +++ b/nzbToMedia.py @@ -70,10 +70,10 @@ # Set the number of minutes to wait after calling the renamer, to check the movie has changed status. #cpswait_for=2 -# CouchPotatoServer and NZBGet are a different system (0, 1). +# Couchpotato and NZBGet are a different system (0, 1). # -# set to 1 if CouchPotato and NZBGet are on a different system, or 0 if on the same system. -#remoteCPS = 0 +# Enable to replace local path with the path as per the mountPoints below. +#cpsremote_path=0 ## SickBeard @@ -124,6 +124,11 @@ # 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= +# SickBeard and NZBGet are a different system (0, 1). +# +# Enable to replace local path with the path as per the mountPoints below. +#sbremote_path=0 + ## NzbDrone # NzbDrone script category. @@ -160,6 +165,11 @@ # set to 1 to delete failed, or 0 to leave files in place. #nddelete_failed=0 +# NzbDrone and NZBGet are a different system (0, 1). +# +# Enable to replace local path with the path as per the mountPoints below. +#ndremote_path=0 + ## HeadPhones # HeadPhones script category. @@ -186,6 +196,11 @@ # set this if using a reverse proxy. #hpweb_root= +# HeadPhones and NZBGet are a different system (0, 1). +# +# Enable to replace local path with the path as per the mountPoints below. +#hpremote_path=0 + ## Mylar # Mylar script category. @@ -217,6 +232,11 @@ # Set the number of minutes to wait after calling the force process, to check the issue has changed status. #myswait_for=1 +# Mylar and NZBGet are a different system (0, 1). +# +# Enable to replace local path with the path as per the mountPoints below. +#myremote_path=0 + ## Gamez # Gamez script category. @@ -248,6 +268,19 @@ # set this if using a reverse proxy. #gzweb_root= +# Gamez and NZBGet are a different system (0, 1). +# +# Enable to replace local path with the path as per the mountPoints below. +#gzremote_path=0 + +## Network + +# Network Mount Points (Needed for remote path above) +# +# Enter Mount points as LocalPath,RemotePath and separate each pair with '|' +# e.g. mountPoints=/volume1/Public/,E:\|/volume2/share/,\\NAS\ +#mountPoints= + ## Extensions # Media Extensions @@ -362,6 +395,11 @@ def process(inputDirectory, inputName=None, status=0, clientAgent='manual', down except: extract = 0 + if int(section[inputCategory]['remote_path']) and not nzbtomedia.REMOTEPATHS: + logger.error('Remote Path is enabled for %s:%s but no Network mount points are defined. Please check your autoProcessMedia.cfg, exiting!' % ( + sectionName, inputCategory)) + return -1 + if extract == 1: logger.debug('Checking for archives to extract in directory: %s' % (inputDirectory)) extractFiles(inputDirectory) diff --git a/nzbToMylar.py b/nzbToMylar.py index 5a9d077e..c34028c9 100755 --- a/nzbToMylar.py +++ b/nzbToMylar.py @@ -61,6 +61,19 @@ # set this to where your Mylar completed downloads are. #mywatch_dir= +# Mylar and NZBGet are a different system (0, 1). +# +# Enable to replace local path with the path as per the mountPoints below. +#myremote_path=0 + +## Network + +# Network Mount Points (Needed for remote path above) +# +# Enter Mount points as LocalPath,RemotePath and separate each pair with '|' +# e.g. mountPoints=/volume1/Public/,E:\|/volume2/share/,\\NAS\ +#mountPoints= + ## WakeOnLan # use WOL (0, 1). diff --git a/nzbToNzbDrone.py b/nzbToNzbDrone.py index 9f65d32d..2f2911c9 100755 --- a/nzbToNzbDrone.py +++ b/nzbToNzbDrone.py @@ -65,6 +65,19 @@ # set to 1 to delete failed, or 0 to leave files in place. #nddelete_failed=0 +# NzbDrone and NZBGet are a different system (0, 1). +# +# Enable to replace local path with the path as per the mountPoints below. +#ndremote_path=0 + +## Network + +# Network Mount Points (Needed for remote path above) +# +# Enter Mount points as LocalPath,RemotePath and separate each pair with '|' +# e.g. mountPoints=/volume1/Public/,E:\|/volume2/share/,\\NAS\ +#mountPoints= + ## Extensions # Media Extensions diff --git a/nzbToSickBeard.py b/nzbToSickBeard.py index c39fea94..afee486b 100755 --- a/nzbToSickBeard.py +++ b/nzbToSickBeard.py @@ -83,6 +83,19 @@ # 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= +# SickBeard and NZBGet are a different system (0, 1). +# +# Enable to replace local path with the path as per the mountPoints below. +#sbremote_path=0 + +## Network + +# Network Mount Points (Needed for remote path above) +# +# Enter Mount points as LocalPath,RemotePath and separate each pair with '|' +# e.g. mountPoints=/volume1/Public/,E:\|/volume2/share/,\\NAS\ +#mountPoints= + ## Extensions # Media Extensions diff --git a/nzbtomedia/__init__.py b/nzbtomedia/__init__.py index 3c763418..7f11a083 100644 --- a/nzbtomedia/__init__.py +++ b/nzbtomedia/__init__.py @@ -91,6 +91,8 @@ NOFLATTEN = [] DELETE_ORIGINAL = None TORRENT_DEFAULTDIR = None +REMOTEPATHS = None + UTORRENTWEBUI = None UTORRENTUSR = None UTORRENTPWD = None @@ -162,7 +164,7 @@ def initialize(section=None): NICENESS, LOG_DEBUG, FORCE_CLEAN, FFMPEG_PATH, FFMPEG, FFPROBE, AUDIOCONTAINER, EXTCONTAINER, TORRENT_CLASS, \ DELETE_ORIGINAL, PASSWORDSFILE, USER_DELAY, USER_SCRIPT, USER_SCRIPT_CLEAN, USER_SCRIPT_MEDIAEXTENSIONS, \ USER_SCRIPT_PARAM, USER_SCRIPT_RUNONCE, USER_SCRIPT_SUCCESSCODES, DOWNLOADINFO, EXT_REPLACE, CHECK_MEDIA, SAFE_MODE, \ - TORRENT_DEFAULTDIR, NZB_DEFAULTDIR + TORRENT_DEFAULTDIR, NZB_DEFAULTDIR, REMOTEPATHS if __INITIALIZED__: return False @@ -280,6 +282,10 @@ def initialize(section=None): DELUGEUSR = CFG["Torrent"]["DelugeUSR"] # mysecretusr DELUGEPWD = CFG["Torrent"]["DelugePWD"] # mysecretpwr + REMOTEPATHS = CFG["Network"]["mount_points"] or None + if REMOTEPATHS: + REMOTEPATHS = [ tuple(item.split(',')) for item in REMOTEPATHS.split('|') ] # /volume1/Public/,E:\|/volume2/share/,\\NAS\ + COMPRESSEDCONTAINER = [re.compile('.r\d{2}$', re.I), re.compile('.part\d+.rar$', re.I), re.compile('.rar$', re.I)] diff --git a/nzbtomedia/autoProcess/autoProcessComics.py b/nzbtomedia/autoProcess/autoProcessComics.py index 32f3cedb..bc9a1dd1 100644 --- a/nzbtomedia/autoProcess/autoProcessComics.py +++ b/nzbtomedia/autoProcess/autoProcessComics.py @@ -3,7 +3,7 @@ import time import nzbtomedia import requests import time -from nzbtomedia.nzbToMediaUtil import convert_to_ascii, replaceExtensions +from nzbtomedia.nzbToMediaUtil import convert_to_ascii, replaceExtensions, remoteDir from nzbtomedia import logger class autoProcessComics: @@ -51,28 +51,20 @@ class autoProcessComics: except: web_root = "" try: - remote_path = nzbtomedia.CFG[section][inputCategory]["remote_path"] + remote_path = int(nzbtomedia.CFG[section][inputCategory]["remote_path"]) except: - remote_path = None + remote_path = 0 inputName, dirName = convert_to_ascii(inputName, dirName) replaceExtensions(dirName) - if remote_path: - if remote_path[-1] in ['\\','/']: # supplied directory includes final directory separator - remote_path = remote_path + os.path.basename(dirName) - elif remote_path[0] == '/': # posix path - remote_path = remote_path + '/' + os.path.basename(dirName) - else: # assume windows path or UNF path - remote_path = remote_path + '\\' + os.path.basename(dirName) - params = {} params['apikey'] = apikey params['cmd'] = "forceProcess" params['nzb_folder'] = dirName if remote_path: - params['nzb_folder'] = remote_path + params['nzb_folder'] = remoteDir(dirName) if inputName != None: params['nzb_name'] = inputName diff --git a/nzbtomedia/autoProcess/autoProcessMovie.py b/nzbtomedia/autoProcess/autoProcessMovie.py index f4eb3e9b..06bc5469 100644 --- a/nzbtomedia/autoProcess/autoProcessMovie.py +++ b/nzbtomedia/autoProcess/autoProcessMovie.py @@ -4,7 +4,7 @@ import requests import nzbtomedia from nzbtomedia.nzbToMediaSceneExceptions import process_all_exceptions -from nzbtomedia.nzbToMediaUtil import convert_to_ascii, rmDir, find_imdbid, find_download, listMediaFiles +from nzbtomedia.nzbToMediaUtil import convert_to_ascii, rmDir, find_imdbid, find_download, listMediaFiles, remoteDir from nzbtomedia import logger from nzbtomedia.transcoder import transcoder @@ -113,9 +113,9 @@ class autoProcessMovie: except: web_root = "" try: - remote_path = nzbtomedia.CFG[section][inputCategory]["remote_path"] + remote_path = int(nzbtomedia.CFG[section][inputCategory]["remote_path"]) except: - remote_path = None + remote_path = 0 if ssl: protocol = "https://" @@ -145,14 +145,6 @@ class autoProcessMovie: process_all_exceptions(inputName.lower(), dirName) inputName, dirName = convert_to_ascii(inputName, dirName) - if remote_path: - if remote_path[-1] in ['\\','/']: # supplied directory includes final directory separator - remote_path = remote_path + os.path.basename(dirName) - elif remote_path[0] == '/': # posix path - remote_path = remote_path + '/' + os.path.basename(dirName) - else: # assume windows path or UNF path - remote_path = remote_path + '\\' + os.path.basename(dirName) - if status == 0: if nzbtomedia.TRANSCODE == 1: result = transcoder.Transcode_directory(dirName) @@ -173,7 +165,7 @@ class autoProcessMovie: params['media_folder'] = dirName if remote_path: - params['media_folder'] = remote_path + params['media_folder'] = remoteDir(dirName) url = "%s%s" % (baseURL, command) diff --git a/nzbtomedia/autoProcess/autoProcessMusic.py b/nzbtomedia/autoProcess/autoProcessMusic.py index 33e9fdb6..cc3d3b33 100644 --- a/nzbtomedia/autoProcess/autoProcessMusic.py +++ b/nzbtomedia/autoProcess/autoProcessMusic.py @@ -3,7 +3,7 @@ import time import requests import nzbtomedia -from nzbtomedia.nzbToMediaUtil import convert_to_ascii +from nzbtomedia.nzbToMediaUtil import convert_to_ascii, remoteDir from nzbtomedia import logger class autoProcessMusic: @@ -47,9 +47,9 @@ class autoProcessMusic: web_root = "" try: - remote_path = nzbtomedia.CFG[section][inputCategory]["remote_path"] + remote_path = int(nzbtomedia.CFG[section][inputCategory]["remote_path"]) except: - remote_path = None + remote_path = 0 if ssl: protocol = "https://" @@ -58,14 +58,6 @@ class autoProcessMusic: inputName, dirName = convert_to_ascii(inputName, dirName) - if remote_path: - if remote_path[-1] in ['\\','/']: # supplied directory includes final directory separator - remote_path = remote_path + os.path.basename(dirName) - elif remote_path[0] == '/': # posix path - remote_path = remote_path + '/' + os.path.basename(dirName) - else: # assume windows path or UNF path - remote_path = remote_path + '\\' + os.path.basename(dirName) - url = "%s%s:%s%s/api" % (protocol,host,port,web_root) if status == 0: @@ -76,7 +68,7 @@ class autoProcessMusic: params['dir'] = os.path.dirname(dirName) if remote_path: - params['dir'] = remote_path + params['dir'] = remoteDir(dirName) release_status = self.get_status(url, apikey, dirName) if not release_status: diff --git a/nzbtomedia/autoProcess/autoProcessTV.py b/nzbtomedia/autoProcess/autoProcessTV.py index e0818e3f..de17f99d 100644 --- a/nzbtomedia/autoProcess/autoProcessTV.py +++ b/nzbtomedia/autoProcess/autoProcessTV.py @@ -7,7 +7,7 @@ import nzbtomedia from nzbtomedia.nzbToMediaAutoFork import autoFork from nzbtomedia.nzbToMediaSceneExceptions import process_all_exceptions -from nzbtomedia.nzbToMediaUtil import convert_to_ascii, flatten, rmDir, listMediaFiles +from nzbtomedia.nzbToMediaUtil import convert_to_ascii, flatten, rmDir, listMediaFiles, remoteDir from nzbtomedia import logger from nzbtomedia.transcoder import transcoder @@ -73,9 +73,9 @@ class autoProcessTV: except: process_method = None try: - remote_path = nzbtomedia.CFG[section][inputCategory]["remote_path"] + remote_path = int(nzbtomedia.CFG[section][inputCategory]["remote_path"]) except: - remote_path = None + remote_path = 0 try: wait_for = int(nzbtomedia.CFG[section][inputCategory]["wait_for"]) except: @@ -107,14 +107,6 @@ class autoProcessTV: status = 1 failed = 1 - if remote_path: - if remote_path[-1] in ['\\','/']: # supplied directory includes final directory separator - remote_path = remote_path + os.path.basename(dirName) - elif remote_path[0] == '/': # posix path - remote_path = remote_path + '/' + os.path.basename(dirName) - else: # assume windows path or UNF path - remote_path = remote_path + '\\' + os.path.basename(dirName) - # configure SB params to pass fork_params['quiet'] = 1 if inputName is not None: @@ -127,7 +119,7 @@ class autoProcessTV: if param in ["dirName", "dir"]: fork_params[param] = dirName if remote_path: - fork_params[param] = remote_path + fork_params[param] = remoteDir(dirName) if param == "process_method": if process_method: diff --git a/nzbtomedia/nzbToMediaConfig.py b/nzbtomedia/nzbToMediaConfig.py index d4775368..185fd3d0 100644 --- a/nzbtomedia/nzbToMediaConfig.py +++ b/nzbtomedia/nzbToMediaConfig.py @@ -172,7 +172,11 @@ class ConfigObj(configobj.ConfigObj, Section): if option == "forceClean": CFG_NEW['General']['force_clean'] = value values.pop(option) - + if option == "remote_path": + if value and not isinstance(value, int): + value = 1 + elif not value: + value = 0 # remove any options that we no longer need so they don't migrate into our new config if not list(ConfigObj.find_key(CFG_NEW, option)): values.pop(option) @@ -247,10 +251,20 @@ class ConfigObj(configobj.ConfigObj, Section): value = os.environ[key] CFG_NEW[section][option] = value + section = "Network" + envKeys = ['MOUNTPOINTS'] + cfgKeys = ['mount_points'] + for index in range(len(envKeys)): + key = 'NZBPO_' + envKeys[index] + if os.environ.has_key(key): + option = cfgKeys[index] + value = os.environ[key] + CFG_NEW[section][option] = value + section = "CouchPotato" envCatKey = 'NZBPO_CPSCATEGORY' - envKeys = ['ENABLED', 'APIKEY', 'HOST', 'PORT', 'SSL', 'WEB_ROOT', 'METHOD', 'DELETE_FAILED', 'REMOTECPS', 'WAIT_FOR', 'WATCH_DIR'] - cfgKeys = ['enabled', 'apikey', 'host', 'port', 'ssl', 'web_root', 'method', 'delete_failed', 'remoteCPS', 'wait_for', 'watch_dir'] + envKeys = ['ENABLED', 'APIKEY', 'HOST', 'PORT', 'SSL', 'WEB_ROOT', 'METHOD', 'DELETE_FAILED', 'REMOTE_PATH' 'WAIT_FOR', 'WATCH_DIR'] + cfgKeys = ['enabled', 'apikey', 'host', 'port', 'ssl', 'web_root', 'method', 'delete_failed', 'remote_path', 'wait_for', 'watch_dir'] if os.environ.has_key(envCatKey): for index in range(len(envKeys)): key = 'NZBPO_CPS' + envKeys[index] @@ -264,8 +278,8 @@ class ConfigObj(configobj.ConfigObj, Section): section = "SickBeard" envCatKey = 'NZBPO_SBCATEGORY' - envKeys = ['ENABLED', 'HOST', 'PORT', 'USERNAME', 'PASSWORD', 'SSL', 'WEB_ROOT', 'WATCH_DIR', 'FORK', 'DELETE_FAILED', 'TORRENT_NOLINK', 'NZBEXTRACTIONBY'] - cfgKeys = ['enabled', 'host', 'port', 'username', 'password', 'ssl', 'web_root', 'watch_dir', 'fork', 'delete_failed', 'Torrent_NoLink', 'nzbExtractionBy'] + envKeys = ['ENABLED', 'HOST', 'PORT', 'USERNAME', 'PASSWORD', 'SSL', 'WEB_ROOT', 'WATCH_DIR', 'FORK', 'DELETE_FAILED', 'TORRENT_NOLINK', 'NZBEXTRACTIONBY', 'REMOTE_PATH'] + cfgKeys = ['enabled', 'host', 'port', 'username', 'password', 'ssl', 'web_root', 'watch_dir', 'fork', 'delete_failed', 'Torrent_NoLink', 'nzbExtractionBy', 'remote_path'] if os.environ.has_key(envCatKey): for index in range(len(envKeys)): key = 'NZBPO_SB' + envKeys[index] @@ -279,8 +293,8 @@ class ConfigObj(configobj.ConfigObj, Section): section = "HeadPhones" envCatKey = 'NZBPO_HPCATEGORY' - envKeys = ['ENABLED', 'APIKEY', 'HOST', 'PORT', 'SSL', 'WEB_ROOT', 'WAIT_FOR', 'WATCH_DIR'] - cfgKeys = ['enabled', 'apikey', 'host', 'port', 'ssl', 'web_root', 'wait_for', 'watch_dir'] + envKeys = ['ENABLED', 'APIKEY', 'HOST', 'PORT', 'SSL', 'WEB_ROOT', 'WAIT_FOR', 'WATCH_DIR', 'REMOTE_PATH'] + cfgKeys = ['enabled', 'apikey', 'host', 'port', 'ssl', 'web_root', 'wait_for', 'watch_dir', 'remote_path'] if os.environ.has_key(envCatKey): for index in range(len(envKeys)): key = 'NZBPO_HP' + envKeys[index] @@ -294,8 +308,8 @@ class ConfigObj(configobj.ConfigObj, Section): section = "Mylar" envCatKey = 'NZBPO_MYCATEGORY' - envKeys = ['ENABLED', 'HOST', 'PORT', 'USERNAME', 'PASSWORD', 'SSL', 'WEB_ROOT', 'WATCH_DIR'] - cfgKeys = ['enabled', 'host', 'port', 'username', 'password', 'ssl', 'web_root', 'watch_dir'] + envKeys = ['ENABLED', 'HOST', 'PORT', 'USERNAME', 'PASSWORD', 'SSL', 'WEB_ROOT', 'WATCH_DIR', 'REMOTE_PATH'] + cfgKeys = ['enabled', 'host', 'port', 'username', 'password', 'ssl', 'web_root', 'watch_dir', 'remote_path'] if os.environ.has_key(envCatKey): for index in range(len(envKeys)): key = 'NZBPO_MY' + envKeys[index] @@ -309,8 +323,8 @@ class ConfigObj(configobj.ConfigObj, Section): section = "Gamez" envCatKey = 'NZBPO_GZCATEGORY' - envKeys = ['ENABLED', 'APIKEY', 'HOST', 'PORT', 'SSL', 'WEB_ROOT', 'WATCH_DIR', 'LIBRARY'] - cfgKeys = ['enabled', 'apikey', 'host', 'port', 'ssl', 'web_root', 'watch_dir', 'library'] + envKeys = ['ENABLED', 'APIKEY', 'HOST', 'PORT', 'SSL', 'WEB_ROOT', 'WATCH_DIR', 'LIBRARY', 'REMOTE_PATH'] + cfgKeys = ['enabled', 'apikey', 'host', 'port', 'ssl', 'web_root', 'watch_dir', 'library', 'remote_path'] if os.environ.has_key(envCatKey): for index in range(len(envKeys)): key = 'NZBPO_GZ' + envKeys[index] @@ -324,8 +338,8 @@ class ConfigObj(configobj.ConfigObj, Section): section = "NzbDrone" envCatKey = 'NZBPO_NDCATEGORY' - envKeys = ['ENABLED', 'HOST', 'APIKEY', 'PORT', 'SSL', 'WEB_ROOT', 'WATCH_DIR', 'FORK', 'DELETE_FAILED', 'TORRENT_NOLINK', 'NZBEXTRACTIONBY', 'WAIT_FOR', 'DELETE_FAILED'] - cfgKeys = ['enabled', 'host', 'apikey', 'port', 'ssl', 'web_root', 'watch_dir', 'fork', 'delete_failed', 'Torrent_NoLink', 'nzbExtractionBy', 'wait_for', 'delete_failed'] + envKeys = ['ENABLED', 'HOST', 'APIKEY', 'PORT', 'SSL', 'WEB_ROOT', 'WATCH_DIR', 'FORK', 'DELETE_FAILED', 'TORRENT_NOLINK', 'NZBEXTRACTIONBY', 'WAIT_FOR', 'DELETE_FAILED', 'REMOTE_PATH'] + cfgKeys = ['enabled', 'host', 'apikey', 'port', 'ssl', 'web_root', 'watch_dir', 'fork', 'delete_failed', 'Torrent_NoLink', 'nzbExtractionBy', 'wait_for', 'delete_failed', 'remote_path'] if os.environ.has_key(envCatKey): for index in range(len(envKeys)): key = 'NZBPO_ND' + envKeys[index] diff --git a/nzbtomedia/nzbToMediaUtil.py b/nzbtomedia/nzbToMediaUtil.py index 322285a0..9265bcbc 100644 --- a/nzbtomedia/nzbToMediaUtil.py +++ b/nzbtomedia/nzbToMediaUtil.py @@ -31,7 +31,7 @@ def sanitizeName(name): ''' # remove bad chars from the filename - name = re.sub(r'[\\/\*]', '-', name) + name = re.sub(r'[\\\/*]', '-', name) name = re.sub(r'[:"<>|?]', '', name) # remove leading/trailing periods and spaces @@ -62,6 +62,21 @@ def makeDir(path): return False return True +def remoteDir(path): + for local,remote in nzbtomedia.REMOTEPATHS: + if local in path: + base_dirs = path.replace(local,"").split(os.sep) + if '/' in remote: + remote_sep = '/' + else: + remote_sep = '\\' + new_path = remote_sep.join([remote] + base_dirs) + new_path = re.sub(r'(\S)(\\+)', r'\1\\', new_path) + new_path = re.sub(r'(\/+)', r'/', new_path) + new_path = re.sub(r'([\/\\])$', r'', new_path) + return new_path + return path + def category_search(inputDirectory, inputName, inputCategory, root, categories): tordir = False