mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-14 13:13:06 +00:00
parent
1fb707badb
commit
28787f16c6
@ -13,6 +13,7 @@ from ..compat import (
|
|||||||
)
|
)
|
||||||
from ..postprocessor.ffmpeg import FFmpegPostProcessor, EXT_TO_OUT_FORMATS
|
from ..postprocessor.ffmpeg import FFmpegPostProcessor, EXT_TO_OUT_FORMATS
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
|
classproperty,
|
||||||
cli_option,
|
cli_option,
|
||||||
cli_valueless_option,
|
cli_valueless_option,
|
||||||
cli_bool_option,
|
cli_bool_option,
|
||||||
@ -73,17 +74,23 @@ class ExternalFD(FragmentFD):
|
|||||||
def get_basename(cls):
|
def get_basename(cls):
|
||||||
return cls.__name__[:-2].lower()
|
return cls.__name__[:-2].lower()
|
||||||
|
|
||||||
|
@classproperty
|
||||||
|
def EXE_NAME(cls):
|
||||||
|
return cls.get_basename()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def exe(self):
|
def exe(self):
|
||||||
return self.get_basename()
|
return self.EXE_NAME
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def available(cls, path=None):
|
def available(cls, path=None):
|
||||||
path = check_executable(path or cls.get_basename(), [cls.AVAILABLE_OPT])
|
path = check_executable(
|
||||||
if path:
|
cls.EXE_NAME if path in (None, cls.get_basename()) else path,
|
||||||
cls.exe = path
|
[cls.AVAILABLE_OPT])
|
||||||
return path
|
if not path:
|
||||||
return False
|
return False
|
||||||
|
cls.exe = path
|
||||||
|
return path
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def supports(cls, info_dict):
|
def supports(cls, info_dict):
|
||||||
@ -106,7 +113,7 @@ class ExternalFD(FragmentFD):
|
|||||||
|
|
||||||
def _configuration_args(self, keys=None, *args, **kwargs):
|
def _configuration_args(self, keys=None, *args, **kwargs):
|
||||||
return _configuration_args(
|
return _configuration_args(
|
||||||
self.get_basename(), self.params.get('external_downloader_args'), self.get_basename(),
|
self.get_basename(), self.params.get('external_downloader_args'), self.EXE_NAME,
|
||||||
keys, *args, **kwargs)
|
keys, *args, **kwargs)
|
||||||
|
|
||||||
def _call_downloader(self, tmpfilename, info_dict):
|
def _call_downloader(self, tmpfilename, info_dict):
|
||||||
@ -306,10 +313,7 @@ class Aria2cFD(ExternalFD):
|
|||||||
|
|
||||||
class HttpieFD(ExternalFD):
|
class HttpieFD(ExternalFD):
|
||||||
AVAILABLE_OPT = '--version'
|
AVAILABLE_OPT = '--version'
|
||||||
|
EXE_NAME = 'http'
|
||||||
@classmethod
|
|
||||||
def available(cls, path=None):
|
|
||||||
return super().available(path or 'http')
|
|
||||||
|
|
||||||
def _make_cmd(self, tmpfilename, info_dict):
|
def _make_cmd(self, tmpfilename, info_dict):
|
||||||
cmd = ['http', '--download', '--output', tmpfilename, info_dict['url']]
|
cmd = ['http', '--download', '--output', tmpfilename, info_dict['url']]
|
||||||
@ -510,11 +514,13 @@ class AVconvFD(FFmpegFD):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
_BY_NAME = dict(
|
_BY_NAME = {
|
||||||
(klass.get_basename(), klass)
|
klass.get_basename(): klass
|
||||||
for name, klass in globals().items()
|
for name, klass in globals().items()
|
||||||
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():
|
||||||
@ -526,4 +532,4 @@ def get_external_downloader(external_downloader):
|
|||||||
downloader . """
|
downloader . """
|
||||||
# Drop .exe extension on Windows
|
# 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)
|
return _BY_NAME.get(bn, _BY_EXE.get(bn))
|
||||||
|
@ -5502,3 +5502,11 @@ has_websockets = bool(compat_websockets)
|
|||||||
def merge_headers(*dicts):
|
def merge_headers(*dicts):
|
||||||
"""Merge dicts of http headers case insensitively, prioritizing the latter ones"""
|
"""Merge dicts of http headers case insensitively, prioritizing the latter ones"""
|
||||||
return {k.title(): v for k, v in itertools.chain.from_iterable(map(dict.items, dicts))}
|
return {k.title(): v for k, v in itertools.chain.from_iterable(map(dict.items, dicts))}
|
||||||
|
|
||||||
|
|
||||||
|
class classproperty:
|
||||||
|
def __init__(self, f):
|
||||||
|
self.f = f
|
||||||
|
|
||||||
|
def __get__(self, _, cls):
|
||||||
|
return self.f(cls)
|
||||||
|
Loading…
Reference in New Issue
Block a user