2 from __future__
import unicode_literals
4 from .common
import InfoExtractor
5 from ..utils
import unified_strdate
8 class OlympicsReplayIE(InfoExtractor
):
9 _VALID_URL
= r
'(?:https?://)(?:www\.)?olympics\.com/tokyo-2020/(?:[a-z]{2}/)?replay/(?P<id>[^/#&?]+)'
11 'url': 'https://olympics.com/tokyo-2020/en/replay/300622eb-abc0-43ea-b03b-c5f2d429ec7b/jumping-team-qualifier',
13 'id': '300622eb-abc0-43ea-b03b-c5f2d429ec7b',
15 'title': 'Jumping Team Qualifier',
16 'release_date': '20210806',
17 'upload_date': '20210713',
23 'url': 'https://olympics.com/tokyo-2020/en/replay/bd242924-4b22-49a5-a846-f1d4c809250d/mens-bronze-medal-match-hun-esp',
24 'only_matching': True,
27 def _real_extract(self
, url
):
28 id = self
._match
_id
(url
)
29 # The parameters are hardcoded in the webpage, it's not necessary to download the webpage just for these parameters.
30 # If in downloading webpage serves other functions aswell, then extract these parameters from it.
31 token_url
= 'https://appovptok.ovpobs.tv/api/identity/app/token?api_key=OTk5NDcxOjpvY3N3LWFwaXVzZXI%3D&api_secret=ODY4ODM2MjE3ODMwYmVjNTAxMWZlMDJiMTYxZmY0MjFiMjMwMjllMjJmNDA1YWRiYzA5ODcxYTZjZTljZDkxOTo6NTM2NWIzNjRlMTM1ZmI2YWNjNmYzMGMzOGM3NzZhZTY%3D'
32 token
= self
._download
_webpage
(token_url
, id)
33 headers
= {'x-obs-app-token': token}
34 data_json
= self
._download
_json
(f
'https://appocswtok.ovpobs.tv/api/schedule-sessions/{id}?include=stream',
36 meta_data
= data_json
['data']['attributes']
37 for t_dict
in data_json
['included']:
38 if t_dict
.get('type') == 'Stream':
39 stream_data
= t_dict
['attributes']
40 m3u8_url
= self
._download
_json
(
41 'https://meteringtok.ovpobs.tv/api/playback-sessions', id, headers
=headers
, query
={
42 'alias': stream_data
['alias'],
43 'stream': stream_data
['stream'],
45 })['data']['attributes']['url']
46 formats
, subtitles
= self
._extract
_m
3u8_formats
_and
_subtitles
(m3u8_url
, id)
47 self
._sort
_formats
(formats
)
51 'title': meta_data
['title'],
52 'release_date': unified_strdate(meta_data
.get('start') or meta_data
.get('broadcastPublished')),
53 'upload_date': unified_strdate(meta_data
.get('publishedAt')),
55 'subtitles': subtitles
,