From 8434a58df0e6b5ecd20d2f669a5316afd1508983 Mon Sep 17 00:00:00 2001 From: echel0n Date: Sat, 19 Apr 2014 17:55:44 -0700 Subject: [PATCH] Detects ffmpeg and ffprobe at startup but will alert you to if there missing only when needed to be used so that we don't get a stupid error message at startup for no reason. --- TorrentToMedia.py | 4 ++-- autoProcessMedia.cfg.spec | 12 +++++++++--- nzbToMedia.py | 2 +- nzbtomedia/Transcoder.py | 8 ++++++++ nzbtomedia/__init__.py | 23 ++++++----------------- 5 files changed, 26 insertions(+), 23 deletions(-) diff --git a/TorrentToMedia.py b/TorrentToMedia.py index a096d578..9d8676c6 100755 --- a/TorrentToMedia.py +++ b/TorrentToMedia.py @@ -53,7 +53,7 @@ def processTorrent(inputDirectory, inputName, inputCategory, inputHash, inputID, status = 0 # Check video files for corruption for video in listMediaFiles(inputDirectory): - if nzbtomedia.FFPROBE and not Transcoder().isVideoGood(video): + if not Transcoder().isVideoGood(video): status = 1 logger.info("Calling autoProcessTV to post-process: %s",inputName) @@ -196,7 +196,7 @@ def processTorrent(inputDirectory, inputName, inputCategory, inputHash, inputID, # Check video files for corruption for video in listMediaFiles(inputDirectory): - if nzbtomedia.FFPROBE and not Transcoder().isVideoGood(video): + if not Transcoder().isVideoGood(video): status = 1 if nzbtomedia.CFG['CouchPotato'][inputCategory]: diff --git a/autoProcessMedia.cfg.spec b/autoProcessMedia.cfg.spec index dc2af100..250f7f4a 100644 --- a/autoProcessMedia.cfg.spec +++ b/autoProcessMedia.cfg.spec @@ -2,14 +2,22 @@ # For more information, visit https://github.com/clinton-hall/nzbToMedia/wiki [General] + # Enable/Disable update notifications version_notify = 1 + # Enable/Disable automatic updates auto_update = 0 + # Set to where your git executable is located git_path = + # GitHUB user for repo git_user = + # GitHUB branch for repo git_branch = force_clean = 0 + # Enable/Disable logging debug messages to nzbtomedia.log log_debug = 0 - + # Set to where your ffmpeg/ffprobe executables are located + ffmpeg_path = + [CouchPotato] #### autoProcessing for Movies #### movie - category that gets called for post-processing with CPS @@ -169,8 +177,6 @@ [Transcoder] transcode = 0 - # Set ffmpeg_path to the location where ffmpeg is located - ffmpeg_path = ###### duplicate =1 will cretae a new file. =0 will replace the original duplicate = 1 # Only works on Linux. Highest priority is -20, lowest priority is 19. diff --git a/nzbToMedia.py b/nzbToMedia.py index abd88bd3..a29106f1 100755 --- a/nzbToMedia.py +++ b/nzbToMedia.py @@ -292,7 +292,7 @@ def process(nzbDir, inputName=None, status=0, clientAgent='manual', download_id= if section: # Check video files for corruption for video in listMediaFiles(nzbDir): - if nzbtomedia.FFPROBE and not Transcoder().isVideoGood(video): + if not Transcoder().isVideoGood(video): status = 1 logger.info("Sending %s to %s for post-processing ..." % (inputName, str(section).upper())) diff --git a/nzbtomedia/Transcoder.py b/nzbtomedia/Transcoder.py index 89ccdaa6..9d59fcb9 100644 --- a/nzbtomedia/Transcoder.py +++ b/nzbtomedia/Transcoder.py @@ -14,6 +14,10 @@ class Transcoder: else: bitbucket = open('/dev/null') + if not nzbtomedia.FFPROBE: + logger.error("Cannot detect corrupt video files!, set your ffmpeg_path in your autoProcessMedia.cfg ...") + return False + command = [nzbtomedia.FFPROBE, videofile] try: logger.info('Checking if %s has any corruption, please stand by ...' % (videofile)) @@ -35,6 +39,10 @@ class Transcoder: else: bitbucket = open('/dev/null') + if not nzbtomedia.FFMPEG: + logger.error("Cannot transcode files!, set your ffmpeg_path in your autoProcessMedia.cfg ...") + return 1 + logger.info("Checking for files to be transcoded") final_result = 0 # initialize as successful for file in listMediaFiles(dirName): diff --git a/nzbtomedia/__init__.py b/nzbtomedia/__init__.py index 6e1373c4..6e4ad978 100644 --- a/nzbtomedia/__init__.py +++ b/nzbtomedia/__init__.py @@ -195,6 +195,7 @@ def initialize(section=None): GIT_USER = CFG['General']['git_user'] or 'clinton-hall' GIT_BRANCH = CFG['General']['git_branch'] or 'dev' FORCE_CLEAN = CFG["General"]["force_clean"] + FFMPEG_PATH = CFG["General"]["ffmpeg_path"] # Check for updates via GitHUB if versionCheck.CheckVersion().check_for_new_version(): @@ -245,7 +246,6 @@ def initialize(section=None): SAMPLEIDS = (CFG["Extensions"]["SampleIDs"]) # sample,-s. TRANSCODE = int(CFG["Transcoder"]["transcode"]) - FFMPEG_PATH = CFG["Transcoder"]["ffmpeg_path"] DUPLICATE = int(CFG["Transcoder"]["duplicate"]) IGNOREEXTENSIONS = (CFG["Transcoder"]["ignoreExtensions"]) OUTPUTVIDEOEXTENSION = CFG["Transcoder"]["outputVideoExtension"].strip() @@ -265,35 +265,24 @@ def initialize(section=None): FFMPEG = os.path.join(FFMPEG_PATH, 'ffmpeg.exe') FFPROBE = os.path.join(FFMPEG_PATH, 'ffprobe.exe') if TRANSCODE and not os.path.isfile(FFMPEG): # problem - logger.error("%s not found, insure that it does exist and that you've set the correct ffmpeg_path in your autoProcessMedia.cfg" % FFMPEG) - logger.error("Cannot transcode files, disabling transcoding!") - TRANSCODE = 0 FFMPEG = None if not os.path.isfile(FFPROBE): # problem - logger.error( - "%s not found, insure that it does exist and that you've set the correct ffmpeg_path in your autoProcessMedia.cfg" % FFPROBE) - logger.error("Cannot detect corrupt video files, disabling!") FFPROBE = None - else: bitbucket = open('/dev/null') FFMPEG = 'ffmpeg' FFPROBE = 'ffprobe' - if subprocess.call(['which', 'ffmpeg']) != 0: + if TRANSCODE and subprocess.call(['which', 'ffmpeg']) != 0 or subprocess.call(['which', 'ffprobe']) != 0: res = subprocess.call([os.path.join(PROGRAM_DIR, 'getffmpeg.sh')], stdout=bitbucket, stderr=bitbucket) - if res or subprocess.call(['which', 'ffmpeg'], stdout=bitbucket, stderr=bitbucket) != 0: # did not install or ffmpeg still not found. + if res: # did not install or ffmpeg still not found. logger.error("Failed to install ffmpeg. Please install manually") - logger.info("Cannot transcode video files, disabling transcoding!") - TRANSCODE = 0 + + if subprocess.call(['which', 'ffmpeg'], stdout=bitbucket, stderr=bitbucket) != 0: FFMPEG = None - if subprocess.call(['which', 'ffprobe']) != 0: - res = subprocess.call([os.path.join(PROGRAM_DIR, 'getffmpeg.sh')], stdout=bitbucket, stderr=bitbucket) - if res or subprocess.call(['which', 'ffprobe'], stdout=bitbucket, stderr=bitbucket) != 0: - logger.error("Failed to install ffprobe. Please install manually") - logger.info("Cannot detect corrupt video files, disabling corrupt video detection!") + if subprocess.call(['which', 'ffprobe'], stdout=bitbucket, stderr=bitbucket) != 0: FFPROBE = None USER_SCRIPT_CATEGORIES = CFG["UserScript"]["user_script_categories"]