0
0
Fork 0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2024-11-25 02:45:12 +00:00

get session token

This commit is contained in:
bashonly 2024-11-20 15:24:36 +00:00 committed by GitHub
parent 50cdbbaf9c
commit 886ae0c277
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -8,6 +8,7 @@
str_or_none, str_or_none,
try_call, try_call,
unified_timestamp, unified_timestamp,
update_url_query,
) )
from ..utils.traversal import traverse_obj from ..utils.traversal import traverse_obj
@ -80,11 +81,20 @@ def _real_extract(self, url):
if not video_player or not video_player.get('manifest-url'): if not video_player or not video_player.get('manifest-url'):
raise ExtractorError('No video found', expected=True) raise ExtractorError('No video found', expected=True)
manifest_url = video_player['manifest-url']
session_token = self._download_json(
'https://sts.postimees.ee/session/register', video_id, 'Registering session',
'Unable to register session', headers={
'Accept': 'application/json',
'X-Original-URI': manifest_url,
})['session']
manifest_url = update_url_query(manifest_url, {'s': session_token})
episode_attr = self._parse_json(video_player.get(':episode') or '', video_id, fatal=False) or {} episode_attr = self._parse_json(video_player.get(':episode') or '', video_id, fatal=False) or {}
return { return {
'id': video_id, 'id': video_id,
'formats': self._extract_m3u8_formats(video_player['manifest-url'], video_id, 'mp4'), 'formats': self._extract_m3u8_formats(manifest_url, video_id, 'mp4'),
**traverse_obj(episode_attr, { **traverse_obj(episode_attr, {
'title': 'title', 'title': 'title',
'description': 'synopsis', 'description': 'synopsis',