mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2025-10-04 22:57:53 -04:00
[ffmpeg] Framework for feature detection
Related: #1502, #1237, https://github.com/ytdl-org/youtube-dl/pull/29581
This commit is contained in:
@@ -4007,10 +4007,7 @@ def check_executable(exe, args=[]):
|
||||
return exe
|
||||
|
||||
|
||||
def get_exe_version(exe, args=['--version'],
|
||||
version_re=None, unrecognized='present'):
|
||||
""" Returns the version of the specified executable,
|
||||
or False if the executable is not present """
|
||||
def _get_exe_version_output(exe, args):
|
||||
try:
|
||||
# STDIN should be redirected too. On UNIX-like systems, ffmpeg triggers
|
||||
# SIGTTOU if yt-dlp is run in the background.
|
||||
@@ -4022,7 +4019,7 @@ def get_exe_version(exe, args=['--version'],
|
||||
return False
|
||||
if isinstance(out, bytes): # Python 2.x
|
||||
out = out.decode('ascii', 'ignore')
|
||||
return detect_exe_version(out, version_re, unrecognized)
|
||||
return out
|
||||
|
||||
|
||||
def detect_exe_version(output, version_re=None, unrecognized='present'):
|
||||
@@ -4036,6 +4033,14 @@ def detect_exe_version(output, version_re=None, unrecognized='present'):
|
||||
return unrecognized
|
||||
|
||||
|
||||
def get_exe_version(exe, args=['--version'],
|
||||
version_re=None, unrecognized='present'):
|
||||
""" Returns the version of the specified executable,
|
||||
or False if the executable is not present """
|
||||
out = _get_exe_version_output(exe, args)
|
||||
return detect_exe_version(out, version_re, unrecognized) if out else False
|
||||
|
||||
|
||||
class LazyList(collections.abc.Sequence):
|
||||
''' Lazy immutable list from an iterable
|
||||
Note that slices of a LazyList are lists and not LazyList'''
|
||||
|
Reference in New Issue
Block a user