aboutsummaryrefslogtreecommitdiff
path: root/yt_dlp/extractor/common.py
diff options
context:
space:
mode:
authorbashonly <bashonly@protonmail.com>2024-10-30 13:40:07 -0500
committerbashonly <88596187+bashonly@users.noreply.github.com>2024-10-30 18:58:50 +0000
commit88402b714ec124633933737bc156b172a3dec3d6 (patch)
tree2ba54d621c6243f95e5e8fef7f04dcfce2662919 /yt_dlp/extractor/common.py
parent5bc5fb2835ea59bdf326bd12176d74d2c7348a95 (diff)
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>
Diffstat (limited to 'yt_dlp/extractor/common.py')
-rw-r--r--yt_dlp/extractor/common.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/yt_dlp/extractor/common.py b/yt_dlp/extractor/common.py
index ecece85f5..7e6e6227d 100644
--- a/yt_dlp/extractor/common.py
+++ b/yt_dlp/extractor/common.py
@@ -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):