From 5090388b73a840199b86158aa2241978053ab0f5 Mon Sep 17 00:00:00 2001 From: coletdjnz <coletdjnz@protonmail.com> Date: Sat, 4 Jan 2025 12:28:42 +1300 Subject: [PATCH] Move cookie log in message to _real_initialize --- yt_dlp/extractor/youtube.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/yt_dlp/extractor/youtube.py b/yt_dlp/extractor/youtube.py index 6926f8688d..776d20e348 100644 --- a/yt_dlp/extractor/youtube.py +++ b/yt_dlp/extractor/youtube.py @@ -567,9 +567,15 @@ class YoutubeBaseInfoExtractor(InfoExtractor): pref.update({'hl': self._preferred_lang or 'en', 'tz': 'UTC'}) self._set_cookie('.youtube.com', name='PREF', value=urllib.parse.urlencode(pref)) + def _initialize_cookie_auth(self): + self._load_sid_cookies() + if self._SAPISID or self._1PSAPISID or self._3PSAPISID: + self.write_debug('Logged in using cookies') + def _real_initialize(self): self._initialize_pref() self._initialize_consent() + self._initialize_cookie_auth() self._check_login_required() def _perform_login(self, username, password): @@ -800,10 +806,7 @@ class YoutubeBaseInfoExtractor(InfoExtractor): @functools.cached_property def is_authenticated(self): - if bool(self._generate_sid_authorization()): - self.write_debug('Logged in using cookies') - return True - return False + return bool(self._generate_sid_authorization()) def extract_ytcfg(self, video_id, webpage): if not webpage: