mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-30 12:01:28 +00:00
[youtube] Add debug message for SAPISID cookie extraction (#540)
Authored by: colethedj
This commit is contained in:
parent
982ee69a74
commit
c926c9541f
|
@ -520,13 +520,15 @@ def _generate_sapisidhash_header(self, origin='https://www.youtube.com'):
|
||||||
yt_cookies = self._get_cookies('https://www.youtube.com')
|
yt_cookies = self._get_cookies('https://www.youtube.com')
|
||||||
sapisid_cookie = dict_get(
|
sapisid_cookie = dict_get(
|
||||||
yt_cookies, ('__Secure-3PAPISID', 'SAPISID'))
|
yt_cookies, ('__Secure-3PAPISID', 'SAPISID'))
|
||||||
if sapisid_cookie is None:
|
if sapisid_cookie is None or not sapisid_cookie.value:
|
||||||
return
|
return
|
||||||
time_now = round(time.time())
|
time_now = round(time.time())
|
||||||
# SAPISID cookie is required if not already present
|
# SAPISID cookie is required if not already present
|
||||||
if not yt_cookies.get('SAPISID'):
|
if not yt_cookies.get('SAPISID'):
|
||||||
|
self.write_debug('Copying __Secure-3PAPISID cookie to SAPISID cookie', only_once=True)
|
||||||
self._set_cookie(
|
self._set_cookie(
|
||||||
'.youtube.com', 'SAPISID', sapisid_cookie.value, secure=True, expire_time=time_now + 3600)
|
'.youtube.com', 'SAPISID', sapisid_cookie.value, secure=True, expire_time=time_now + 3600)
|
||||||
|
self.write_debug('Extracted SAPISID cookie', only_once=True)
|
||||||
# SAPISIDHASH algorithm from https://stackoverflow.com/a/32065323
|
# SAPISIDHASH algorithm from https://stackoverflow.com/a/32065323
|
||||||
sapisidhash = hashlib.sha1(
|
sapisidhash = hashlib.sha1(
|
||||||
f'{time_now} {sapisid_cookie.value} {origin}'.encode('utf-8')).hexdigest()
|
f'{time_now} {sapisid_cookie.value} {origin}'.encode('utf-8')).hexdigest()
|
||||||
|
|
Loading…
Reference in a new issue