mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2025-01-31 18:39:42 +00:00
[ntvcojp] Extract NUXT data (#1915)
Fixes: https://github.com/ytdl-org/youtube-dl/issues/30309 Authored by: nao20010128nao
This commit is contained in:
parent
443b21dc4e
commit
ddd24c9949
@ -3,8 +3,9 @@
|
|||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
js_to_json,
|
ExtractorError,
|
||||||
smuggle_url,
|
smuggle_url,
|
||||||
|
traverse_obj,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -19,7 +20,7 @@ class NTVCoJpCUIE(InfoExtractor):
|
|||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
'title': '桜エビと炒り卵がポイント! 「中華風 エビチリおにぎり」──『美虎』五十嵐美幸',
|
'title': '桜エビと炒り卵がポイント! 「中華風 エビチリおにぎり」──『美虎』五十嵐美幸',
|
||||||
'upload_date': '20181213',
|
'upload_date': '20181213',
|
||||||
'description': 'md5:211b52f4fd60f3e0e72b68b0c6ba52a9',
|
'description': 'md5:1985b51a9abc285df0104d982a325f2a',
|
||||||
'uploader_id': '3855502814001',
|
'uploader_id': '3855502814001',
|
||||||
'timestamp': 1544669941,
|
'timestamp': 1544669941,
|
||||||
},
|
},
|
||||||
@ -28,22 +29,30 @@ class NTVCoJpCUIE(InfoExtractor):
|
|||||||
'skip_download': True,
|
'skip_download': True,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
BRIGHTCOVE_URL_TEMPLATE = 'http://players.brightcove.net/%s/default_default/index.html?videoId=%s'
|
BRIGHTCOVE_URL_TEMPLATE = 'http://players.brightcove.net/%s/default_default/index.html?videoId=%s'
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
display_id = self._match_id(url)
|
display_id = self._match_id(url)
|
||||||
webpage = self._download_webpage(url, display_id)
|
webpage = self._download_webpage(url, display_id)
|
||||||
player_config = self._parse_json(self._search_regex(
|
player_config = self._search_nuxt_data(webpage, display_id)
|
||||||
r'(?s)PLAYER_CONFIG\s*=\s*({.+?})',
|
video_id = traverse_obj(player_config, ('movie', 'video_id'))
|
||||||
webpage, 'player config'), display_id, js_to_json)
|
if not video_id:
|
||||||
video_id = player_config['videoId']
|
raise ExtractorError('Failed to extract video ID for Brightcove')
|
||||||
account_id = player_config.get('account') or '3855502814001'
|
account_id = traverse_obj(player_config, ('player', 'account')) or '3855502814001'
|
||||||
|
title = traverse_obj(player_config, ('movie', 'name'))
|
||||||
|
if not title:
|
||||||
|
og_title = self._og_search_title(webpage, fatal=False) or traverse_obj(player_config, ('player', 'title'))
|
||||||
|
if og_title:
|
||||||
|
title = og_title.split('(', 1)[0].strip()
|
||||||
|
description = (traverse_obj(player_config, ('movie', 'description'))
|
||||||
|
or self._html_search_meta(['description', 'og:description'], webpage))
|
||||||
return {
|
return {
|
||||||
'_type': 'url_transparent',
|
'_type': 'url_transparent',
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
'display_id': display_id,
|
'display_id': display_id,
|
||||||
'title': self._search_regex(r'<h1[^>]+class="title"[^>]*>([^<]+)', webpage, 'title').strip(),
|
'title': title,
|
||||||
'description': self._html_search_meta(['description', 'og:description'], webpage),
|
'description': description,
|
||||||
'url': smuggle_url(self.BRIGHTCOVE_URL_TEMPLATE % (account_id, video_id), {'geo_countries': ['JP']}),
|
'url': smuggle_url(self.BRIGHTCOVE_URL_TEMPLATE % (account_id, video_id), {'geo_countries': ['JP']}),
|
||||||
'ie_key': 'BrightcoveNew',
|
'ie_key': 'BrightcoveNew',
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user