Skip to content

Commit

Permalink
[utils] Encode URLs in YoutubeDLCookieProcessor
Browse files Browse the repository at this point in the history
  • Loading branch information
pukkandan committed Apr 24, 2021
1 parent cf9d6cf commit 915f911
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion yt_dlp/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2921,7 +2921,15 @@ def http_response(self, request, response):
# 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


Expand Down

0 comments on commit 915f911

Please sign in to comment.