mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2025-06-28 01:18:30 +00:00
Merge 6e3c184fbf
into 06c1a8cdff
This commit is contained in:
commit
e820545cfc
@ -1,12 +1,12 @@
|
|||||||
|
import functools
|
||||||
|
import urllib.parse
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..networking import HEADRequest
|
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
UserNotLive,
|
UserNotLive,
|
||||||
determine_ext,
|
determine_ext,
|
||||||
float_or_none,
|
float_or_none,
|
||||||
int_or_none,
|
int_or_none,
|
||||||
merge_dicts,
|
|
||||||
parse_iso8601,
|
parse_iso8601,
|
||||||
str_or_none,
|
str_or_none,
|
||||||
traverse_obj,
|
traverse_obj,
|
||||||
@ -16,21 +16,17 @@
|
|||||||
|
|
||||||
|
|
||||||
class KickBaseIE(InfoExtractor):
|
class KickBaseIE(InfoExtractor):
|
||||||
def _real_initialize(self):
|
@functools.cached_property
|
||||||
self._request_webpage(
|
def _api_headers(self):
|
||||||
HEADRequest('https://kick.com/'), None, 'Setting up session', fatal=False, impersonate=True)
|
token = traverse_obj(
|
||||||
xsrf_token = self._get_cookies('https://kick.com/').get('XSRF-TOKEN')
|
self._get_cookies('https://kick.com/'),
|
||||||
if not xsrf_token:
|
('session_token', 'value', {urllib.parse.unquote}))
|
||||||
self.write_debug('kick.com did not set XSRF-TOKEN cookie')
|
return {'Authorization': f'Bearer {token}'} if token else {}
|
||||||
KickBaseIE._API_HEADERS = {
|
|
||||||
'Authorization': f'Bearer {xsrf_token.value}',
|
|
||||||
'X-XSRF-TOKEN': xsrf_token.value,
|
|
||||||
} if xsrf_token else {}
|
|
||||||
|
|
||||||
def _call_api(self, path, display_id, note='Downloading API JSON', headers={}, **kwargs):
|
def _call_api(self, path, display_id, note='Downloading API JSON', headers={}, **kwargs):
|
||||||
return self._download_json(
|
return self._download_json(
|
||||||
f'https://kick.com/api/{path}', display_id, note=note,
|
f'https://kick.com/api/{path}', display_id, note=note,
|
||||||
headers=merge_dicts(headers, self._API_HEADERS), impersonate=True, **kwargs)
|
headers={**self._api_headers, **headers}, impersonate=True, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
class KickIE(KickBaseIE):
|
class KickIE(KickBaseIE):
|
||||||
|
Loading…
Reference in New Issue
Block a user