From f7b6f6b40f97813206252f9c41dbe05bda592918 Mon Sep 17 00:00:00 2001 From: Zhiming Wang Date: Sun, 25 Dec 2016 13:48:00 -0500 Subject: [PATCH] ffmpeg: set loglevel to info in debug mode Occasionally, the FFmpeg invocation fails (which could be due to bugs in you-get; see #1558 for instance), but -loglevel quiet means nothing is printed other than the exit status (pretty much always 1) in Python's traceback, which is not helpful at all. This commit restores FFmpeg's regular output (-loglevel info) when --debug is specified. We're not using verbose, debug or trace because those levels are mostly only useful for debugging FFmpeg itself, which is not our goal. Due to lack of meaningful API to access the global logging level, this is a hack based on two assumptions: 1. When --debug is enabled, the root logger level is set to DEBUG; 2. processor.ffmpeg is lazily imported, after command line options are parsed. --- src/you_get/processor/ffmpeg.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) mode change 100644 => 100755 src/you_get/processor/ffmpeg.py diff --git a/src/you_get/processor/ffmpeg.py b/src/you_get/processor/ffmpeg.py old mode 100644 new mode 100755 index a8599e52..f5b3cd38 --- a/src/you_get/processor/ffmpeg.py +++ b/src/you_get/processor/ffmpeg.py @@ -1,5 +1,6 @@ #!/usr/bin/env python +import logging import os.path import subprocess from ..util.strings import parameterize @@ -21,7 +22,10 @@ def get_usable_ffmpeg(cmd): return None FFMPEG, FFMPEG_VERSION = get_usable_ffmpeg('ffmpeg') or get_usable_ffmpeg('avconv') or (None, None) -LOGLEVEL = ['-loglevel', 'quiet'] +if logging.getLogger().isEnabledFor(logging.DEBUG): + LOGLEVEL = ['-loglevel', 'info'] +else: + LOGLEVEL = ['-loglevel', 'quiet'] def has_ffmpeg_installed(): return FFMPEG is not None