diff options
author | bashonly <bashonly@protonmail.com> | 2024-10-30 13:41:26 -0500 |
---|---|---|
committer | bashonly <88596187+bashonly@users.noreply.github.com> | 2024-10-30 18:58:50 +0000 |
commit | d569a8845254d90ce13ad74ae76695e8d6441068 (patch) | |
tree | 20d1606eec9a559f3c9a2ea8330747b26ad3e1d6 | |
parent | 88402b714ec124633933737bc156b172a3dec3d6 (diff) |
[ie/youtube] Adjust OAuth refresh token handling (#11414)
Removes support for using '' as an empty password in netrc, e.g.:
machine youtube login oauth password ''
Double-quotes ("") are valid and must be used instead, e.g.:
machine youtube login oauth password ""
Authored by: bashonly
-rw-r--r-- | yt_dlp/extractor/youtube.py | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/yt_dlp/extractor/youtube.py b/yt_dlp/extractor/youtube.py index 5148e8261..99b8bfecc 100644 --- a/yt_dlp/extractor/youtube.py +++ b/yt_dlp/extractor/youtube.py @@ -644,13 +644,14 @@ class YoutubeBaseInfoExtractor(InfoExtractor): YoutubeBaseInfoExtractor._OAUTH_ACCESS_TOKEN_CACHE[self._OAUTH_PROFILE] = {} if refresh_token: - refresh_token = refresh_token.strip('\'') or None - - # Allow refresh token passed to initialize cache - if refresh_token: + msg = f'{self._OAUTH_DISPLAY_ID}: Using password input as refresh token' + if self.get_param('cachedir') is not False: + msg += ' and caching token to disk; you should supply an empty password next time' + self.to_screen(msg) self.cache.store(self._NETRC_MACHINE, self._oauth_cache_key, refresh_token) + else: + refresh_token = self.cache.load(self._NETRC_MACHINE, self._oauth_cache_key) - refresh_token = refresh_token or self.cache.load(self._NETRC_MACHINE, self._oauth_cache_key) if refresh_token: YoutubeBaseInfoExtractor._OAUTH_ACCESS_TOKEN_CACHE[self._OAUTH_PROFILE]['refresh_token'] = refresh_token try: |