From ecdc15c84b466e62287f8778415b66a2498c789c Mon Sep 17 00:00:00 2001 From: clinton-hall Date: Sat, 22 Aug 2015 07:51:18 +0930 Subject: [PATCH 01/13] allways add -strict -2 to aac codec. --- core/transcoder/transcoder.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/core/transcoder/transcoder.py b/core/transcoder/transcoder.py index 51d789cf..9ef83ad7 100644 --- a/core/transcoder/transcoder.py +++ b/core/transcoder/transcoder.py @@ -277,8 +277,6 @@ def buildCommands(file, newDir, movieName, bitbucket): audio_cmd.extend(['-c:a:' + str(used_audio), core.ACODEC]) else: audio_cmd.extend(['-c:a:' + str(used_audio), 'copy']) - if core.ACODEC == 'aac': - audio_cmd.extend(['-strict', '-2']) elif audio3: # just pick the default audio track map_cmd.extend(['-map', '0:' + str(audio3[0]["index"])]) a_mapped.extend([audio3[0]["index"]]) @@ -292,8 +290,6 @@ def buildCommands(file, newDir, movieName, bitbucket): audio_cmd.extend(['-c:a:' + str(used_audio), core.ACODEC]) else: audio_cmd.extend(['-c:a:' + str(used_audio), 'copy']) - if core.ACODEC == 'aac': - audio_cmd.extend(['-strict', '-2']) if core.ACHANNELS and channels and channels > core.ACHANNELS: audio_cmd.extend(['-ac:a:' + str(used_audio), str(core.ACHANNELS)]) @@ -307,6 +303,8 @@ def buildCommands(file, newDir, movieName, bitbucket): audio_cmd.extend(['-q:a:' + str(used_audio), str(core.OUTPUTQUALITYPERCENT)]) if audio_cmd[1] == 'copy': audio_cmd[1] = core.ACODEC + if audio_cmd[1] == 'aac': + audio_cmd[2:2] = ['-strict', '-2'] if core.ACODEC2_ALLOW: used_audio += 1 @@ -334,8 +332,6 @@ def buildCommands(file, newDir, movieName, bitbucket): audio_cmd2.extend(['-c:a:' + str(used_audio), core.ACODEC2]) else: audio_cmd2.extend(['-c:a:' + str(used_audio), 'copy']) - if core.ACODEC2 == 'aac': - audio_cmd2.extend(['-strict', '-2']) elif audio3: # just pick the default audio track map_cmd.extend(['-map', '0:' + str(audio3[0]["index"])]) a_mapped.extend([audio3[0]["index"]]) @@ -349,8 +345,6 @@ def buildCommands(file, newDir, movieName, bitbucket): audio_cmd2.extend(['-c:a:' + str(used_audio), core.ACODEC2]) else: audio_cmd2.extend(['-c:a:' + str(used_audio), 'copy']) - if core.ACODEC2 == 'aac': - audio_cmd2.extend(['-strict', '-2']) if core.ACHANNELS2 and channels and channels > core.ACHANNELS2: audio_cmd2.extend(['-ac:a:' + str(used_audio), str(core.ACHANNELS2)]) @@ -364,6 +358,8 @@ def buildCommands(file, newDir, movieName, bitbucket): audio_cmd2.extend(['-q:a:' + str(used_audio), str(core.OUTPUTQUALITYPERCENT)]) if audio_cmd2[1] == 'copy': audio_cmd2[1] = core.ACODEC2 + if audio_cmd2[1] == 'aac': + audio_cmd2[2:2] = ['-strict', '-2'] audio_cmd.extend(audio_cmd2) if core.AINCLUDE and audio3 and core.ACODEC3: @@ -386,8 +382,6 @@ def buildCommands(file, newDir, movieName, bitbucket): audio_cmd3.extend(['-c:a:' + str(used_audio), core.ACODEC3]) else: audio_cmd3.extend(['-c:a:' + str(used_audio), 'copy']) - if core.ACODEC3 == 'aac': - audio_cmd3.extend(['-strict', '-2']) if core.ACHANNELS3 and channels and channels > core.ACHANNELS3: audio_cmd3.extend(['-ac:a:' + str(used_audio), str(core.ACHANNELS3)]) @@ -401,6 +395,8 @@ def buildCommands(file, newDir, movieName, bitbucket): audio_cmd3.extend(['-q:a:' + str(used_audio), str(core.OUTPUTQUALITYPERCENT)]) if audio_cmd3[1] == 'copy': audio_cmd3[1] = core.ACODEC3 + if audio_cmd3[1] == 'aac': + audio_cmd3[2:2] = ['-strict', '-2'] audio_cmd.extend(audio_cmd3) s_mapped = [] From 016ef3e80ce4e885b81c838524f6f6a00eb41ec1 Mon Sep 17 00:00:00 2001 From: clinton-hall Date: Sun, 23 Aug 2015 08:02:54 +0930 Subject: [PATCH 02/13] fix typos. Fixes #813 --- autoProcessMedia.cfg.spec | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/autoProcessMedia.cfg.spec b/autoProcessMedia.cfg.spec index 1d493f15..26c35a8f 100644 --- a/autoProcessMedia.cfg.spec +++ b/autoProcessMedia.cfg.spec @@ -57,7 +57,7 @@ extract = 1 # Set this to minimum required size to consider a media file valid (in MB) minSize = 0 - # Enable/Disable deleteing ignored files (samples and invalid media files) + # Enable/Disable deleting ignored files (samples and invalid media files) delete_ignored = 0 ##### Enable if Couchpotato is on a remote server for this category remote_path = 0 @@ -87,7 +87,7 @@ nzbExtractionBy = Downloader # Set this to minimum required size to consider a media file valid (in MB) minSize = 0 - # Enable/Disable deleteing ignored files (samples and invalid media files) + # Enable/Disable deleting ignored files (samples and invalid media files) delete_ignored = 0 ##### Enable if SickBeard is on a remote server for this category remote_path = 0 @@ -115,7 +115,7 @@ wait_for = 2 # Set this to minimum required size to consider a media file valid (in MB) minSize = 0 - # Enable/Disable deleteing ignored files (samples and invalid media files) + # Enable/Disable deleting ignored files (samples and invalid media files) delete_ignored = 0 ##### Enable if NzbDrone is on a remote server for this category remote_path = 0 @@ -139,7 +139,7 @@ extract = 1 # Set this to minimum required size to consider a media file valid (in MB) minSize = 0 - # Enable/Disable deleteing ignored files (samples and invalid media files) + # Enable/Disable deleting ignored files (samples and invalid media files) delete_ignored = 0 ##### Enable if HeadPhones is on a remote server for this category remote_path = 0 @@ -163,7 +163,7 @@ extract = 1 # Set this to minimum required size to consider a media file valid (in MB) minSize = 0 - # Enable/Disable deleteing ignored files (samples and invalid media files) + # Enable/Disable deleting ignored files (samples and invalid media files) delete_ignored = 0 ##### Enable if Mylar is on a remote server for this category remote_path = 0 @@ -188,7 +188,7 @@ extract = 1 # Set this to minimum required size to consider a media file valid (in MB) minSize = 0 - # Enable/Disable deleteing ignored files (samples and invalid media files) + # Enable/Disable deleting ignored files (samples and invalid media files) delete_ignored = 0 ##### Enable if Gamez is on a remote server for this category remote_path = 0 @@ -262,10 +262,11 @@ subLanguages = eng,spa,fra # transcode. enable to use transcoder transcode = 0 - ###### duplicate =1 will cretae a new file. =0 will replace the original + ###### duplicate =1 will create a new file. =0 will replace the original duplicate = 1 # concat. joins cd1 cd2 etc into a single video. concat = 1 + # IgnoreExtensions is a comma-separated list of extensions that will not be transcoded. ignoreExtensions = .avi,.mkv,.mp4 # outputFastStart. 1 will use -movflags + faststart. 0 will disable this from being used. outputFastStart = 0 @@ -279,9 +280,9 @@ audioLanguage = eng # allAudioLanguages. 1 will keep all audio tracks (uses AudioCodec3) where available. allAudioLanguages = 0 - # allSubLanguages. 1 will keep all exisiting sub languages. 0 will discare those not in your list above. + # allSubLanguages. 1 will keep all existing sub languages. 0 will discard those not in your list above. allSubLanguages = 0 - # embedSubs. 1 will embded external sub/srt subs into your video if this is supported. + # embedSubs. 1 will embed external sub/srt subs into your video if this is supported. embedSubs = 1 # burnInSubtitle. burns the default sub language into your video (needed for players that don't support subs) burnInSubtitle = 0 @@ -347,7 +348,7 @@ #for example FP,FN,DN, TN, TL for file path (absolute file name with path), file name, absolute directory name (with path), Torrent Name, Torrent Label/Category. #So the result is /media/test/script/script.sh FP FN DN TN TL. Add other arguments as needed eg -f, -r user_script_param = FN - #Set user_script_runOnce = 0 to run for each file, or 1 to only run once (presumably on teh entire directory). + #Set user_script_runOnce = 0 to run for each file, or 1 to only run once (presumably on the entire directory). user_script_runOnce = 0 #Specify the successcodes returned by the user script as a comma separated list. Linux default is 0 user_script_successCodes = 0 @@ -371,5 +372,5 @@ [Custom] # enter a list (comma separated) of Group Tags you want removed from filenames to help with subtitle matching. # e.g remove_group = [rarbag],-NZBgeek - # be careful if your "group" is a common "real" word. Please report if you have any group replacments that would fall in this category. + # be careful if your "group" is a common "real" word. Please report if you have any group replacements that would fall in this category. remove_group = From 22bb2b64b12bc917cb7116ee795d78500e7d67e4 Mon Sep 17 00:00:00 2001 From: clinton-hall Date: Sun, 23 Aug 2015 08:17:09 +0930 Subject: [PATCH 03/13] add "delete_on" parameter for SickRage. Fixes #814 --- autoProcessMedia.cfg.spec | 2 ++ core/__init__.py | 4 ++-- core/autoProcess/autoProcessTV.py | 10 ++++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/autoProcessMedia.cfg.spec b/autoProcessMedia.cfg.spec index 26c35a8f..e846c16a 100644 --- a/autoProcessMedia.cfg.spec +++ b/autoProcessMedia.cfg.spec @@ -83,6 +83,8 @@ process_method = # force processing of already processed content when running a manual scan. force = 0 + # tell SickRage to delete all source files after processing. + delete_on = 0 extract = 1 nzbExtractionBy = Downloader # Set this to minimum required size to consider a media file valid (in MB) diff --git a/core/__init__.py b/core/__init__.py index 7024e7a4..a38eb313 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -56,8 +56,8 @@ FORK_SICKRAGE = "sickrage" FORKS[FORK_DEFAULT] = {"dir": None} FORKS[FORK_FAILED] = {"dirName": None, "failed": None} FORKS[FORK_FAILED_TORRENT] = {"dir": None, "failed": None, "process_method": None} -FORKS[FORK_SICKRAGE] = {"dir": None, "failed": None, "process_method": None, "force": None} -ALL_FORKS = {"dir": None, "dirName": None, "failed": None, "process_method": None, "force": None} +FORKS[FORK_SICKRAGE] = {"dir": None, "failed": None, "process_method": None, "force": None, "delete_on": None} +ALL_FORKS = {"dir": None, "dirName": None, "failed": None, "process_method": None, "force": None, "delete_on": None} SICKBEARD_FAILED = [FORK_FAILED, FORK_FAILED_TORRENT, FORK_SICKRAGE] SICKBEARD_TORRENT = [FORK_FAILED_TORRENT, FORK_SICKRAGE] diff --git a/core/autoProcess/autoProcessTV.py b/core/autoProcess/autoProcessTV.py index b202177e..da4e6972 100644 --- a/core/autoProcess/autoProcessTV.py +++ b/core/autoProcess/autoProcessTV.py @@ -104,6 +104,10 @@ class autoProcessTV: force = int(core.CFG[section][inputCategory]["force"]) except: force = 0 + try: + delete_on = int(core.CFG[section][inputCategory]["delete_on"]) + except: + delete_on = 0 try: extract = int(section[inputCategory]["extract"]) except: @@ -211,6 +215,12 @@ class autoProcessTV: else: del fork_params[param] + if param == "delete_on": + if delete_on: + fork_params[param] = delete_on + else: + del fork_params[param] + # delete any unused params so we don't pass them to SB by mistake [fork_params.pop(k) for k,v in fork_params.items() if v is None] From 6ab821c5ea65fe39cdba3f9dd492afa99f1b71ec Mon Sep 17 00:00:00 2001 From: clinton-hall Date: Mon, 14 Sep 2015 19:43:14 +0930 Subject: [PATCH 04/13] add https for SABnzbd. Fixes #823 --- autoProcessMedia.cfg.spec | 2 +- core/nzbToMediaUtil.py | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/autoProcessMedia.cfg.spec b/autoProcessMedia.cfg.spec index e846c16a..ee5baf3f 100644 --- a/autoProcessMedia.cfg.spec +++ b/autoProcessMedia.cfg.spec @@ -206,7 +206,7 @@ ###### clientAgent - Supported clients: sabnzbd, nzbget clientAgent = sabnzbd ###### SabNZBD (You must edit this if your using nzbToMedia.py with SabNZBD) - sabnzbd_host = localhost + sabnzbd_host = http://localhost sabnzbd_port = 8080 sabnzbd_apikey = ###### Enter the default path to your default download directory (non-category downloads). this directory is protected by safe_mode. diff --git a/core/nzbToMediaUtil.py b/core/nzbToMediaUtil.py index f6491274..19602728 100644 --- a/core/nzbToMediaUtil.py +++ b/core/nzbToMediaUtil.py @@ -798,7 +798,10 @@ def find_download(clientAgent, download_id): if clientAgent == 'deluge': return False if clientAgent == 'sabnzbd': - baseURL = "http://%s:%s/api" % (core.SABNZBDHOST, core.SABNZBDPORT) + if "http" in core.SABNZBDHOST: + baseURL = "%s:%s/api" % (core.SABNZBDHOST, core.SABNZBDPORT) + else: + baseURL = "http://%s:%s/api" % (core.SABNZBDHOST, core.SABNZBDPORT) url = baseURL params = {} params['apikey'] = core.SABNZBDAPIKEY @@ -819,7 +822,10 @@ def find_download(clientAgent, download_id): def get_nzoid(inputName): nzoid = None logger.debug("Searching for nzoid from SAbnzbd ...") - baseURL = "http://%s:%s/api" % (core.SABNZBDHOST, core.SABNZBDPORT) + if "http" in core.SABNZBDHOST: + baseURL = "%s:%s/api" % (core.SABNZBDHOST, core.SABNZBDPORT) + else: + baseURL = "http://%s:%s/api" % (core.SABNZBDHOST, core.SABNZBDPORT) url = baseURL params = {} params['apikey'] = core.SABNZBDAPIKEY From 76115ce7359d2a2772c37cd8a2cff7ccf79c8b6e Mon Sep 17 00:00:00 2001 From: clinton-hall Date: Mon, 14 Sep 2015 19:48:48 +0930 Subject: [PATCH 05/13] fix typo. Fixes #822 --- core/nzbToMediaUtil.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/nzbToMediaUtil.py b/core/nzbToMediaUtil.py index 19602728..c5f3b050 100644 --- a/core/nzbToMediaUtil.py +++ b/core/nzbToMediaUtil.py @@ -1063,7 +1063,7 @@ def server_responding(baseURL): def plex_update(category): if core.PLEXSSL: - ulr = 'https://' + url = 'https://' else: url = 'http://' url = url + core.PLEXHOST + ':' + core.PLEXPORT + '/library/sections/' From ab4d02a24006ac0979f0801f43541c5eae4c049f Mon Sep 17 00:00:00 2001 From: Hagai Cohen Date: Thu, 24 Sep 2015 17:29:56 +0300 Subject: [PATCH 06/13] Added the ability to chmod Torrent diretory before processing --- TorrentToMedia.py | 3 +++ autoProcessMedia.cfg.spec | 1 + core/__init__.py | 16 +++++++++++++++- 3 files changed, 19 insertions(+), 1 deletion(-) 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) From 0d1e27c09384d717fe8671e43d4fdab4b50a2c95 Mon Sep 17 00:00:00 2001 From: Hagai Cohen Date: Thu, 24 Sep 2015 18:17:01 +0300 Subject: [PATCH 07/13] Add the ability to not resume torrent on failure --- TorrentToMedia.py | 4 +++- autoProcessMedia.cfg.spec | 1 + core/__init__.py | 4 +++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/TorrentToMedia.py b/TorrentToMedia.py index 3cb18daf..6fd691c0 100755 --- a/TorrentToMedia.py +++ b/TorrentToMedia.py @@ -223,7 +223,9 @@ def processTorrent(inputDirectory, inputName, inputCategory, inputHash, inputID, plex_update(inputCategory) if result[0] != 0: - if clientAgent != 'manual': + if 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( "A problem was reported in the autoProcess* script. If torrent was paused we will resume seeding") core.resume_torrent(clientAgent, inputHash, inputID, inputName) diff --git a/autoProcessMedia.cfg.spec b/autoProcessMedia.cfg.spec index 46e6a2ea..a9d848db 100644 --- a/autoProcessMedia.cfg.spec +++ b/autoProcessMedia.cfg.spec @@ -240,6 +240,7 @@ ###### ADVANCED USE - ONLY EDIT IF YOU KNOW WHAT YOU'RE DOING ###### deleteOriginal = 0 chmodDirecotry = 0 + resumeOnFailure = 1 [Extensions] compressedExtensions = .zip,.rar,.7z,.gz,.bz,.tar,.arj,.1,.01,.001 diff --git a/core/__init__.py b/core/__init__.py index 6a64adf4..3c4a3244 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -100,6 +100,7 @@ NOFLATTEN = [] DELETE_ORIGINAL = None TORRENT_CHMOD_DIRECTORY = None TORRENT_DEFAULTDIR = None +TORRENT_RESUME_ON_FAILURE = None REMOTEPATHS = [] @@ -213,7 +214,7 @@ def initialize(section=None): NICENESS, LOG_DEBUG, FORCE_CLEAN, FFMPEG_PATH, FFMPEG, FFPROBE, AUDIOCONTAINER, EXTCONTAINER, TORRENT_CLASS, \ 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, \ + TORRENT_DEFAULTDIR, TORRENT_RESUME_ON_FAILURE, NZB_DEFAULTDIR, REMOTEPATHS, LOG_ENV, PID_FILE, MYAPP, ACHANNELS, ACHANNELS2, ACHANNELS3, \ PLEXSSL, PLEXHOST, PLEXPORT, PLEXTOKEN, PLEXSEC if __INITIALIZED__: @@ -341,6 +342,7 @@ def initialize(section=None): if isinstance(CATEGORIES, str): CATEGORIES = CATEGORIES.split(',') 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/ UTORRENTUSR = CFG["Torrent"]["uTorrentUSR"] # mysecretusr UTORRENTPWD = CFG["Torrent"]["uTorrentPWD"] # mysecretpwr From 96dfe7d765a1f87e7d90523ee4647c1fb73a7d4f Mon Sep 17 00:00:00 2001 From: Hagai Cohen Date: Thu, 24 Sep 2015 21:21:49 +0300 Subject: [PATCH 08/13] Fixed torrent file handling torrents sometimes comes as single file, however, processors (Sickbeard for example) are expecting isolated folder. This patch will make sure that if processed item is not a directory, then it will create a directory (similar to file name) and move the media there. --- TorrentToMedia.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/TorrentToMedia.py b/TorrentToMedia.py index 6fd691c0..8ebdb15b 100755 --- a/TorrentToMedia.py +++ b/TorrentToMedia.py @@ -97,7 +97,12 @@ def processTorrent(inputDirectory, inputName, inputCategory, inputHash, inputID, if clientAgent != 'manual': 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( core.os.path.join(core.OUTPUTDIRECTORY, inputCategory, core.sanitizeName(inputName))) else: From d54d5a35b71bd58c084307d0124d17d4f94db45d Mon Sep 17 00:00:00 2001 From: Hagai Cohen Date: Sat, 26 Sep 2015 11:12:46 +0300 Subject: [PATCH 09/13] Fixed a small bug (missing not) --- TorrentToMedia.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TorrentToMedia.py b/TorrentToMedia.py index 8ebdb15b..70ebd5ba 100755 --- a/TorrentToMedia.py +++ b/TorrentToMedia.py @@ -228,7 +228,7 @@ def processTorrent(inputDirectory, inputName, inputCategory, inputHash, inputID, plex_update(inputCategory) if result[0] != 0: - if core.TORRENT_RESUME_ON_FAILURE: + 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( From d94d9f50de618dd76c5d8f2135dae260aea1721c Mon Sep 17 00:00:00 2001 From: clinton-hall Date: Tue, 29 Sep 2015 22:03:10 +0930 Subject: [PATCH 10/13] add processed name to final SABnzbd print out. Fixes #836 --- core/autoProcess/autoProcessTV.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/autoProcess/autoProcessTV.py b/core/autoProcess/autoProcessTV.py index da4e6972..93dc87c7 100644 --- a/core/autoProcess/autoProcessTV.py +++ b/core/autoProcess/autoProcessTV.py @@ -286,6 +286,8 @@ class autoProcessTV: for line in r.iter_lines(): if line: logger.postprocess("%s" % (line), section) + if "Moving file from" in line: + inputName = os.path.split(line)[1] if "Processing succeeded" in line or "Successfully processed" in line: Success = True elif section == "NzbDrone": From e9a347346a7ae1303a4ed45e3d751121fc113802 Mon Sep 17 00:00:00 2001 From: gibxxi Date: Tue, 29 Sep 2015 14:12:28 +0100 Subject: [PATCH 11/13] SSL Warnings workaround - autoProcessComics.py Add code to disable warnings in NZBGet about 'unverified SSL Requests' being made between apps. --- core/autoProcess/autoProcessComics.py | 3 +++ core/autoProcess/autoProcessGames.py | 3 +++ core/autoProcess/autoProcessMovie.py | 1 + core/autoProcess/autoProcessMusic.py | 2 ++ core/autoProcess/autoProcessTV.py | 2 ++ 5 files changed, 11 insertions(+) diff --git a/core/autoProcess/autoProcessComics.py b/core/autoProcess/autoProcessComics.py index 6394d187..89060b62 100644 --- a/core/autoProcess/autoProcessComics.py +++ b/core/autoProcess/autoProcessComics.py @@ -3,10 +3,13 @@ import time import core import requests import time + from core.nzbToMediaUtil import convert_to_ascii, remoteDir, server_responding from core.nzbToMediaSceneExceptions import process_all_exceptions from core import logger +requests.packages.urllib3.disable_warnings() + class autoProcessComics: def processEpisode(self, section, dirName, inputName=None, status=0, clientAgent='manual', inputCategory=None): if int(status) != 0: diff --git a/core/autoProcess/autoProcessGames.py b/core/autoProcess/autoProcessGames.py index fcf2134a..7fa14227 100644 --- a/core/autoProcess/autoProcessGames.py +++ b/core/autoProcess/autoProcessGames.py @@ -1,10 +1,13 @@ import core import requests import shutil + from core.nzbToMediaUtil import convert_to_ascii, server_responding from core.nzbToMediaSceneExceptions import process_all_exceptions from core import logger +requests.packages.urllib3.disable_warnings() + class autoProcessGames: def process(self, section, dirName, inputName=None, status=0, clientAgent='manual', inputCategory=None): status = int(status) diff --git a/core/autoProcess/autoProcessMovie.py b/core/autoProcess/autoProcessMovie.py index 2fde1523..e3b54873 100644 --- a/core/autoProcess/autoProcessMovie.py +++ b/core/autoProcess/autoProcessMovie.py @@ -8,6 +8,7 @@ from core.nzbToMediaUtil import convert_to_ascii, rmDir, find_imdbid, find_downl from core import logger from core.transcoder import transcoder +requests.packages.urllib3.disable_warnings() class autoProcessMovie: def get_release(self, baseURL, imdbid=None, download_id=None, release_id=None): diff --git a/core/autoProcess/autoProcessMusic.py b/core/autoProcess/autoProcessMusic.py index 67a390ae..98fc390f 100644 --- a/core/autoProcess/autoProcessMusic.py +++ b/core/autoProcess/autoProcessMusic.py @@ -7,6 +7,8 @@ from core.nzbToMediaUtil import convert_to_ascii, remoteDir, listMediaFiles, ser from core.nzbToMediaSceneExceptions import process_all_exceptions from core import logger +requests.packages.urllib3.disable_warnings() + class autoProcessMusic: def get_status(self, url, apikey, dirName): logger.debug("Attempting to get current status for release:%s" % (os.path.basename(dirName))) diff --git a/core/autoProcess/autoProcessTV.py b/core/autoProcess/autoProcessTV.py index da4e6972..e2575c2f 100644 --- a/core/autoProcess/autoProcessTV.py +++ b/core/autoProcess/autoProcessTV.py @@ -12,6 +12,8 @@ from core.nzbToMediaUtil import convert_to_ascii, flatten, rmDir, listMediaFiles from core import logger from core.transcoder import transcoder +requests.packages.urllib3.disable_warnings() + class autoProcessTV: def command_complete(self, url, params, headers, section): r = None From 6d63c3ab3066d2683cba9a24033963b9d71f97a0 Mon Sep 17 00:00:00 2001 From: clinton-hall Date: Wed, 30 Sep 2015 20:33:45 +0930 Subject: [PATCH 12/13] add .ts to mediaExtensions. Fixes #843 --- autoProcessMedia.cfg.spec | 2 +- nzbToCouchPotato.py | 2 +- nzbToMedia.py | 2 +- nzbToNzbDrone.py | 2 +- nzbToSickBeard.py | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/autoProcessMedia.cfg.spec b/autoProcessMedia.cfg.spec index 4f1cac4d..2fd39584 100644 --- a/autoProcessMedia.cfg.spec +++ b/autoProcessMedia.cfg.spec @@ -246,7 +246,7 @@ [Extensions] compressedExtensions = .zip,.rar,.7z,.gz,.bz,.tar,.arj,.1,.01,.001 - mediaExtensions = .mkv,.avi,.divx,.xvid,.mov,.wmv,.mp4,.mpg,.mpeg,.vob,.iso,.m4v + mediaExtensions = .mkv,.avi,.divx,.xvid,.mov,.wmv,.mp4,.mpg,.mpeg,.vob,.iso,.m4v,.ts audioExtensions = .mp3, .aac, .ogg, .ape, .m4a, .asf, .wma, .flac metaExtensions = .nfo,.sub,.srt,.jpg,.gif diff --git a/nzbToCouchPotato.py b/nzbToCouchPotato.py index f75342b1..c9957d4c 100755 --- a/nzbToCouchPotato.py +++ b/nzbToCouchPotato.py @@ -95,7 +95,7 @@ # Media Extensions # # This is a list of media extensions that are used to verify that the download does contain valid media. -#mediaExtensions=.mkv,.avi,.divx,.xvid,.mov,.wmv,.mp4,.mpg,.mpeg,.vob,.iso +#mediaExtensions=.mkv,.avi,.divx,.xvid,.mov,.wmv,.mp4,.mpg,.mpeg,.vob,.iso,.ts ## Posix diff --git a/nzbToMedia.py b/nzbToMedia.py index 16a04a73..f74de560 100755 --- a/nzbToMedia.py +++ b/nzbToMedia.py @@ -301,7 +301,7 @@ # Media Extensions # # This is a list of media extensions that are used to verify that the download does contain valid media. -#mediaExtensions=.mkv,.avi,.divx,.xvid,.mov,.wmv,.mp4,.mpg,.mpeg,.vob,.iso +#mediaExtensions=.mkv,.avi,.divx,.xvid,.mov,.wmv,.mp4,.mpg,.mpeg,.vob,.iso,.ts ## Posix diff --git a/nzbToNzbDrone.py b/nzbToNzbDrone.py index caa2703d..8d4f3a49 100755 --- a/nzbToNzbDrone.py +++ b/nzbToNzbDrone.py @@ -85,7 +85,7 @@ # Media Extensions # # This is a list of media extensions that are used to verify that the download does contain valid media. -#mediaExtensions=.mkv,.avi,.divx,.xvid,.mov,.wmv,.mp4,.mpg,.mpeg,.vob,.iso +#mediaExtensions=.mkv,.avi,.divx,.xvid,.mov,.wmv,.mp4,.mpg,.mpeg,.vob,.iso,.ts ## Posix diff --git a/nzbToSickBeard.py b/nzbToSickBeard.py index ec3168ae..69ff5397 100755 --- a/nzbToSickBeard.py +++ b/nzbToSickBeard.py @@ -98,7 +98,7 @@ # Media Extensions # # This is a list of media extensions that are used to verify that the download does contain valid media. -#mediaExtensions=.mkv,.avi,.divx,.xvid,.mov,.wmv,.mp4,.mpg,.mpeg,.vob,.iso +#mediaExtensions=.mkv,.avi,.divx,.xvid,.mov,.wmv,.mp4,.mpg,.mpeg,.vob,.iso,.ts ## Posix From d7919e6c9389c0c6d69358d754e548b810e7c9e3 Mon Sep 17 00:00:00 2001 From: hugepants Date: Sat, 3 Oct 2015 15:19:28 +0100 Subject: [PATCH 13/13] Update README.md --- README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index dc321cd3..6cd3a259 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ nzbToMedia ================ -Provides an efficient way to handle postprocessing for [CouchPotatoServer](https://couchpota.to/ "CouchPotatoServer") and [SickBeard](http://sickbeard.com/ "SickBeard") +Provides an [efficient](https://github.com/clinton-hall/nzbToMedia/wiki/Efficient-on-demand-post-processing) way to handle postprocessing for [CouchPotatoServer](https://couchpota.to/ "CouchPotatoServer") and [SickBeard](http://sickbeard.com/ "SickBeard") (and its [forks](https://github.com/clinton-hall/nzbToMedia/wiki/Failed-Download-Handling-%28FDH%29#sick-beard-and-its-forks)) when using one of the popular NZB download clients like [SABnzbd](http://sabnzbd.org/ "SABnzbd") and [NZBGet](http://nzbget.sourceforge.net/ "NZBGet") on low performance systems like a NAS. This script is based on sabToSickBeard (written by Nic Wolfe and supplied with SickBeard), with the support for NZBGet being added by [thorli](https://github.com/thorli "thorli") and further contributions by [schumi2004](https://github.com/schumi2004 "schumi2004") and [hugbug](https://sourceforge.net/apps/phpbb/nzbget/memberlist.php?mode=viewprofile&u=67 "hugbug"). Torrent suport added by [jkaberg](https://github.com/jkaberg "jkaberg") and [berkona](https://github.com/berkona "berkona") @@ -9,17 +9,17 @@ Corrupt video checking, auto SickBeard fork determination and a whole lot of cod Introduction ------------ -Originally this was modified from the SickBeard version to allow for "on-demand" renaming and not have My QNAP TS-412 NAS constantly scanning the download directory. -Later, a few failed downloads prompted me to incorporate "failed download" handling. +Originally this was modified from the SickBeard version to allow for ["on-demand" renaming](https://github.com/clinton-hall/nzbToMedia/wiki/Efficient-on-demand-post-processing) and not have My QNAP TS-412 NAS constantly scanning the download directory. +Later, a few failed downloads prompted me to incorporate ["failed download" handling](https://github.com/clinton-hall/nzbToMedia/wiki/Failed-Download-Handling-%28FDH%29). Failed download handling is now provided for SABnzbd, by CouchPotatoServer; however on arm processors (e.g. small NAS systems) this can be un-reliable. -Failed download handling for SickBeard is available by using the development branch from fork [SickBeard-failed](https://github.com/Tolstyak/Sick-Beard.git "SickBeard-failed") -To use this feature, in autoProcessTV.cfg set the parameter "fork=failed". Default is "fork=default" and will work with standard version of SickBeard and just ignores failed downloads. -Additional forks exist for ThePirateBay (does its own extraction and linking). See [SickBeard Forks](https://github.com/clinton-hall/nzbToMedia/wiki/sickbeard-branches "SickBeard Forks") for a list of known forks. +Failed download handling for SickBeard is available by using Tolstyak's fork [SickBeard-failed](https://github.com/hugepants/Sick-Beard)). +To use this feature, in autoProcessTV.cfg set the parameter "fork=failed". Default is "fork=default" and will work with the standard version of SickBeard and just ignores failed downloads. +Development of Tolstyak's fork ended in 2013, but newer forks exist with significant feature updates such as [Mr-Orange TPB](https://github.com/coach0742/Sick-Beard) (discontinued) and [SickRage](https://github.com/SiCKRAGETV/SickRage) (active). See [SickBeard Forks](https://github.com/clinton-hall/nzbToMedia/wiki/Failed-Download-Handling-%28FDH%29#sick-beard-and-its-forks "SickBeard Forks") for a list of known forks. -Full support is provided for [SickRage](https://github.com/echel0n/SickRage "SickRage"). +Full support is provided for [SickRage](https://github.com/SiCKRAGETV/SickRage). -Torrent support has been added with the assistance of jkaberg and berkona. Currently supports uTorrent, Transmissions, Deluge and possibly more. +Torrent support has been added with the assistance of jkaberg and berkona. Currently supports uTorrent, Transmission, Deluge and possibly more. To enable Torrent extraction, on Windows, you need to install [7-zip](http://www.7-zip.org/ "7-zip") or on *nix you need to install the following packages/commands. "unrar", "unzip", "tar", "7zr"