]> jfr.im git - yt-dlp.git/blame - yt_dlp/utils/_deprecated.py
[networking] Rewrite architecture (#2861)
[yt-dlp.git] / yt_dlp / utils / _deprecated.py
CommitLineData
69bec673 1"""Deprecated - New code should avoid these"""
c365dba8 2import warnings
3
4from ..compat.compat_utils import passthrough_module
5
6# XXX: Implement this the same way as other DeprecationWarnings without circular import
7passthrough_module(__name__, '.._legacy', callback=lambda attr: warnings.warn(
8 DeprecationWarning(f'{__name__}.{attr} is deprecated'), stacklevel=6))
9del passthrough_module
10
69bec673 11
12from ._utils import preferredencoding
227bf1a3 13from ..networking._urllib import HTTPHandler
69bec673 14
c365dba8 15# isort: split
227bf1a3 16from .networking import random_user_agent, std_headers # noqa: F401
c365dba8 17from ..networking._urllib import PUTRequest # noqa: F401
18from ..networking._urllib import SUPPORTED_ENCODINGS, HEADRequest # noqa: F401
c365dba8 19from ..networking._urllib import ProxyHandler as PerRequestProxyHandler # noqa: F401
20from ..networking._urllib import RedirectHandler as YoutubeDLRedirectHandler # noqa: F401
21from ..networking._urllib import make_socks_conn_class, update_Request # noqa: F401
22from ..networking.exceptions import network_exceptions # noqa: F401
c365dba8 23
69bec673 24
25def encodeFilename(s, for_subprocess=False):
26 assert isinstance(s, str)
27 return s
28
29
30def decodeFilename(b, for_subprocess=False):
31 return b
32
33
34def decodeArgument(b):
35 return b
36
37
38def decodeOption(optval):
39 if optval is None:
40 return optval
41 if isinstance(optval, bytes):
42 optval = optval.decode(preferredencoding())
43
44 assert isinstance(optval, str)
45 return optval
46
47
48def error_to_compat_str(err):
49 return str(err)
227bf1a3 50
51
52class YoutubeDLHandler(HTTPHandler):
53 def __init__(self, params, *args, **kwargs):
54 self._params = params
55 super().__init__(*args, **kwargs)
56
57
58YoutubeDLHTTPSHandler = YoutubeDLHandler