1 from __future__ import unicode_literals
3 from .common import InfoExtractor
4 from ..utils import ExtractorError
7 class NhkVodIE(InfoExtractor):
8 _VALID_URL = r'https?://www3\.nhk\.or\.jp/nhkworld/en/(?:vod|ondemand)/(?P<id>[^/]+/[^/?#&]+)'
10 # Videos available only for a limited period of time. Visit
11 # http://www3.nhk.or.jp/nhkworld/en/vod/ for working samples.
12 'url': 'http://www3.nhk.or.jp/nhkworld/en/vod/tokyofashion/20160815',
14 'id': 'A1bnNiNTE6nY3jLllS-BIISfcC_PpvF5',
16 'title': 'TOKYO FASHION EXPRESS - The Kimono as Global Fashion',
17 'description': 'md5:db338ee6ce8204f415b754782f819824',
18 'series': 'TOKYO FASHION EXPRESS',
19 'episode': 'The Kimono as Global Fashion',
21 'skip': 'Videos available only for a limited period of time',
23 'url': 'https://www3.nhk.or.jp/nhkworld/en/ondemand/video/2015173/',
24 'only_matching': True,
26 _API_URL = 'http://api.nhk.or.jp/nhkworld/vodesdlist/v1/all/all/all.json?apikey=EJfK8jdS57GqlupFgAfAAwr573q01y6k'
28 def _real_extract(self, url):
29 video_id = self._match_id(url)
31 data = self._download_json(self._API_URL, video_id)
35 e for e in data['data']['episodes']
36 if e.get('url') and video_id in e['url'])
38 raise ExtractorError('Unable to find episode')
40 embed_code = episode['vod_id']
42 title = episode.get('sub_title_clean') or episode['sub_title']
43 description = episode.get('description_clean') or episode.get('description')
44 series = episode.get('title_clean') or episode.get('title')
47 '_type': 'url_transparent',
49 'url': 'ooyala:%s' % embed_code,
50 'title': '%s - %s' % (series, title) if series and title else title,
51 'description': description,