1 from .common
import InfoExtractor
6 get_element_html_by_attribute
,
7 get_elements_html_by_class
,
17 from ..utils
.traversal
import traverse_obj
20 class Kenh14VideoIE(InfoExtractor
):
21 _VALID_URL
= r
'https?://video\.kenh14\.vn/(?:video/)?[\w-]+-(?P<id>[0-9]+)\.chn'
23 'url': 'https://video.kenh14.vn/video/mo-hop-iphone-14-pro-max-nguon-unbox-therapy-316173.chn',
24 'md5': '1ed67f9c3a1e74acf15db69590cf6210',
28 'title': 'Video mở hộp iPhone 14 Pro Max (Nguồn: Unbox Therapy)',
29 'description': 'Video mở hộp iPhone 14 Pro MaxVideo mở hộp iPhone 14 Pro Max (Nguồn: Unbox Therapy)',
30 'thumbnail': r
're:^https?://videothumbs\.mediacdn\.vn/.*\.jpg$',
32 'uploader': 'Unbox Therapy',
33 'upload_date': '20220517',
36 'timestamp': 1652764468,
39 'url': 'https://video.kenh14.vn/video-316174.chn',
40 'md5': '2b41877d2afaf4a3f487ceda8e5c7cbd',
44 'title': 'Khoảnh khắc VĐV nằm gục khóc sau chiến thắng: 7 năm trời Việt Nam mới có HCV kiếm chém nữ, chỉ có 8 tháng để khổ luyện trước khi lên sàn đấu',
45 'description': 'md5:de86aa22e143e2b277bce8ec9c6f17dc',
46 'thumbnail': r
're:^https?://videothumbs\.mediacdn\.vn/.*\.jpg$',
48 'upload_date': '20220517',
51 'timestamp': 1652766021,
54 'url': 'https://video.kenh14.vn/0-344740.chn',
55 'md5': 'b843495d5e728142c8870c09b46df2a9',
59 'title': 'Kỳ Duyên đầy căng thẳng trong buổi ra quân đi Miss Universe, nghi thức tuyên thuệ lần đầu xuất hiện gây nhiều tranh cãi',
60 'description': 'md5:2a2dbb4a7397169fb21ee68f09160497',
61 'thumbnail': r
're:^https?://kenh14cdn\.com/.*\.jpg$',
62 'tags': ['kỳ duyên', 'Kỳ Duyên tuyên thuệ', 'miss universe'],
63 'uploader': 'Quang Vũ',
64 'upload_date': '20241024',
67 'timestamp': 1729741590,
71 def _real_extract(self
, url
):
72 video_id
= self
._match
_id
(url
)
73 webpage
= self
._download
_webpage
(url
, video_id
)
75 attrs
= extract_attributes(get_element_html_by_attribute('type', 'VideoStream', webpage
) or '')
76 direct_url
= attrs
['data-vid']
78 metadata
= self
._download
_json
(
79 'https://api.kinghub.vn/video/api/v1/detailVideoByGet?FileName={}'.format(
80 remove_start(direct_url
, 'kenh14cdn.com/')), video_id
, fatal
=False)
82 formats
= [{'url': f
'https://{direct_url}', 'format_id': 'http', 'quality': 1}]
84 video_data
= self
._download
_json
(
85 f
'https://{direct_url}.json', video_id
, note
='Downloading video data', fatal
=False)
86 if hls_url
:= traverse_obj(video_data
, ('hls', {url_or_none}
)):
87 fmts
, subs
= self
._extract
_m
3u8_formats
_and
_subtitles
(
88 hls_url
, video_id
, m3u8_id
='hls', fatal
=False)
90 self
._merge
_subtitles
(subs
, target
=subtitles
)
91 if dash_url
:= traverse_obj(video_data
, ('mpd', {url_or_none}
)):
92 fmts
, subs
= self
._extract
_mpd
_formats
_and
_subtitles
(
93 dash_url
, video_id
, mpd_id
='dash', fatal
=False)
95 self
._merge
_subtitles
(subs
, target
=subtitles
)
98 **traverse_obj(metadata
, {
99 'duration': ('duration', {parse_duration}
),
100 'uploader': ('author', {strip_or_none}
),
101 'timestamp': ('uploadtime', {parse_iso8601(delimiter
=' ')}),
102 'view_count': ('views', {int_or_none}
),
106 traverse_obj(metadata
, ('title', {strip_or_none}
))
107 or clean_html(self
._og
_search
_title
(webpage
))
108 or clean_html(get_element_by_class('vdbw-title', webpage
))),
110 'subtitles': subtitles
,
112 clean_html(self
._og
_search
_description
(webpage
))
113 or clean_html(get_element_by_class('vdbw-sapo', webpage
))),
114 'thumbnail': (self
._og
_search
_thumbnail
(webpage
) or attrs
.get('data-thumb')),
115 'tags': traverse_obj(self
._html
_search
_meta
('keywords', webpage
), (
116 {lambda x
: x
.split(';')}, ..., filter)),
120 class Kenh14PlaylistIE(InfoExtractor
):
121 _VALID_URL
= r
'https?://video\.kenh14\.vn/playlist/[\w-]+-(?P<id>[0-9]+)\.chn'
123 'url': 'https://video.kenh14.vn/playlist/tran-tinh-naked-love-mua-2-71.chn',
126 'title': 'Trần Tình (Naked love) mùa 2',
127 'description': 'md5:e9522339304956dea931722dd72eddb2',
128 'thumbnail': r
're:^https?://kenh14cdn\.com/.*\.png$',
132 'url': 'https://video.kenh14.vn/playlist/0-72.chn',
135 'title': 'Lau Lại Đầu Từ',
136 'description': 'Cùng xem xưa và nay có gì khác biệt nhé!',
137 'thumbnail': r
're:^https?://kenh14cdn\.com/.*\.png$',
142 def _real_extract(self
, url
):
143 playlist_id
= self
._match
_id
(url
)
144 webpage
= self
._download
_webpage
(url
, playlist_id
)
146 category_detail
= get_element_by_class('category-detail', webpage
) or ''
147 embed_info
= traverse_obj(
148 self
._yield
_json
_ld
(webpage
, playlist_id
),
149 (lambda _
, v
: v
['name'] and v
['alternateName'], any
)) or {}
151 return self
.playlist_from_matches(
152 get_elements_html_by_class('video-item', webpage
), playlist_id
,
153 (clean_html(get_element_by_class('name', category_detail
)) or unescapeHTML(embed_info
.get('name'))),
154 getter
=lambda x
: 'https://video.kenh14.vn/video/video-{}.chn'.format(extract_attributes(x
)['data-id']),
155 ie
=Kenh14VideoIE
, playlist_description
=(
156 clean_html(get_element_by_class('description', category_detail
))
157 or unescapeHTML(embed_info
.get('alternateName'))),
158 thumbnail
=traverse_obj(
159 self
._og
_search
_thumbnail
(webpage
),
160 ({url_or_none}
, {update_url(query
=None)})))