diff --git a/TorrentToMedia.py b/TorrentToMedia.py index 730ad364..3cb18daf 100755 --- a/TorrentToMedia.py +++ b/TorrentToMedia.py @@ -197,6 +197,9 @@ def processTorrent(inputDirectory, inputName, inputCategory, inputHash, inputID, 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, "" ] if sectionName == 'UserScript': result = external_script(outputDestination, inputName, inputCategory, section[usercat]) diff --git a/autoProcessMedia.cfg.spec b/autoProcessMedia.cfg.spec index 1d493f15..46e6a2ea 100644 --- a/autoProcessMedia.cfg.spec +++ b/autoProcessMedia.cfg.spec @@ -239,6 +239,7 @@ DelugePWD = your password ###### ADVANCED USE - ONLY EDIT IF YOU KNOW WHAT YOU'RE DOING ###### deleteOriginal = 0 + chmodDirecotry = 0 [Extensions] compressedExtensions = .zip,.rar,.7z,.gz,.bz,.tar,.arj,.1,.01,.001 diff --git a/core/__init__.py b/core/__init__.py index 7024e7a4..6a64adf4 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -98,6 +98,7 @@ USELINK = None OUTPUTDIRECTORY = None NOFLATTEN = [] DELETE_ORIGINAL = None +TORRENT_CHMOD_DIRECTORY = None TORRENT_DEFAULTDIR = None REMOTEPATHS = [] @@ -210,7 +211,7 @@ def initialize(section=None): ACODEC2, ACODEC2_ALLOW, ABITRATE2, ACODEC3, ACODEC3_ALLOW, ABITRATE3, ALLOWSUBS, SEXTRACT, SEMBED, SLANGUAGES, \ 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, \ - 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, \ TORRENT_DEFAULTDIR, NZB_DEFAULTDIR, REMOTEPATHS, LOG_ENV, PID_FILE, MYAPP, ACHANNELS, ACHANNELS2, ACHANNELS3, \ PLEXSSL, PLEXHOST, PLEXPORT, PLEXTOKEN, PLEXSEC @@ -339,6 +340,7 @@ def initialize(section=None): if isinstance(NOFLATTEN, str): NOFLATTEN = NOFLATTEN.split(',') if isinstance(CATEGORIES, str): CATEGORIES = CATEGORIES.split(',') DELETE_ORIGINAL = int(CFG["Torrent"]["deleteOriginal"]) + TORRENT_CHMOD_DIRECTORY = int(CFG["Torrent"]["chmodDirecotry"], 8) UTORRENTWEBUI = CFG["Torrent"]["uTorrentWEBui"] # http://localhost:8090/gui/ UTORRENTUSR = CFG["Torrent"]["uTorrentUSR"] # mysecretusr UTORRENTPWD = CFG["Torrent"]["uTorrentPWD"] # mysecretpwr @@ -740,3 +742,15 @@ def restart(): status = p.returncode 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)