mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-19 12:59:36 -07:00
added safe_mode to prevent processing ALL downloads.
This commit is contained in:
parent
7ece7997a9
commit
07719e79b6
4 changed files with 35 additions and 3 deletions
|
@ -109,6 +109,12 @@ def processTorrent(inputDirectory, inputName, inputCategory, inputHash, inputID,
|
||||||
|
|
||||||
logger.info("Output directory set to: %s" % (outputDestination))
|
logger.info("Output directory set to: %s" % (outputDestination))
|
||||||
|
|
||||||
|
if nzbtomedia.SAFE_MODE and outputDestination == nzbtomedia.TORRENT_DEFAULTDIR:
|
||||||
|
logger.error(
|
||||||
|
'The output directory:[%s] is the Download Directory. Edit outputDirectory in autoProcessMedia.cfg. Exiting' % (
|
||||||
|
inputDirectory))
|
||||||
|
return -1
|
||||||
|
|
||||||
if not "NONE" in nzbtomedia.USER_SCRIPT_CATEGORIES: # if None, we only process the 5 listed.
|
if not "NONE" in nzbtomedia.USER_SCRIPT_CATEGORIES: # if None, we only process the 5 listed.
|
||||||
if "ALL" in nzbtomedia.USER_SCRIPT_CATEGORIES: # All defined categories
|
if "ALL" in nzbtomedia.USER_SCRIPT_CATEGORIES: # All defined categories
|
||||||
processOnly = nzbtomedia.CATEGORIES
|
processOnly = nzbtomedia.CATEGORIES
|
||||||
|
|
|
@ -24,6 +24,11 @@
|
||||||
# Enable/Disable media file checking using ffprobe.
|
# Enable/Disable media file checking using ffprobe.
|
||||||
#check_media=1
|
#check_media=1
|
||||||
|
|
||||||
|
# Safe Mode protection of DestDir (0, 1).
|
||||||
|
#
|
||||||
|
# Enable/Disable a safety check to ensure we don't process all downloads in the default_downloadDirectory by mistake.
|
||||||
|
#safe_mode=1
|
||||||
|
|
||||||
## CouchPotato
|
## CouchPotato
|
||||||
|
|
||||||
# CouchPotato script category.
|
# CouchPotato script category.
|
||||||
|
@ -309,6 +314,12 @@ from nzbtomedia import logger, nzbToMediaDB
|
||||||
|
|
||||||
# post-processing
|
# post-processing
|
||||||
def process(inputDirectory, inputName=None, status=0, clientAgent='manual', download_id=None, inputCategory=None):
|
def process(inputDirectory, inputName=None, status=0, clientAgent='manual', download_id=None, inputCategory=None):
|
||||||
|
if nzbtomedia.SAFE_MODE and inputDirectory == nzbtomedia.NZB_DEFAULTDIR:
|
||||||
|
logger.error(
|
||||||
|
'The input directory:[%s] is the Default Download Directory. Please configure category directories to prevent processing of other media.' % (
|
||||||
|
inputDirectory))
|
||||||
|
return -1
|
||||||
|
|
||||||
if clientAgent != 'manual' and not nzbtomedia.DOWNLOADINFO:
|
if clientAgent != 'manual' and not nzbtomedia.DOWNLOADINFO:
|
||||||
logger.debug('Adding NZB download info for directory %s to database' % (inputDirectory))
|
logger.debug('Adding NZB download info for directory %s to database' % (inputDirectory))
|
||||||
|
|
||||||
|
|
|
@ -75,11 +75,13 @@ GIT_USER = None
|
||||||
GIT_BRANCH = None
|
GIT_BRANCH = None
|
||||||
GIT_REPO = None
|
GIT_REPO = None
|
||||||
FORCE_CLEAN = None
|
FORCE_CLEAN = None
|
||||||
|
SAFE_MODE = None
|
||||||
|
|
||||||
NZB_CLIENTAGENT = None
|
NZB_CLIENTAGENT = None
|
||||||
SABNZBDHOST = None
|
SABNZBDHOST = None
|
||||||
SABNZBDPORT = None
|
SABNZBDPORT = None
|
||||||
SABNZBDAPIKEY = None
|
SABNZBDAPIKEY = None
|
||||||
|
NZB_DEFAULTDIR = None
|
||||||
|
|
||||||
TORRENT_CLIENTAGENT = None
|
TORRENT_CLIENTAGENT = None
|
||||||
TORRENT_CLASS = None
|
TORRENT_CLASS = None
|
||||||
|
@ -87,6 +89,7 @@ USELINK = None
|
||||||
OUTPUTDIRECTORY = None
|
OUTPUTDIRECTORY = None
|
||||||
NOFLATTEN = []
|
NOFLATTEN = []
|
||||||
DELETE_ORIGINAL = None
|
DELETE_ORIGINAL = None
|
||||||
|
TORRENT_DEFAULTDIR = None
|
||||||
|
|
||||||
UTORRENTWEBUI = None
|
UTORRENTWEBUI = None
|
||||||
UTORRENTUSR = None
|
UTORRENTUSR = None
|
||||||
|
@ -158,7 +161,8 @@ def initialize(section=None):
|
||||||
OUTPUTVIDEOBITRATE, OUTPUTAUDIOCODEC, OUTPUTAUDIOBITRATE, OUTPUTSUBTITLECODEC, OUTPUTFASTSTART, OUTPUTQUALITYPERCENT, \
|
OUTPUTVIDEOBITRATE, OUTPUTAUDIOCODEC, OUTPUTAUDIOBITRATE, OUTPUTSUBTITLECODEC, OUTPUTFASTSTART, OUTPUTQUALITYPERCENT, \
|
||||||
NICENESS, LOG_DEBUG, FORCE_CLEAN, FFMPEG_PATH, FFMPEG, FFPROBE, AUDIOCONTAINER, EXTCONTAINER, TORRENT_CLASS, \
|
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, \
|
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
|
USER_SCRIPT_PARAM, USER_SCRIPT_RUNONCE, USER_SCRIPT_SUCCESSCODES, DOWNLOADINFO, EXT_REPLACE, CHECK_MEDIA, SAFE_MODE, \
|
||||||
|
TORRENT_DEFAULTDIR, NZB_DEFAULTDIR
|
||||||
|
|
||||||
if __INITIALIZED__:
|
if __INITIALIZED__:
|
||||||
return False
|
return False
|
||||||
|
@ -228,6 +232,7 @@ def initialize(section=None):
|
||||||
FORCE_CLEAN = CFG["General"]["force_clean"]
|
FORCE_CLEAN = CFG["General"]["force_clean"]
|
||||||
FFMPEG_PATH = CFG["General"]["ffmpeg_path"]
|
FFMPEG_PATH = CFG["General"]["ffmpeg_path"]
|
||||||
CHECK_MEDIA = int(CFG["General"]["check_media"])
|
CHECK_MEDIA = int(CFG["General"]["check_media"])
|
||||||
|
SAFE_MODE = int(CFG["General"]["safe_mode"])
|
||||||
|
|
||||||
# Check for updates via GitHUB
|
# Check for updates via GitHUB
|
||||||
if versionCheck.CheckVersion().check_for_new_version():
|
if versionCheck.CheckVersion().check_for_new_version():
|
||||||
|
@ -251,10 +256,12 @@ def initialize(section=None):
|
||||||
SABNZBDHOST = CFG["Nzb"]["sabnzbd_host"]
|
SABNZBDHOST = CFG["Nzb"]["sabnzbd_host"]
|
||||||
SABNZBDPORT = int(CFG["Nzb"]["sabnzbd_port"])
|
SABNZBDPORT = int(CFG["Nzb"]["sabnzbd_port"])
|
||||||
SABNZBDAPIKEY = CFG["Nzb"]["sabnzbd_apikey"]
|
SABNZBDAPIKEY = CFG["Nzb"]["sabnzbd_apikey"]
|
||||||
|
NZB_DEFAULTDIR = int(CFG["Nzb"]["default_downloadDirectory"])
|
||||||
|
|
||||||
TORRENT_CLIENTAGENT = CFG["Torrent"]["clientAgent"] # utorrent | deluge | transmission | rtorrent | other
|
TORRENT_CLIENTAGENT = CFG["Torrent"]["clientAgent"] # utorrent | deluge | transmission | rtorrent | other
|
||||||
USELINK = CFG["Torrent"]["useLink"] # no | hard | sym
|
USELINK = CFG["Torrent"]["useLink"] # no | hard | sym
|
||||||
OUTPUTDIRECTORY = CFG["Torrent"]["outputDirectory"] # /abs/path/to/complete/
|
OUTPUTDIRECTORY = CFG["Torrent"]["outputDirectory"] # /abs/path/to/complete/
|
||||||
|
NZB_DEFAULTDIR = int(CFG["Torrent"]["default_downloadDirectory"])
|
||||||
CATEGORIES = (CFG["Torrent"]["categories"]) # music,music_videos,pictures,software
|
CATEGORIES = (CFG["Torrent"]["categories"]) # music,music_videos,pictures,software
|
||||||
NOFLATTEN = (CFG["Torrent"]["noFlatten"])
|
NOFLATTEN = (CFG["Torrent"]["noFlatten"])
|
||||||
if isinstance(NOFLATTEN, str): NOFLATTEN = NOFLATTEN.split(',')
|
if isinstance(NOFLATTEN, str): NOFLATTEN = NOFLATTEN.split(',')
|
||||||
|
|
|
@ -229,10 +229,18 @@ class ConfigObj(configobj.ConfigObj, Section):
|
||||||
# load configs into memory
|
# load configs into memory
|
||||||
CFG_NEW = config()
|
CFG_NEW = config()
|
||||||
|
|
||||||
|
try:
|
||||||
|
section = "Nzb"
|
||||||
|
key = 'NZBOP_DESTDIR'
|
||||||
|
if os.environ.has_key(key):
|
||||||
|
option = default_downloadDirectory
|
||||||
|
value = os.environ[key]
|
||||||
|
CFG_NEW[section][option] = value
|
||||||
|
|
||||||
try:
|
try:
|
||||||
section = "General"
|
section = "General"
|
||||||
envKeys = ['AUTO_UPDATE', 'CHECK_MEDIA']
|
envKeys = ['AUTO_UPDATE', 'CHECK_MEDIA', 'SAFE_MODE']
|
||||||
cfgKeys = ['auto_update', 'check_media']
|
cfgKeys = ['auto_update', 'check_media', 'safe_mode']
|
||||||
for index in range(len(envKeys)):
|
for index in range(len(envKeys)):
|
||||||
key = 'NZBPO_' + envKeys[index]
|
key = 'NZBPO_' + envKeys[index]
|
||||||
if os.environ.has_key(key):
|
if os.environ.has_key(key):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue