mirror of
				https://github.com/yt-dlp/yt-dlp.git
				synced 2025-10-31 14:45:14 +00:00 
			
		
		
		
	Move check_executable into a helper ufnction
This commit is contained in:
		| @@ -7,6 +7,7 @@ import time | |||||||
| from .common import AudioConversionError, PostProcessor | from .common import AudioConversionError, PostProcessor | ||||||
|  |  | ||||||
| from ..utils import ( | from ..utils import ( | ||||||
|  |     check_executable, | ||||||
|     compat_subprocess_get_DEVNULL, |     compat_subprocess_get_DEVNULL, | ||||||
|     encodeFilename, |     encodeFilename, | ||||||
|     PostProcessingError, |     PostProcessingError, | ||||||
| @@ -27,14 +28,8 @@ class FFmpegPostProcessor(PostProcessor): | |||||||
|  |  | ||||||
|     @staticmethod |     @staticmethod | ||||||
|     def detect_executables(): |     def detect_executables(): | ||||||
|         def executable(exe): |  | ||||||
|             try: |  | ||||||
|                 subprocess.Popen([exe, '-version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate() |  | ||||||
|             except OSError: |  | ||||||
|                 return False |  | ||||||
|             return exe |  | ||||||
|         programs = ['avprobe', 'avconv', 'ffmpeg', 'ffprobe'] |         programs = ['avprobe', 'avconv', 'ffmpeg', 'ffprobe'] | ||||||
|         return dict((program, executable(program)) for program in programs) |         return dict((program, check_executable(program, ['-version'])) for program in programs) | ||||||
|  |  | ||||||
|     def run_ffmpeg_multiple_files(self, input_paths, out_path, opts): |     def run_ffmpeg_multiple_files(self, input_paths, out_path, opts): | ||||||
|         if not self._exes['ffmpeg'] and not self._exes['avconv']: |         if not self._exes['ffmpeg'] and not self._exes['avconv']: | ||||||
|   | |||||||
| @@ -1151,3 +1151,13 @@ def parse_duration(s): | |||||||
| def prepend_extension(filename, ext): | def prepend_extension(filename, ext): | ||||||
|     name, real_ext = os.path.splitext(filename)  |     name, real_ext = os.path.splitext(filename)  | ||||||
|     return u'{0}.{1}{2}'.format(name, ext, real_ext) |     return u'{0}.{1}{2}'.format(name, ext, real_ext) | ||||||
|  |  | ||||||
|  |  | ||||||
|  | def check_executable(exe, args=[]): | ||||||
|  |     """ Checks if the given binary is installed somewhere in PATH, and returns its name. | ||||||
|  |     args can be a list of arguments for a short output (like -version) """ | ||||||
|  |     try: | ||||||
|  |         subprocess.Popen([exe] + args, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate() | ||||||
|  |     except OSError: | ||||||
|  |         return False | ||||||
|  |     return exe | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Philipp Hagemeister
					Philipp Hagemeister