mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-19 21:03:14 -07:00
Merge pull request #837 from DxCx/master
Couple of enhancements for Torrents usage
This commit is contained in:
commit
90acaa4935
3 changed files with 32 additions and 4 deletions
|
@ -97,7 +97,12 @@ def processTorrent(inputDirectory, inputName, inputCategory, inputHash, inputID,
|
||||||
if clientAgent != 'manual':
|
if clientAgent != 'manual':
|
||||||
core.pause_torrent(clientAgent, inputHash, inputID, inputName)
|
core.pause_torrent(clientAgent, inputHash, inputID, inputName)
|
||||||
|
|
||||||
if uniquePath:
|
# Incase input is not directory, make sure to create one.
|
||||||
|
# This way Processing is isolated.
|
||||||
|
if not os.path.isdir(os.path.join(inputDirectory, inputName)):
|
||||||
|
basename = os.path.splitext(core.sanitizeName(inputName))[0]
|
||||||
|
outputDestination = os.path.join(core.OUTPUTDIRECTORY, inputCategory, basename)
|
||||||
|
elif uniquePath:
|
||||||
outputDestination = os.path.normpath(
|
outputDestination = os.path.normpath(
|
||||||
core.os.path.join(core.OUTPUTDIRECTORY, inputCategory, core.sanitizeName(inputName)))
|
core.os.path.join(core.OUTPUTDIRECTORY, inputCategory, core.sanitizeName(inputName)))
|
||||||
else:
|
else:
|
||||||
|
@ -197,6 +202,9 @@ def processTorrent(inputDirectory, inputName, inputCategory, inputHash, inputID,
|
||||||
|
|
||||||
logger.info("Calling %s:%s to post-process:%s" % (sectionName, usercat, inputName))
|
logger.info("Calling %s:%s to post-process:%s" % (sectionName, usercat, inputName))
|
||||||
|
|
||||||
|
if core.TORRENT_CHMOD_DIRECTORY:
|
||||||
|
core.rchmod(outputDestination, core.TORRENT_CHMOD_DIRECTORY)
|
||||||
|
|
||||||
result = [ 0, "" ]
|
result = [ 0, "" ]
|
||||||
if sectionName == 'UserScript':
|
if sectionName == 'UserScript':
|
||||||
result = external_script(outputDestination, inputName, inputCategory, section[usercat])
|
result = external_script(outputDestination, inputName, inputCategory, section[usercat])
|
||||||
|
@ -220,7 +228,9 @@ def processTorrent(inputDirectory, inputName, inputCategory, inputHash, inputID,
|
||||||
plex_update(inputCategory)
|
plex_update(inputCategory)
|
||||||
|
|
||||||
if result[0] != 0:
|
if result[0] != 0:
|
||||||
if clientAgent != 'manual':
|
if not core.TORRENT_RESUME_ON_FAILURE:
|
||||||
|
logger.error("A problem was reported in the autoProcess* script. torrent won't resume seeding (settings)")
|
||||||
|
elif clientAgent != 'manual':
|
||||||
logger.error(
|
logger.error(
|
||||||
"A problem was reported in the autoProcess* script. If torrent was paused we will resume seeding")
|
"A problem was reported in the autoProcess* script. If torrent was paused we will resume seeding")
|
||||||
core.resume_torrent(clientAgent, inputHash, inputID, inputName)
|
core.resume_torrent(clientAgent, inputHash, inputID, inputName)
|
||||||
|
|
|
@ -241,6 +241,8 @@
|
||||||
DelugePWD = your password
|
DelugePWD = your password
|
||||||
###### ADVANCED USE - ONLY EDIT IF YOU KNOW WHAT YOU'RE DOING ######
|
###### ADVANCED USE - ONLY EDIT IF YOU KNOW WHAT YOU'RE DOING ######
|
||||||
deleteOriginal = 0
|
deleteOriginal = 0
|
||||||
|
chmodDirecotry = 0
|
||||||
|
resumeOnFailure = 1
|
||||||
|
|
||||||
[Extensions]
|
[Extensions]
|
||||||
compressedExtensions = .zip,.rar,.7z,.gz,.bz,.tar,.arj,.1,.01,.001
|
compressedExtensions = .zip,.rar,.7z,.gz,.bz,.tar,.arj,.1,.01,.001
|
||||||
|
|
|
@ -98,7 +98,9 @@ USELINK = None
|
||||||
OUTPUTDIRECTORY = None
|
OUTPUTDIRECTORY = None
|
||||||
NOFLATTEN = []
|
NOFLATTEN = []
|
||||||
DELETE_ORIGINAL = None
|
DELETE_ORIGINAL = None
|
||||||
|
TORRENT_CHMOD_DIRECTORY = None
|
||||||
TORRENT_DEFAULTDIR = None
|
TORRENT_DEFAULTDIR = None
|
||||||
|
TORRENT_RESUME_ON_FAILURE = None
|
||||||
|
|
||||||
REMOTEPATHS = []
|
REMOTEPATHS = []
|
||||||
|
|
||||||
|
@ -210,9 +212,9 @@ def initialize(section=None):
|
||||||
ACODEC2, ACODEC2_ALLOW, ABITRATE2, ACODEC3, ACODEC3_ALLOW, ABITRATE3, ALLOWSUBS, SEXTRACT, SEMBED, SLANGUAGES, \
|
ACODEC2, ACODEC2_ALLOW, ABITRATE2, ACODEC3, ACODEC3_ALLOW, ABITRATE3, ALLOWSUBS, SEXTRACT, SEMBED, SLANGUAGES, \
|
||||||
SINCLUDE, SUBSDIR, SCODEC, OUTPUTFASTSTART, OUTPUTQUALITYPERCENT, BURN, GETSUBS, HWACCEL, LOG_DIR, LOG_FILE, \
|
SINCLUDE, SUBSDIR, SCODEC, OUTPUTFASTSTART, OUTPUTQUALITYPERCENT, BURN, GETSUBS, HWACCEL, LOG_DIR, LOG_FILE, \
|
||||||
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, TORRENT_CHMOD_DIRECTORY, PASSWORDSFILE, USER_DELAY, USER_SCRIPT, USER_SCRIPT_CLEAN, USER_SCRIPT_MEDIAEXTENSIONS, \
|
||||||
USER_SCRIPT_PARAM, USER_SCRIPT_RUNONCE, USER_SCRIPT_SUCCESSCODES, DOWNLOADINFO, CHECK_MEDIA, SAFE_MODE, \
|
USER_SCRIPT_PARAM, USER_SCRIPT_RUNONCE, USER_SCRIPT_SUCCESSCODES, DOWNLOADINFO, CHECK_MEDIA, SAFE_MODE, \
|
||||||
TORRENT_DEFAULTDIR, NZB_DEFAULTDIR, REMOTEPATHS, LOG_ENV, PID_FILE, MYAPP, ACHANNELS, ACHANNELS2, ACHANNELS3, \
|
TORRENT_DEFAULTDIR, TORRENT_RESUME_ON_FAILURE, NZB_DEFAULTDIR, REMOTEPATHS, LOG_ENV, PID_FILE, MYAPP, ACHANNELS, ACHANNELS2, ACHANNELS3, \
|
||||||
PLEXSSL, PLEXHOST, PLEXPORT, PLEXTOKEN, PLEXSEC
|
PLEXSSL, PLEXHOST, PLEXPORT, PLEXTOKEN, PLEXSEC
|
||||||
|
|
||||||
if __INITIALIZED__:
|
if __INITIALIZED__:
|
||||||
|
@ -339,6 +341,8 @@ def initialize(section=None):
|
||||||
if isinstance(NOFLATTEN, str): NOFLATTEN = NOFLATTEN.split(',')
|
if isinstance(NOFLATTEN, str): NOFLATTEN = NOFLATTEN.split(',')
|
||||||
if isinstance(CATEGORIES, str): CATEGORIES = CATEGORIES.split(',')
|
if isinstance(CATEGORIES, str): CATEGORIES = CATEGORIES.split(',')
|
||||||
DELETE_ORIGINAL = int(CFG["Torrent"]["deleteOriginal"])
|
DELETE_ORIGINAL = int(CFG["Torrent"]["deleteOriginal"])
|
||||||
|
TORRENT_CHMOD_DIRECTORY = int(CFG["Torrent"]["chmodDirecotry"], 8)
|
||||||
|
TORRENT_RESUME_ON_FAILURE = int(CFG["Torrent"]["resumeOnFailure"])
|
||||||
UTORRENTWEBUI = CFG["Torrent"]["uTorrentWEBui"] # http://localhost:8090/gui/
|
UTORRENTWEBUI = CFG["Torrent"]["uTorrentWEBui"] # http://localhost:8090/gui/
|
||||||
UTORRENTUSR = CFG["Torrent"]["uTorrentUSR"] # mysecretusr
|
UTORRENTUSR = CFG["Torrent"]["uTorrentUSR"] # mysecretusr
|
||||||
UTORRENTPWD = CFG["Torrent"]["uTorrentPWD"] # mysecretpwr
|
UTORRENTPWD = CFG["Torrent"]["uTorrentPWD"] # mysecretpwr
|
||||||
|
@ -740,3 +744,15 @@ def restart():
|
||||||
status = p.returncode
|
status = p.returncode
|
||||||
|
|
||||||
os._exit(status)
|
os._exit(status)
|
||||||
|
|
||||||
|
def rchmod(path, mod):
|
||||||
|
logger.log("Changing file mode of %s to %s" % (path, oct(mod)))
|
||||||
|
os.chmod(path, mod)
|
||||||
|
if not os.path.isdir(path):
|
||||||
|
return # Skip files
|
||||||
|
|
||||||
|
for root, dirs, files in os.walk(path):
|
||||||
|
for d in dirs:
|
||||||
|
os.chmod(os.path.join(root, d), mod)
|
||||||
|
for f in files:
|
||||||
|
os.chmod(os.path.join(root, f), mod)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue