aboutsummaryrefslogtreecommitdiffstats
path: root/yt_dlp/cookies.py
diff options
context:
space:
mode:
authorbashonly <bashonly@bashonly.com>2023-07-05 15:16:28 -0500
committerpukkandan <pukkandan.ytdlp@gmail.com>2023-07-06 23:14:38 +0530
commit1ceb657bdd254ad961489e5060f2ccc7d556b729 (patch)
tree15036d93f7b614adfa252a20120968e80bb587c5 /yt_dlp/cookies.py
parentad8902f616ad2541f9b9626738f1393fad89a64c (diff)
downloadhypervideo-pre-1ceb657bdd254ad961489e5060f2ccc7d556b729.tar.lz
hypervideo-pre-1ceb657bdd254ad961489e5060f2ccc7d556b729.tar.xz
hypervideo-pre-1ceb657bdd254ad961489e5060f2ccc7d556b729.zip
[fd/external] Scope cookies
- ffmpeg: Calculate cookies from cookiejar and pass with `-cookies` arg instead of `-headers` - aria2c, curl, wget: Write cookiejar to file and use external FD built-in cookiejar support - httpie: Calculate cookies from cookiejar instead of `http_headers` - axel: Calculate cookies from cookiejar and disable http redirection if cookies are passed - May break redirects, but axel simply don't have proper cookie support Ref: https://github.com/yt-dlp/yt-dlp/security/advisories/GHSA-v8mc-9377-rwjj Authored by: bashonly, coletdjnz
Diffstat (limited to 'yt_dlp/cookies.py')
-rw-r--r--yt_dlp/cookies.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/yt_dlp/cookies.py b/yt_dlp/cookies.py
index f21e4f7e7..53fe0ec2d 100644
--- a/yt_dlp/cookies.py
+++ b/yt_dlp/cookies.py
@@ -1327,6 +1327,13 @@ class YoutubeDLCookieJar(http.cookiejar.MozillaCookieJar):
self.add_cookie_header(cookie_req)
return cookie_req.get_header('Cookie')
+ def get_cookies_for_url(self, url):
+ """Generate a list of Cookie objects for a given url"""
+ # Policy `_now` attribute must be set before calling `_cookies_for_request`
+ # Ref: https://github.com/python/cpython/blob/3.7/Lib/http/cookiejar.py#L1360
+ self._policy._now = self._now = int(time.time())
+ return self._cookies_for_request(urllib.request.Request(escape_url(sanitize_url(url))))
+
def clear(self, *args, **kwargs):
with contextlib.suppress(KeyError):
return super().clear(*args, **kwargs)