ntvcojp.py 2.2 KB

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