ntvcojp.py (1939B)
1 # coding: utf-8 2 from __future__ import unicode_literals 3 4 from .common import InfoExtractor 5 from ..utils import ( 6 js_to_json, 7 smuggle_url, 8 ) 9 10 11 class NTVCoJpCUIE(InfoExtractor): 12 IE_NAME = 'cu.ntv.co.jp' 13 IE_DESC = 'Nippon Television Network' 14 _VALID_URL = r'https?://cu\.ntv\.co\.jp/(?!program)(?P<id>[^/?&#]+)' 15 _TEST = { 16 'url': 'https://cu.ntv.co.jp/televiva-chill-gohan_181031/', 17 'info_dict': { 18 'id': '5978891207001', 19 'ext': 'mp4', 20 'title': '桜エビと炒り卵がポイント! 「中華風 エビチリおにぎり」──『美虎』五十嵐美幸', 21 'upload_date': '20181213', 22 'description': 'md5:211b52f4fd60f3e0e72b68b0c6ba52a9', 23 'uploader_id': '3855502814001', 24 'timestamp': 1544669941, 25 }, 26 'params': { 27 # m3u8 download 28 'skip_download': True, 29 }, 30 } 31 BRIGHTCOVE_URL_TEMPLATE = 'http://players.brightcove.net/%s/default_default/index.html?videoId=%s' 32 33 def _real_extract(self, url): 34 display_id = self._match_id(url) 35 webpage = self._download_webpage(url, display_id) 36 player_config = self._parse_json(self._search_regex( 37 r'(?s)PLAYER_CONFIG\s*=\s*({.+?})', 38 webpage, 'player config'), display_id, js_to_json) 39 video_id = player_config['videoId'] 40 account_id = player_config.get('account') or '3855502814001' 41 return { 42 '_type': 'url_transparent', 43 'id': video_id, 44 'display_id': display_id, 45 'title': self._search_regex(r'<h1[^>]+class="title"[^>]*>([^<]+)', webpage, 'title').strip(), 46 'description': self._html_search_meta(['description', 'og:description'], webpage), 47 'url': smuggle_url(self.BRIGHTCOVE_URL_TEMPLATE % (account_id, video_id), {'geo_countries': ['JP']}), 48 'ie_key': 'BrightcoveNew', 49 }