From 37a8b5aca161e07f139ab37bd23744dd1dc1b764 Mon Sep 17 00:00:00 2001 From: clinton-hall Date: Sat, 3 May 2014 20:04:15 +0930 Subject: [PATCH 1/2] added NZBDrone fork test and FFProbe path check. fixes #367 --- nzbtomedia/__init__.py | 18 ++++++++++++------ nzbtomedia/autoProcess/autoProcessTV.py | 2 +- nzbtomedia/nzbToMediaAutoFork.py | 22 +++++++++++++++++++++- 3 files changed, 34 insertions(+), 8 deletions(-) diff --git a/nzbtomedia/__init__.py b/nzbtomedia/__init__.py index e89c6b85..4eb551c3 100644 --- a/nzbtomedia/__init__.py +++ b/nzbtomedia/__init__.py @@ -324,14 +324,20 @@ def initialize(section=None): FFPROBE = subprocess.Popen(['which', 'ffprobe'], stdout=subprocess.PIPE).communicate()[0].strip() if not FFMPEG: - FFMPEG = None - logger.warning("Failed to locate ffmpeg, transcoding disabled!") - logger.warning("Install ffmpeg with x264 support to enable this feature ...") + if os.access(os.path.join(FFMPEG_PATH, 'ffmpeg'), os.X_OK): + FFMPEG = os.path.join(FFMPEG_PATH, 'ffmpeg') + else: + FFMPEG = None + logger.warning("Failed to locate ffmpeg, transcoding disabled!") + logger.warning("Install ffmpeg with x264 support to enable this feature ...") if not FFPROBE: - FFPROBE = None - logger.warning("Failed to locate ffprobe, video corruption detection disabled!") - logger.warning("Install ffmpeg with x264 support to enable this feature ...") + if os.access(os.path.join(FFMPEG_PATH, 'ffprobe'), os.X_OK): + FFPROBE = os.path.join(FFMPEG_PATH, 'ffprobe') + else: + FFPROBE = None + logger.warning("Failed to locate ffprobe, video corruption detection disabled!") + logger.warning("Install ffmpeg with x264 support to enable this feature ...") # userscript map(USER_SCRIPT_CATEGORIES.append, ([subsections[0] for subsections in CFG['UserScript'].items()])) diff --git a/nzbtomedia/autoProcess/autoProcessTV.py b/nzbtomedia/autoProcess/autoProcessTV.py index eaec6dd2..8ab64a41 100644 --- a/nzbtomedia/autoProcess/autoProcessTV.py +++ b/nzbtomedia/autoProcess/autoProcessTV.py @@ -107,7 +107,7 @@ class autoProcessTV: if status == 0: logger.postprocess("SUCCESS: The download succeeded, sending a post-process request", section) else: - if fork in nzbtomedia.SICKBEARD_FAILED: + if fork in nzbtomedia.SICKBEARD_FAILED or section == "NzbDrone": logger.postprocess("FAILED: The download failed. Sending 'failed' process request to %s branch" % (fork), section) else: logger.postprocess("FAILED: The download failed. %s branch does not handle failed downloads. Nothing to process" % (fork), section) diff --git a/nzbtomedia/nzbToMediaAutoFork.py b/nzbtomedia/nzbToMediaAutoFork.py index 9b9fea94..e57b0fe5 100644 --- a/nzbtomedia/nzbToMediaAutoFork.py +++ b/nzbtomedia/nzbToMediaAutoFork.py @@ -20,6 +20,11 @@ def autoFork(section, inputCategory): username = None password = None + try: + apikey = nzbtomedia.CFG[section][inputCategory]["apikey"] + except: + apikey = None + try: ssl = int(nzbtomedia.CFG[section][inputCategory]["ssl"]) except: @@ -41,7 +46,22 @@ def autoFork(section, inputCategory): protocol = "http://" detected = False - if fork == "auto": + if section == "NzbDrone": + logger.info("Attempting to verify %s fork" % inputCategory) + url = "%s%s:%s%s/api/rootfolder" % (protocol,host,port,web_root) + headers={"X-Api-Key": apikey} + try: + r = requests.get(url, headers=headers, stream=True, verify=False) + except requests.ConnectionError: + logger.info("Could not connect to %s:%s to verify fork!" % (section, inputCategory)) + break + + if r.ok: + fork = ['default', {}] + else: + logger.info("Connection to %s:%s failed! Check your configuration" % (section, inputCategory)) + + elif fork == "auto": logger.info("Attempting to auto-detect %s fork" % inputCategory) for fork in sorted(nzbtomedia.FORKS.iteritems(), reverse=False): url = "%s%s:%s%s/home/postprocess/processEpisode?%s" % (protocol,host,port,web_root,urllib.urlencode(fork[1])) From 7f96df5e60322012c14e1e8d61b41d55e4760acf Mon Sep 17 00:00:00 2001 From: clinton-hall Date: Sat, 3 May 2014 20:09:21 +0930 Subject: [PATCH 2/2] fix fork check #367 --- nzbtomedia/nzbToMediaAutoFork.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/nzbtomedia/nzbToMediaAutoFork.py b/nzbtomedia/nzbToMediaAutoFork.py index e57b0fe5..fed68889 100644 --- a/nzbtomedia/nzbToMediaAutoFork.py +++ b/nzbtomedia/nzbToMediaAutoFork.py @@ -53,13 +53,12 @@ def autoFork(section, inputCategory): try: r = requests.get(url, headers=headers, stream=True, verify=False) except requests.ConnectionError: - logger.info("Could not connect to %s:%s to verify fork!" % (section, inputCategory)) - break + logger.warning("Could not connect to %s:%s to verify fork!" % (section, inputCategory)) - if r.ok: - fork = ['default', {}] - else: - logger.info("Connection to %s:%s failed! Check your configuration" % (section, inputCategory)) + if not r.ok: + logger.warning("Connection to %s:%s failed! Check your configuration" % (section, inputCategory)) + + fork = ['default', {}] elif fork == "auto": logger.info("Attempting to auto-detect %s fork" % inputCategory)