mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-06 13:07:07 +01:00
[usatoday] fix extraction for videos with custom brightcove partner id(closes #18990)
This commit is contained in:
parent
1602a240a7
commit
ae18d58297
@ -3,21 +3,23 @@
|
|||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
|
ExtractorError,
|
||||||
get_element_by_attribute,
|
get_element_by_attribute,
|
||||||
parse_duration,
|
parse_duration,
|
||||||
|
try_get,
|
||||||
update_url_query,
|
update_url_query,
|
||||||
ExtractorError,
|
|
||||||
)
|
)
|
||||||
from ..compat import compat_str
|
from ..compat import compat_str
|
||||||
|
|
||||||
|
|
||||||
class USATodayIE(InfoExtractor):
|
class USATodayIE(InfoExtractor):
|
||||||
_VALID_URL = r'https?://(?:www\.)?usatoday\.com/(?:[^/]+/)*(?P<id>[^?/#]+)'
|
_VALID_URL = r'https?://(?:www\.)?usatoday\.com/(?:[^/]+/)*(?P<id>[^?/#]+)'
|
||||||
_TEST = {
|
_TESTS = [{
|
||||||
|
# Brightcove Partner ID = 29906170001
|
||||||
'url': 'http://www.usatoday.com/media/cinematic/video/81729424/us-france-warn-syrian-regime-ahead-of-new-peace-talks/',
|
'url': 'http://www.usatoday.com/media/cinematic/video/81729424/us-france-warn-syrian-regime-ahead-of-new-peace-talks/',
|
||||||
'md5': '4d40974481fa3475f8bccfd20c5361f8',
|
'md5': '033587d2529dc3411a1ab3644c3b8827',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': '81729424',
|
'id': '4799374959001',
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
'title': 'US, France warn Syrian regime ahead of new peace talks',
|
'title': 'US, France warn Syrian regime ahead of new peace talks',
|
||||||
'timestamp': 1457891045,
|
'timestamp': 1457891045,
|
||||||
@ -25,8 +27,20 @@ class USATodayIE(InfoExtractor):
|
|||||||
'uploader_id': '29906170001',
|
'uploader_id': '29906170001',
|
||||||
'upload_date': '20160313',
|
'upload_date': '20160313',
|
||||||
}
|
}
|
||||||
|
}, {
|
||||||
|
# ui-video-data[asset_metadata][items][brightcoveaccount] = 28911775001
|
||||||
|
'url': 'https://www.usatoday.com/story/tech/science/2018/08/21/yellowstone-supervolcano-eruption-stop-worrying-its-blow/973633002/',
|
||||||
|
'info_dict': {
|
||||||
|
'id': '5824495846001',
|
||||||
|
'ext': 'mp4',
|
||||||
|
'title': 'Yellowstone more likely to crack rather than explode',
|
||||||
|
'timestamp': 1534790612,
|
||||||
|
'description': 'md5:3715e7927639a4f16b474e9391687c62',
|
||||||
|
'uploader_id': '28911775001',
|
||||||
|
'upload_date': '20180820',
|
||||||
}
|
}
|
||||||
BRIGHTCOVE_URL_TEMPLATE = 'http://players.brightcove.net/29906170001/38a9eecc-bdd8-42a3-ba14-95397e48b3f8_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)
|
||||||
@ -35,10 +49,11 @@ def _real_extract(self, url):
|
|||||||
if not ui_video_data:
|
if not ui_video_data:
|
||||||
raise ExtractorError('no video on the webpage', expected=True)
|
raise ExtractorError('no video on the webpage', expected=True)
|
||||||
video_data = self._parse_json(ui_video_data, display_id)
|
video_data = self._parse_json(ui_video_data, display_id)
|
||||||
|
item = try_get(video_data, lambda x: x['asset_metadata']['items'], dict) or {}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'_type': 'url_transparent',
|
'_type': 'url_transparent',
|
||||||
'url': self.BRIGHTCOVE_URL_TEMPLATE % video_data['brightcove_id'],
|
'url': self.BRIGHTCOVE_URL_TEMPLATE % (item.get('brightcoveaccount', '29906170001'), item.get('brightcoveid') or video_data['brightcove_id']),
|
||||||
'id': compat_str(video_data['id']),
|
'id': compat_str(video_data['id']),
|
||||||
'title': video_data['title'],
|
'title': video_data['title'],
|
||||||
'thumbnail': video_data.get('thumbnail'),
|
'thumbnail': video_data.get('thumbnail'),
|
||||||
|
Loading…
Reference in New Issue
Block a user