diff options
author | dirkf <fieldhouse@gmx.net> | 2022-01-31 04:28:54 +0000 |
---|---|---|
committer | dirkf <fieldhouse@gmx.net> | 2023-02-13 03:54:51 +0000 |
commit | 58988c1421b88875a33015b08e4d2ada43021e09 (patch) | |
tree | 468a0ced4de0fb37de023768f5bc465077c1648f /youtube_dl/utils.py | |
parent | e19ec5232216fd801ded88728df5b50bfb05c1cc (diff) |
[YouTube] Bypass age-gating for certain restricted videos
* Use TVHTML5_SIMPLY_EMBEDDED_PLAYER client
* Also add and fix tests
* Introduce and use new utility function `update_url()`
Diffstat (limited to 'youtube_dl/utils.py')
-rw-r--r-- | youtube_dl/utils.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py index e3c3ccff9..d5cc6386d 100644 --- a/youtube_dl/utils.py +++ b/youtube_dl/utils.py @@ -4121,6 +4121,17 @@ def update_url_query(url, query): query=compat_urllib_parse_urlencode(qs, True))) +def update_url(url, **kwargs): + """Replace URL components specified by kwargs + url: compat_str or parsed URL tuple + returns: compat_str""" + if not kwargs: + return compat_urlparse.urlunparse(url) if isinstance(url, tuple) else url + if not isinstance(url, tuple): + url = compat_urlparse.urlparse(url) + return compat_urlparse.urlunparse(url._replace(**kwargs)) + + def update_Request(req, url=None, data=None, headers={}, query={}): req_headers = req.headers.copy() req_headers.update(headers) |