You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.9 KiB

  1. from __future__ import unicode_literals
  2. from .common import InfoExtractor
  3. from ..utils import ExtractorError
  4. class NhkVodIE(InfoExtractor):
  5. _VALID_URL = r'https?://www3\.nhk\.or\.jp/nhkworld/en/vod/(?P<id>[^/]+/[^/?#&]+)'
  6. _TEST = {
  7. # Videos available only for a limited period of time. Visit
  8. # http://www3.nhk.or.jp/nhkworld/en/vod/ for working samples.
  9. 'url': 'http://www3.nhk.or.jp/nhkworld/en/vod/tokyofashion/20160815',
  10. 'info_dict': {
  11. 'id': 'A1bnNiNTE6nY3jLllS-BIISfcC_PpvF5',
  12. 'ext': 'flv',
  13. 'title': 'TOKYO FASHION EXPRESS - The Kimono as Global Fashion',
  14. 'description': 'md5:db338ee6ce8204f415b754782f819824',
  15. 'series': 'TOKYO FASHION EXPRESS',
  16. 'episode': 'The Kimono as Global Fashion',
  17. },
  18. 'skip': 'Videos available only for a limited period of time',
  19. }
  20. _API_URL = 'http://api.nhk.or.jp/nhkworld/vodesdlist/v1/all/all/all.json?apikey=EJfK8jdS57GqlupFgAfAAwr573q01y6k'
  21. def _real_extract(self, url):
  22. video_id = self._match_id(url)
  23. data = self._download_json(self._API_URL, video_id)
  24. try:
  25. episode = next(
  26. e for e in data['data']['episodes']
  27. if e.get('url') and video_id in e['url'])
  28. except StopIteration:
  29. raise ExtractorError('Unable to find episode')
  30. embed_code = episode['vod_id']
  31. title = episode.get('sub_title_clean') or episode['sub_title']
  32. description = episode.get('description_clean') or episode.get('description')
  33. series = episode.get('title_clean') or episode.get('title')
  34. return {
  35. '_type': 'url_transparent',
  36. 'ie_key': 'Ooyala',
  37. 'url': 'ooyala:%s' % embed_code,
  38. 'title': '%s - %s' % (series, title) if series and title else title,
  39. 'description': description,
  40. 'series': series,
  41. 'episode': title,
  42. }