1
0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2025-12-31 12:01:36 +00:00

Merge branch 'yt-dlp:master' into pr/yt-live-from-start-range

This commit is contained in:
bashonly
2024-03-19 15:18:22 -05:00
282 changed files with 3479 additions and 3113 deletions

View File

@@ -10,14 +10,14 @@ import urllib.request
import zlib
from ._utils import Popen, decode_base_n, preferredencoding
from .networking import escape_rfc3986 # noqa: F401
from .networking import normalize_url as escape_url # noqa: F401
from .traversal import traverse_obj
from ..dependencies import certifi, websockets
from ..networking._helper import make_ssl_context
from ..networking._urllib import HTTPHandler
# isort: split
from .networking import escape_rfc3986 # noqa: F401
from .networking import normalize_url as escape_url # noqa: F401
from .networking import random_user_agent, std_headers # noqa: F401
from ..cookies import YoutubeDLCookieJar # noqa: F401
from ..networking._urllib import PUTRequest # noqa: F401
@@ -90,7 +90,7 @@ class WebSocketsWrapper:
for task in to_cancel:
task.cancel()
# XXX: "loop" is removed in python 3.10+
# XXX: "loop" is removed in Python 3.10+
loop.run_until_complete(
asyncio.gather(*to_cancel, loop=loop, return_exceptions=True))

View File

@@ -1379,6 +1379,9 @@ class DateRange:
def __repr__(self):
return f'{__name__}.{type(self).__name__}({self.start.isoformat()!r}, {self.end.isoformat()!r})'
def __str__(self):
return f'{self.start} to {self.end}'
def __eq__(self, other):
return (isinstance(other, DateRange)
and self.start == other.start and self.end == other.end)
@@ -1424,7 +1427,8 @@ def write_string(s, out=None, encoding=None):
s = re.sub(r'([\r\n]+)', r' \1', s)
enc, buffer = None, out
if 'b' in getattr(out, 'mode', ''):
# `mode` might be `None` (Ref: https://github.com/yt-dlp/yt-dlp/issues/8816)
if 'b' in (getattr(out, 'mode', None) or ''):
enc = encoding or preferredencoding()
elif hasattr(out, 'buffer'):
buffer = out.buffer
@@ -3243,6 +3247,8 @@ def match_str(filter_str, dct, incomplete=False):
def match_filter_func(filters, breaking_filters=None):
if not filters and not breaking_filters:
return None
repr_ = f'{match_filter_func.__module__}.{match_filter_func.__qualname__}({filters}, {breaking_filters})'
breaking_filters = match_filter_func(breaking_filters) or (lambda _, __: None)
filters = set(variadic(filters or []))
@@ -3250,6 +3256,7 @@ def match_filter_func(filters, breaking_filters=None):
if interactive:
filters.remove('-')
@function_with_repr.set_repr(repr_)
def _match_func(info_dict, incomplete=False):
ret = breaking_filters(info_dict, incomplete)
if ret is not None:
@@ -4473,7 +4480,7 @@ def write_xattr(path, key, value):
else 'xattr' if check_executable('xattr', ['-h']) else None)
if not exe:
raise XAttrUnavailableError(
'Couldn\'t find a tool to set the xattrs. Install either the python "xattr" or "pyxattr" modules or the '
'Couldn\'t find a tool to set the xattrs. Install either the "xattr" or "pyxattr" Python modules or the '
+ ('"xattr" binary' if sys.platform != 'linux' else 'GNU "attr" package (which contains the "setfattr" tool)'))
value = value.decode()
@@ -4981,6 +4988,10 @@ class function_with_repr:
def __call__(self, *args, **kwargs):
return self.func(*args, **kwargs)
@classmethod
def set_repr(cls, repr_):
return functools.partial(cls, repr_=repr_)
def __repr__(self):
if self.__repr:
return self.__repr