]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/nhk.py
6a2c6cb7bb6d039c56fcf7325de422846c437ab5
1 from __future__
import unicode_literals
5 from .common
import InfoExtractor
8 class NhkVodIE(InfoExtractor
):
9 _VALID_URL
= r
'https?://www3\.nhk\.or\.jp/nhkworld/(?P<lang>[a-z]{2})/ondemand/(?P<type>video|audio)/(?P<id>\d{7}|[a-z]+-\d{8}-\d+)'
10 # Content available only for a limited period of time. Visit
11 # https://www3.nhk.or.jp/nhkworld/en/ondemand/ for working samples.
14 'url': 'https://www3.nhk.or.jp/nhkworld/en/ondemand/video/9999011/',
15 'md5': '256a1be14f48d960a7e61e2532d95ec3',
19 'title': "Dining with the Chef - Chef Saito's Family recipe: MENCHI-KATSU",
20 'description': 'md5:5aee4a9f9d81c26281862382103b0ea5',
21 'timestamp': 1565965194,
22 'upload_date': '20190816',
25 'url': 'https://www3.nhk.or.jp/nhkworld/en/ondemand/video/2015173/',
26 'only_matching': True,
28 'url': 'https://www3.nhk.or.jp/nhkworld/en/ondemand/audio/plugin-20190404-1/',
29 'only_matching': True,
31 'url': 'https://www3.nhk.or.jp/nhkworld/fr/ondemand/audio/plugin-20190404-1/',
32 'only_matching': True,
34 _API_URL_TEMPLATE
= 'https://api.nhk.or.jp/nhkworld/%sod%slist/v7/episode/%s/%s/all%s.json'
36 def _real_extract(self
, url
):
37 lang
, m_type
, episode_id
= re
.match(self
._VALID
_URL
, url
).groups()
38 if episode_id
.isdigit():
39 episode_id
= episode_id
[:4] + '-' + episode_id
[4:]
41 is_video
= m_type
== 'video'
42 episode
= self
._download
_json
(
43 self
._API
_URL
_TEMPLATE
% (
44 'v' if is_video
else 'r',
45 'clip' if episode_id
[:4] == '9999' else 'esd',
46 episode_id
, lang
, '/all' if is_video
else ''),
47 episode_id
, query
={'apikey': 'EJfK8jdS57GqlupFgAfAAwr573q01y6k'})['data']['episodes'][0]
48 title
= episode
.get('sub_title_clean') or episode
['sub_title']
50 def get_clean_field(key
):
51 return episode
.get(key
+ '_clean') or episode
.get(key
)
53 series
= get_clean_field('title')
56 for s
, w
, h
in [('', 640, 360), ('_l', 1280, 720)]:
57 img_path
= episode
.get('image' + s
)
64 'url': 'https://www3.nhk.or.jp' + img_path
,
68 'id': episode_id
+ '-' + lang
,
69 'title': '%s - %s' % (series
, title
) if series
and title
else title
,
70 'description': get_clean_field('description'),
71 'thumbnails': thumbnails
,
77 '_type': 'url_transparent',
79 'url': 'https://player.piksel.com/v/refid/nhkworld/prefid/' + episode
['vod_id'],
82 audio
= episode
['audio']
83 audio_path
= audio
['audio']
84 info
['formats'] = self
._extract
_m
3u8_formats
(
85 'https://nhks-vh.akamaihd.net/i%s/master.m3u8' % audio_path
,
86 episode_id
, 'm4a', m3u8_id
='hls', fatal
=False)
87 for proto
in ('rtmpt', 'rtmp'):
88 info
['formats'].append({
91 'url': '%s://flv.nhk.or.jp/ondemand/mp4:flv%s' % (proto
, audio_path
),
94 for f
in info
['formats']: