]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/nhk.py
Update changelog.
[youtubedl] / youtube_dl / extractor / nhk.py
1 from __future__ import unicode_literals
2
3 from .common import InfoExtractor
4 from ..utils import ExtractorError
5
6
7 class NhkVodIE(InfoExtractor):
8 _VALID_URL = r'https?://www3\.nhk\.or\.jp/nhkworld/en/vod/(?P<id>[^/]+/[^/?#&]+)'
9 _TEST = {
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',
13 'info_dict': {
14 'id': 'A1bnNiNTE6nY3jLllS-BIISfcC_PpvF5',
15 'ext': 'flv',
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',
20 },
21 'skip': 'Videos available only for a limited period of time',
22 }
23 _API_URL = 'http://api.nhk.or.jp/nhkworld/vodesdlist/v1/all/all/all.json?apikey=EJfK8jdS57GqlupFgAfAAwr573q01y6k'
24
25 def _real_extract(self, url):
26 video_id = self._match_id(url)
27
28 data = self._download_json(self._API_URL, video_id)
29
30 try:
31 episode = next(
32 e for e in data['data']['episodes']
33 if e.get('url') and video_id in e['url'])
34 except StopIteration:
35 raise ExtractorError('Unable to find episode')
36
37 embed_code = episode['vod_id']
38
39 title = episode.get('sub_title_clean') or episode['sub_title']
40 description = episode.get('description_clean') or episode.get('description')
41 series = episode.get('title_clean') or episode.get('title')
42
43 return {
44 '_type': 'url_transparent',
45 'ie_key': 'Ooyala',
46 'url': 'ooyala:%s' % embed_code,
47 'title': '%s - %s' % (series, title) if series and title else title,
48 'description': description,
49 'series': series,
50 'episode': title,
51 }