Release 2024.12.06
[yt-dlp3.git] / yt_dlp / extractor / ntvcojp.py
blob422ec6eb02bee91987fe9ec87d695a31c58f2db3
1 from .common import InfoExtractor
2 from ..utils import (
3 ExtractorError,
4 smuggle_url,
5 traverse_obj,
9 class NTVCoJpCUIE(InfoExtractor):
10 IE_NAME = 'cu.ntv.co.jp'
11 IE_DESC = 'Nippon Television Network'
12 _VALID_URL = r'https?://cu\.ntv\.co\.jp/(?!program)(?P<id>[^/?&#]+)'
13 _TEST = {
14 'url': 'https://cu.ntv.co.jp/televiva-chill-gohan_181031/',
15 'info_dict': {
16 'id': '5978891207001',
17 'ext': 'mp4',
18 'title': '桜エビと炒り卵がポイント! 「中華風 エビチリおにぎり」──『美虎』五十嵐美幸',
19 'upload_date': '20181213',
20 'description': 'md5:1985b51a9abc285df0104d982a325f2a',
21 'uploader_id': '3855502814001',
22 'timestamp': 1544669941,
24 'params': {
25 # m3u8 download
26 'skip_download': True,
30 BRIGHTCOVE_URL_TEMPLATE = 'http://players.brightcove.net/%s/default_default/index.html?videoId=%s'
32 def _real_extract(self, url):
33 display_id = self._match_id(url)
34 webpage = self._download_webpage(url, display_id)
35 player_config = self._search_nuxt_data(webpage, display_id)
36 video_id = traverse_obj(player_config, ('movie', 'video_id'))
37 if not video_id:
38 raise ExtractorError('Failed to extract video ID for Brightcove')
39 account_id = traverse_obj(player_config, ('player', 'account')) or '3855502814001'
40 title = traverse_obj(player_config, ('movie', 'name'))
41 if not title:
42 og_title = self._og_search_title(webpage, fatal=False) or traverse_obj(player_config, ('player', 'title'))
43 if og_title:
44 title = og_title.split('(', 1)[0].strip()
45 description = (traverse_obj(player_config, ('movie', 'description'))
46 or self._html_search_meta(['description', 'og:description'], webpage))
47 return {
48 '_type': 'url_transparent',
49 'id': video_id,
50 'display_id': display_id,
51 'title': title,
52 'description': description,
53 'url': smuggle_url(self.BRIGHTCOVE_URL_TEMPLATE % (account_id, video_id), {'geo_countries': ['JP']}),
54 'ie_key': 'BrightcoveNew',