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