[downloader/external] Smarter detection of executable

Closes #4778
This commit is contained in:
pukkandan 2022-08-30 18:10:48 +05:30
parent d81ba7d491
commit e1eabd7beb
No known key found for this signature in database
GPG key ID: 7EEE9E1E817D0A39

View file

@ -515,16 +515,14 @@ class AVconvFD(FFmpegFD):
if name.endswith('FD') and name not in ('ExternalFD', 'FragmentFD') if name.endswith('FD') and name not in ('ExternalFD', 'FragmentFD')
} }
_BY_EXE = {klass.EXE_NAME: klass for klass in _BY_NAME.values()}
def list_external_downloaders(): def list_external_downloaders():
return sorted(_BY_NAME.keys()) return sorted(_BY_NAME.keys())
def get_external_downloader(external_downloader): def get_external_downloader(external_downloader):
""" Given the name of the executable, see whether we support the given """ Given the name of the executable, see whether we support the given downloader """
downloader . """
# Drop .exe extension on Windows
bn = os.path.splitext(os.path.basename(external_downloader))[0] bn = os.path.splitext(os.path.basename(external_downloader))[0]
return _BY_NAME.get(bn, _BY_EXE.get(bn)) return _BY_NAME.get(bn) or next((
klass for klass in _BY_NAME.values() if klass.EXE_NAME in bn
), None)