Fix --netrc empty string parsing for Python <=3.10 (#11414)

Ref: https://github.com/python/cpython/commit/15409c720be0503131713e3d3abc1acd0da07378

Closes #11413
Authored by: bashonly, Grub4K

Co-authored-by: Simon Sawicki <contact@grub4k.xyz>
This commit is contained in:
bashonly
2024-10-30 18:58:50 +00:00
committed by bashonly
co-authored by Simon Sawicki
parent 5bc5fb2835
commit 88402b714e
4 changed files with 25 additions and 0 deletions
+7
View File
@@ -1409,6 +1409,13 @@ class InfoExtractor:
return None, None
self.write_debug(f'Using netrc for {netrc_machine} authentication')
# compat: <=py3.10: netrc cannot parse tokens as empty strings, will return `""` instead
# Ref: https://github.com/yt-dlp/yt-dlp/issues/11413
# https://github.com/python/cpython/commit/15409c720be0503131713e3d3abc1acd0da07378
if sys.version_info < (3, 11):
return tuple(x if x != '""' else '' for x in info[::2])
return info[0], info[2]
def _get_login_info(self, username_option='username', password_option='password', netrc_machine=None):