]>
Commit | Line | Data |
---|---|---|
298a120a AN |
1 | from __future__ import unicode_literals |
2 | ||
3 | from .common import InfoExtractor | |
45396dd2 | 4 | from ..utils import ExtractorError |
298a120a AN |
5 | |
6 | ||
7 | class NhkVodIE(InfoExtractor): | |
0eba178f S |
8 | _VALID_URL = r'https?://www3\.nhk\.or\.jp/nhkworld/en/(?:vod|ondemand)/(?P<id>[^/]+/[^/?#&]+)' |
9 | _TESTS = [{ | |
f9b373af S |
10 | # Videos available only for a limited period of time. Visit |
11 | # http://www3.nhk.or.jp/nhkworld/en/vod/ for working samples. | |
45396dd2 | 12 | 'url': 'http://www3.nhk.or.jp/nhkworld/en/vod/tokyofashion/20160815', |
298a120a AN |
13 | 'info_dict': { |
14 | 'id': 'A1bnNiNTE6nY3jLllS-BIISfcC_PpvF5', | |
15 | 'ext': 'flv', | |
f9b373af S |
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', | |
298a120a | 20 | }, |
f9b373af | 21 | 'skip': 'Videos available only for a limited period of time', |
0eba178f S |
22 | }, { |
23 | 'url': 'https://www3.nhk.or.jp/nhkworld/en/ondemand/video/2015173/', | |
24 | 'only_matching': True, | |
25 | }] | |
45396dd2 | 26 | _API_URL = 'http://api.nhk.or.jp/nhkworld/vodesdlist/v1/all/all/all.json?apikey=EJfK8jdS57GqlupFgAfAAwr573q01y6k' |
298a120a AN |
27 | |
28 | def _real_extract(self, url): | |
29 | video_id = self._match_id(url) | |
f9b373af | 30 | |
45396dd2 S |
31 | data = self._download_json(self._API_URL, video_id) |
32 | ||
33 | try: | |
34 | episode = next( | |
35 | e for e in data['data']['episodes'] | |
36 | if e.get('url') and video_id in e['url']) | |
37 | except StopIteration: | |
38 | raise ExtractorError('Unable to find episode') | |
39 | ||
40 | embed_code = episode['vod_id'] | |
41 | ||
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') | |
298a120a | 45 | |
f9b373af S |
46 | return { |
47 | '_type': 'url_transparent', | |
48 | 'ie_key': 'Ooyala', | |
49 | 'url': 'ooyala:%s' % embed_code, | |
50 | 'title': '%s - %s' % (series, title) if series and title else title, | |
51 | 'description': description, | |
52 | 'series': series, | |
53 | 'episode': title, | |
54 | } |