diff options
author | pukkandan <pukkandan.ytdlp@gmail.com> | 2021-04-24 19:18:45 +0530 |
---|---|---|
committer | pukkandan <pukkandan.ytdlp@gmail.com> | 2021-04-24 19:20:07 +0530 |
commit | 915f911e365736227e134ad654601443dbfd7ccb (patch) | |
tree | 33a052023484564d66102a319365f582667f8bb1 /yt_dlp/utils.py | |
parent | cf9d6cfb0ccaf758be7cd21d247e05c0ed5dd839 (diff) | |
download | hypervideo-pre-915f911e365736227e134ad654601443dbfd7ccb.tar.lz hypervideo-pre-915f911e365736227e134ad654601443dbfd7ccb.tar.xz hypervideo-pre-915f911e365736227e134ad654601443dbfd7ccb.zip |
[utils] Encode URLs in `YoutubeDLCookieProcessor`
Closes #263
Diffstat (limited to 'yt_dlp/utils.py')
-rw-r--r-- | yt_dlp/utils.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/yt_dlp/utils.py b/yt_dlp/utils.py index 461f64db0..40d956808 100644 --- a/yt_dlp/utils.py +++ b/yt_dlp/utils.py @@ -2921,7 +2921,15 @@ class YoutubeDLCookieProcessor(compat_urllib_request.HTTPCookieProcessor): # response.headers[set_cookie_header] = set_cookie_escaped return compat_urllib_request.HTTPCookieProcessor.http_response(self, request, response) - https_request = compat_urllib_request.HTTPCookieProcessor.http_request + def http_request(self, request): + # If the URL contains non-ASCII characters, the cookies + # are lost before the request reaches YoutubeDLHandler. + # So we percent encode the url before adding cookies + # See: https://github.com/yt-dlp/yt-dlp/issues/263 + request = update_Request(request, url=escape_url(request.get_full_url())) + return compat_urllib_request.HTTPCookieProcessor.http_request(self, request) + + https_request = http_request https_response = http_response |