[ie/youtube] Add a PO Token Provider Framework (#12840)

https://github.com/yt-dlp/yt-dlp/tree/master/yt_dlp/extractor/youtube/pot/README.md

Authored by: coletdjnz
This commit is contained in:
coletdjnz 2025-05-18 13:45:26 +12:00 committed by GitHub
parent abf58dcd6a
commit 2685654a37
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
28 changed files with 4134 additions and 28 deletions

View file

@ -6,7 +6,8 @@ import math
import re
import urllib.parse
from ._helper import InstanceStoreMixin, select_proxy
from ._helper import InstanceStoreMixin
from ..utils.networking import select_proxy
from .common import (
Features,
Request,

View file

@ -13,7 +13,6 @@ import urllib.request
from .exceptions import RequestError
from ..dependencies import certifi
from ..socks import ProxyType, sockssocket
from ..utils import format_field, traverse_obj
if typing.TYPE_CHECKING:
from collections.abc import Iterable
@ -82,19 +81,6 @@ def make_socks_proxy_opts(socks_proxy):
}
def select_proxy(url, proxies):
"""Unified proxy selector for all backends"""
url_components = urllib.parse.urlparse(url)
if 'no' in proxies:
hostport = url_components.hostname + format_field(url_components.port, None, ':%s')
if urllib.request.proxy_bypass_environment(hostport, {'no': proxies['no']}):
return
elif urllib.request.proxy_bypass(hostport): # check system settings
return
return traverse_obj(proxies, url_components.scheme or 'http', 'all')
def get_redirect_method(method, status):
"""Unified redirect method handling"""

View file

@ -10,7 +10,7 @@ import warnings
from ..dependencies import brotli, requests, urllib3
from ..utils import bug_reports_message, int_or_none, variadic
from ..utils.networking import normalize_url
from ..utils.networking import normalize_url, select_proxy
if requests is None:
raise ImportError('requests module is not installed')
@ -41,7 +41,6 @@ from ._helper import (
create_socks_proxy_socket,
get_redirect_method,
make_socks_proxy_opts,
select_proxy,
)
from .common import (
Features,

View file

@ -26,7 +26,6 @@ from ._helper import (
create_socks_proxy_socket,
get_redirect_method,
make_socks_proxy_opts,
select_proxy,
)
from .common import Features, RequestHandler, Response, register_rh
from .exceptions import (
@ -41,7 +40,7 @@ from .exceptions import (
from ..dependencies import brotli
from ..socks import ProxyError as SocksProxyError
from ..utils import update_url_query
from ..utils.networking import normalize_url
from ..utils.networking import normalize_url, select_proxy
SUPPORTED_ENCODINGS = ['gzip', 'deflate']
CONTENT_DECODE_ERRORS = [zlib.error, OSError]

View file

@ -11,8 +11,8 @@ from ._helper import (
create_connection,
create_socks_proxy_socket,
make_socks_proxy_opts,
select_proxy,
)
from ..utils.networking import select_proxy
from .common import Features, Response, register_rh
from .exceptions import (
CertificateVerifyError,