1 from .common
import InfoExtractor
9 # Video from www.kompas.tv and video.kompas.com seems use jixie player
10 # see [1] https://jixie.atlassian.net/servicedesk/customer/portal/2/article/1339654214?src=-1456335525,
11 # [2] https://scripts.jixie.media/jxvideo.3.1.min.js for more info
14 class KompasVideoIE(InfoExtractor
):
15 _VALID_URL
= r
'https?://video\.kompas\.com/\w+/(?P<id>\d+)/(?P<slug>[\w-]+)'
17 'url': 'https://video.kompas.com/watch/164474/kim-jong-un-siap-kirim-nuklir-lawan-as-dan-korsel',
21 'title': 'Kim Jong Un Siap Kirim Nuklir Lawan AS dan Korsel',
22 'description': 'md5:262530c4fb7462398235f9a5dba92456',
23 'uploader_id': '9262bf2590d558736cac4fff7978fcb1',
24 'display_id': 'kim-jong-un-siap-kirim-nuklir-lawan-as-dan-korsel',
25 'duration': 85.066667,
26 'categories': ['news'],
27 'thumbnail': 'https://video.jixie.media/1001/164474/164474_1280x720.jpg',
32 def _real_extract(self
, url
):
33 video_id
, display_id
= self
._match
_valid
_url
(url
).group('id', 'slug')
34 webpage
= self
._download
_webpage
(url
, display_id
)
36 json_data
= self
._download
_json
(
37 'https://apidam.jixie.io/api/public/stream', display_id
,
38 query
={'metadata': 'full', 'video_id': video_id}
)['data']
40 formats
, subtitles
= [], {}
41 for stream
in json_data
['streams']:
42 if stream
.get('type') == 'HLS':
43 fmt
, sub
= self
._extract
_m
3u8_formats
_and
_subtitles
(stream
.get('url'), display_id
, ext
='mp4')
45 self
._merge
_subtitles
(sub
, target
=subtitles
)
48 'url': stream
.get('url'),
49 'width': stream
.get('width'),
50 'height': stream
.get('height'),
54 self
._sort
_formats
(formats
)
57 'display_id': display_id
,
59 'subtitles': subtitles
,
60 'title': json_data
.get('title') or self
._html
_search
_meta
(['og:title', 'twitter:title'], webpage
),
61 'description': (clean_html(traverse_obj(json_data
, ('metadata', 'description')))
62 or self
._html
_search
_meta
(['description', 'og:description', 'twitter:description'], webpage
)),
63 'thumbnails': traverse_obj(json_data
, ('metadata', 'thumbnails')),
64 'duration': float_or_none(traverse_obj(json_data
, ('metadata', 'duration'))),
65 'tags': try_call(lambda: json_data
['metadata']['keywords'].split(',')),
66 'categories': try_call(lambda: json_data
['metadata']['categories'].split(',')),
67 'uploader_id': json_data
.get('owner_id'),