]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/tempo.py
1 from .common
import InfoExtractor
2 from ..utils
import int_or_none
, parse_iso8601
, str_or_none
, traverse_obj
5 class TempoIE(InfoExtractor
):
6 _VALID_URL
= r
'https?://video\.tempo\.co/\w+/\d+/(?P<id>[\w-]+)'
8 'url': 'https://video.tempo.co/read/30058/anies-baswedan-ajukan-banding-putusan-ptun-batalkan-ump-dki',
12 'title': 'Anies Baswedan Ajukan Banding Putusan PTUN Batalkan UMP DKI',
13 'display_id': 'anies-baswedan-ajukan-banding-putusan-ptun-batalkan-ump-dki',
15 'description': 'md5:a6822b7c4c874fa7e5bd63e96a387b66',
16 'thumbnail': 'https://statik.tempo.co/data/2022/07/27/id_1128287/1128287_720.jpg',
17 'timestamp': 1658911277,
18 'upload_date': '20220727',
19 'tags': ['Anies Baswedan', ' PTUN', ' PTUN | Pengadilan Tata Usaha Negara', ' PTUN Batalkan UMP DKI', ' UMP DKI'],
23 def _real_extract(self
, url
):
24 display_id
= self
._match
_id
(url
)
25 webpage
= self
._download
_webpage
(url
, display_id
)
27 player_key
, widget_id
= self
._search
_regex
(
28 r
'<ivs-player\s*[^>]+data-ivs-key\s*=\s*"(?P<player_key>[\w]+)[^>]+\bdata-ivs-wid="(?P<widget_id>[\w-]+)',
29 webpage
, 'player_key, widget_id', group
=('player_key', 'widget_id'))
31 json_ld_data
= self
._search
_json
_ld
(webpage
, display_id
)
33 json_data
= self
._download
_json
(
34 f
'https://ivxplayer.ivideosmart.com/prod/widget/{widget_id}',
35 display_id
, query
={'key': player_key}
)
36 formats
, subtitles
= self
._extract
_m
3u8_formats
_and
_subtitles
(
37 json_data
['player']['video_url'], display_id
, ext
='mp4')
40 'id': str(json_data
['ivx']['id']),
41 'display_id': display_id
,
43 'subtitles': subtitles
,
44 'title': (self
._html
_search
_meta
('twitter:title', webpage
) or self
._og
_search
_title
(webpage
)
45 or traverse_obj(json_data
, ('ivx', 'name'))),
46 'duration': int_or_none(traverse_obj(json_data
, ('ivx', 'duration'))),
47 'thumbnail': (self
._html
_search
_meta
('twitter:image:src', webpage
) or self
._og
_search
_thumbnail
(webpage
)
48 or traverse_obj(json_data
, ('ivx', 'thumbnail_url'))),
49 'description': (json_ld_data
.get('description') or self
._html
_search
_meta
(['description', 'twitter:description'], webpage
)
50 or self
._og
_search
_description
(webpage
)),
51 'timestamp': parse_iso8601(traverse_obj(json_data
, ('ivx', 'created_at'))),
52 'tags': str_or_none(self
._html
_search
_meta
('keywords', webpage
), '').split(','),