1
0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2025-08-14 00:18:31 +00:00

[ie/weverse] Fix livestream support

Authored by: bashonly
This commit is contained in:
bashonly 2025-08-01 15:28:12 -05:00
parent c58b73d9c7
commit 867aa7f776
No known key found for this signature in database
GPG Key ID: 783F096F253D15B0

View File

@ -99,6 +99,10 @@ def _token_is_expired(self, key):
return is_expired
return not self._access_token_is_valid()
def _set_weverse_auth_cookies(self):
self._set_cookie('.weverse.io', self._ACCESS_TOKEN_KEY, self._oauth_tokens[self._ACCESS_TOKEN_KEY])
self._set_cookie('.weverse.io', self._REFRESH_TOKEN_KEY, self._oauth_tokens[self._REFRESH_TOKEN_KEY])
def _refresh_access_token(self):
if not self._oauth_tokens.get(self._REFRESH_TOKEN_KEY):
self._report_login_error('no_refresh_token')
@ -120,10 +124,9 @@ def _refresh_access_token(self):
except ExtractorError as e:
if isinstance(e.cause, HTTPError) and e.cause.status == 401:
self._oauth_tokens.clear()
if self._oauth_cache_key == 'cookies':
self.cookiejar.clear(domain='.weverse.io', path='/', name=self._ACCESS_TOKEN_KEY)
self.cookiejar.clear(domain='.weverse.io', path='/', name=self._REFRESH_TOKEN_KEY)
else:
self.cookiejar.clear(domain='.weverse.io', path='/', name=self._ACCESS_TOKEN_KEY)
self.cookiejar.clear(domain='.weverse.io', path='/', name=self._REFRESH_TOKEN_KEY)
if self._oauth_cache_key != 'cookies':
self.cache.store(self._NETRC_MACHINE, self._oauth_cache_key, self._oauth_tokens)
self._report_login_error('expired_refresh_token')
raise
@ -133,10 +136,8 @@ def _refresh_access_token(self):
self._REFRESH_TOKEN_KEY: ('refreshToken', {str}, {require('refresh token')}),
}))
if self._oauth_cache_key == 'cookies':
self._set_cookie('.weverse.io', self._ACCESS_TOKEN_KEY, self._oauth_tokens[self._ACCESS_TOKEN_KEY])
self._set_cookie('.weverse.io', self._REFRESH_TOKEN_KEY, self._oauth_tokens[self._REFRESH_TOKEN_KEY])
else:
self._set_weverse_auth_cookies()
if self._oauth_cache_key != 'cookies':
self.cache.store(self._NETRC_MACHINE, self._oauth_cache_key, self._oauth_tokens)
def _get_authorization_header(self):
@ -169,6 +170,7 @@ def _perform_login(self, username, password):
self._oauth_tokens.update(self.cache.load(self._NETRC_MACHINE, self._oauth_cache_key, default={}))
if self._is_logged_in and self._access_token_is_valid():
self._set_weverse_auth_cookies()
return
rt_key = self._REFRESH_TOKEN_KEY
@ -471,6 +473,8 @@ def _real_extract(self, url):
'channel': channel,
'channel_url': f'https://weverse.io/{channel}',
'formats': formats,
# Needed for livestream HLS AES keys
'additional_cookies_urls': ['https://video-api.weverse.io/'],
'availability': availability,
'live_status': live_status,
**self._parse_post_meta(post),