- video_id = self._match_id(url)
-
- webpage = self._download_webpage(url, video_id)
-
- embed_code = self._search_regex(
- r'nw_vod_ooplayer\([^,]+,\s*(["\'])(?P<id>(?:(?!\1).)+)\1',
- webpage, 'ooyala embed code', group='id')
-
- title = self._search_regex(
- r'<div[^>]+class=["\']episode-detail["\']>\s*<h\d+>([^<]+)',
- webpage, 'title', default=None)
- description = self._html_search_regex(
- r'(?s)<p[^>]+class=["\']description["\'][^>]*>(.+?)</p>',
- webpage, 'description', default=None)
- series = self._search_regex(
- r'<h2[^>]+class=["\']detail-top-player-title[^>]+><a[^>]+>([^<]+)',
- webpage, 'series', default=None)
-
- return {
- '_type': 'url_transparent',
- 'ie_key': 'Ooyala',
- 'url': 'ooyala:%s' % embed_code,
+ lang, m_type, episode_id = re.match(self._VALID_URL, url).groups()
+ if episode_id.isdigit():
+ episode_id = episode_id[:4] + '-' + episode_id[4:]
+
+ is_video = m_type == 'video'
+ episode = self._download_json(
+ self._API_URL_TEMPLATE % (
+ 'v' if is_video else 'r',
+ 'clip' if episode_id[:4] == '9999' else 'esd',
+ episode_id, lang, '/all' if is_video else ''),
+ episode_id, query={'apikey': 'EJfK8jdS57GqlupFgAfAAwr573q01y6k'})['data']['episodes'][0]
+ title = episode.get('sub_title_clean') or episode['sub_title']
+
+ def get_clean_field(key):
+ return episode.get(key + '_clean') or episode.get(key)
+
+ series = get_clean_field('title')
+
+ thumbnails = []
+ for s, w, h in [('', 640, 360), ('_l', 1280, 720)]:
+ img_path = episode.get('image' + s)
+ if not img_path:
+ continue
+ thumbnails.append({
+ 'id': '%dp' % h,
+ 'height': h,
+ 'width': w,
+ 'url': 'https://www3.nhk.or.jp' + img_path,
+ })
+
+ info = {
+ 'id': episode_id + '-' + lang,