[msn] improve extraction
- add support for YouTube and NBCSports embeds - add support for aricles with multiple videos - improve AOL embed support - improve format extraction
This commit is contained in:
parent
88a7a9089a
commit
c0b1e01330
1 changed files with 119 additions and 83 deletions
|
@ -14,20 +14,27 @@ from ..utils import (
|
||||||
|
|
||||||
|
|
||||||
class MSNIE(InfoExtractor):
|
class MSNIE(InfoExtractor):
|
||||||
_VALID_URL = r'https?://(?:www\.)?msn\.com/(?:[^/]+/)+(?P<display_id>[^/]+)/[a-z]{2}-(?P<id>[\da-zA-Z]+)'
|
_VALID_URL = r'https?://(?:(?:www|preview)\.)?msn\.com/(?:[^/]+/)+(?P<display_id>[^/]+)/[a-z]{2}-(?P<id>[\da-zA-Z]+)'
|
||||||
_TESTS = [{
|
_TESTS = [{
|
||||||
'url': 'http://www.msn.com/en-ae/foodanddrink/joinourtable/criminal-minds-shemar-moore-shares-a-touching-goodbye-message/vp-BBqQYNE',
|
'url': 'https://www.msn.com/en-in/money/video/7-ways-to-get-rid-of-chest-congestion/vi-BBPxU6d',
|
||||||
'md5': '8442f66c116cbab1ff7098f986983458',
|
'md5': '087548191d273c5c55d05028f8d2cbcd',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': 'BBqQYNE',
|
'id': 'BBPxU6d',
|
||||||
'display_id': 'criminal-minds-shemar-moore-shares-a-touching-goodbye-message',
|
'display_id': '7-ways-to-get-rid-of-chest-congestion',
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
'title': 'Criminal Minds - Shemar Moore Shares A Touching Goodbye Message',
|
'title': 'Seven ways to get rid of chest congestion',
|
||||||
'description': 'md5:e8e89b897b222eb33a6b5067a8f1bc25',
|
'description': '7 Ways to Get Rid of Chest Congestion',
|
||||||
'duration': 104,
|
'duration': 88,
|
||||||
'uploader': 'CBS Entertainment',
|
'uploader': 'Health',
|
||||||
'uploader_id': 'IT0X5aoJ6bJgYerJXSDCgFmYPB1__54v',
|
'uploader_id': 'BBPrMqa',
|
||||||
},
|
},
|
||||||
|
}, {
|
||||||
|
# Article, multiple Dailymotion Embeds
|
||||||
|
'url': 'https://www.msn.com/en-in/money/sports/hottest-football-wags-greatest-footballers-turned-managers-and-more/ar-BBpc7Nl',
|
||||||
|
'info_dict': {
|
||||||
|
'id': 'BBpc7Nl',
|
||||||
|
},
|
||||||
|
'playlist_mincount': 4,
|
||||||
}, {
|
}, {
|
||||||
'url': 'http://www.msn.com/en-ae/news/offbeat/meet-the-nine-year-old-self-made-millionaire/ar-BBt6ZKf',
|
'url': 'http://www.msn.com/en-ae/news/offbeat/meet-the-nine-year-old-self-made-millionaire/ar-BBt6ZKf',
|
||||||
'only_matching': True,
|
'only_matching': True,
|
||||||
|
@ -43,44 +50,58 @@ class MSNIE(InfoExtractor):
|
||||||
'only_matching': True,
|
'only_matching': True,
|
||||||
}, {
|
}, {
|
||||||
# Vidible(AOL) Embed
|
# Vidible(AOL) Embed
|
||||||
'url': 'https://www.msn.com/en-us/video/animals/yellowstone-park-staffers-catch-deer-engaged-in-behavior-they-cant-explain/vi-AAGfdg1',
|
'url': 'https://www.msn.com/en-us/money/other/jupiter-is-about-to-come-so-close-you-can-see-its-moons-with-binoculars/vi-AACqsHR',
|
||||||
'only_matching': True,
|
'only_matching': True,
|
||||||
}, {
|
}, {
|
||||||
# Dailymotion Embed
|
# Dailymotion Embed
|
||||||
'url': 'https://www.msn.com/es-ve/entretenimiento/watch/winston-salem-paire-refait-des-siennes-en-perdant-sa-raquette-au-service/vp-AAG704L',
|
'url': 'https://www.msn.com/es-ve/entretenimiento/watch/winston-salem-paire-refait-des-siennes-en-perdant-sa-raquette-au-service/vp-AAG704L',
|
||||||
'only_matching': True,
|
'only_matching': True,
|
||||||
|
}, {
|
||||||
|
# YouTube Embed
|
||||||
|
'url': 'https://www.msn.com/en-in/money/news/meet-vikram-%E2%80%94-chandrayaan-2s-lander/vi-AAGUr0v',
|
||||||
|
'only_matching': True,
|
||||||
|
}, {
|
||||||
|
# NBCSports Embed
|
||||||
|
'url': 'https://www.msn.com/en-us/money/football_nfl/week-13-preview-redskins-vs-panthers/vi-BBXsCDb',
|
||||||
|
'only_matching': True,
|
||||||
}]
|
}]
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
mobj = re.match(self._VALID_URL, url)
|
display_id, page_id = re.match(self._VALID_URL, url).groups()
|
||||||
video_id, display_id = mobj.group('id', 'display_id')
|
|
||||||
|
|
||||||
webpage = self._download_webpage(url, display_id)
|
webpage = self._download_webpage(url, display_id)
|
||||||
|
|
||||||
video = self._parse_json(
|
entries = []
|
||||||
self._search_regex(
|
for _, metadata in re.findall(r'data-metadata\s*=\s*(["\'])(?P<data>.+?)\1', webpage):
|
||||||
r'data-metadata\s*=\s*(["\'])(?P<data>.+?)\1',
|
video = self._parse_json(unescapeHTML(metadata), display_id)
|
||||||
webpage, 'video data', default='{}', group='data'),
|
|
||||||
display_id, transform_source=unescapeHTML)
|
|
||||||
|
|
||||||
if not video:
|
|
||||||
error = unescapeHTML(self._search_regex(
|
|
||||||
r'data-error=(["\'])(?P<error>.+?)\1',
|
|
||||||
webpage, 'error', group='error'))
|
|
||||||
raise ExtractorError('%s said: %s' % (self.IE_NAME, error), expected=True)
|
|
||||||
|
|
||||||
player_name = video.get('playerName')
|
|
||||||
if player_name:
|
|
||||||
provider_id = video.get('providerId')
|
provider_id = video.get('providerId')
|
||||||
if provider_id:
|
player_name = video.get('playerName')
|
||||||
|
if player_name and provider_id:
|
||||||
|
entry = None
|
||||||
if player_name == 'AOL':
|
if player_name == 'AOL':
|
||||||
return self.url_result(
|
if provider_id.startswith('http'):
|
||||||
|
provider_id = self._search_regex(
|
||||||
|
r'https?://delivery\.vidible\.tv/video/redirect/([0-9a-f]{24})',
|
||||||
|
provider_id, 'vidible id')
|
||||||
|
entry = self.url_result(
|
||||||
'aol-video:' + provider_id, 'Aol', provider_id)
|
'aol-video:' + provider_id, 'Aol', provider_id)
|
||||||
elif player_name == 'Dailymotion':
|
elif player_name == 'Dailymotion':
|
||||||
return self.url_result(
|
entry = self.url_result(
|
||||||
'https://www.dailymotion.com/video/' + provider_id,
|
'https://www.dailymotion.com/video/' + provider_id,
|
||||||
'Dailymotion', provider_id)
|
'Dailymotion', provider_id)
|
||||||
|
elif player_name == 'YouTube':
|
||||||
|
entry = self.url_result(
|
||||||
|
provider_id, 'Youtube', provider_id)
|
||||||
|
elif player_name == 'NBCSports':
|
||||||
|
entry = self.url_result(
|
||||||
|
'http://vplayer.nbcsports.com/p/BxmELC/nbcsports_embed/select/media/' + provider_id,
|
||||||
|
'NBCSportsVPlayer', provider_id)
|
||||||
|
if entry:
|
||||||
|
entries.append(entry)
|
||||||
|
continue
|
||||||
|
|
||||||
|
video_id = video['uuid']
|
||||||
title = video['title']
|
title = video['title']
|
||||||
|
|
||||||
formats = []
|
formats = []
|
||||||
|
@ -88,23 +109,30 @@ class MSNIE(InfoExtractor):
|
||||||
format_url = file_.get('url')
|
format_url = file_.get('url')
|
||||||
if not format_url:
|
if not format_url:
|
||||||
continue
|
continue
|
||||||
if 'm3u8' in format_url:
|
if 'format=m3u8-aapl' in format_url:
|
||||||
# m3u8_native should not be used here until
|
# m3u8_native should not be used here until
|
||||||
# https://github.com/ytdl-org/youtube-dl/issues/9913 is fixed
|
# https://github.com/ytdl-org/youtube-dl/issues/9913 is fixed
|
||||||
m3u8_formats = self._extract_m3u8_formats(
|
formats.extend(self._extract_m3u8_formats(
|
||||||
format_url, display_id, 'mp4',
|
format_url, display_id, 'mp4',
|
||||||
m3u8_id='hls', fatal=False)
|
m3u8_id='hls', fatal=False))
|
||||||
formats.extend(m3u8_formats)
|
elif 'format=mpd-time-csf' in format_url:
|
||||||
elif determine_ext(format_url) == 'ism':
|
formats.extend(self._extract_mpd_formats(
|
||||||
|
format_url, display_id, 'dash', fatal=False))
|
||||||
|
elif '.ism' in format_url:
|
||||||
|
if format_url.endswith('.ism'):
|
||||||
|
format_url += '/manifest'
|
||||||
formats.extend(self._extract_ism_formats(
|
formats.extend(self._extract_ism_formats(
|
||||||
format_url + '/Manifest', display_id, 'mss', fatal=False))
|
format_url, display_id, 'mss', fatal=False))
|
||||||
else:
|
else:
|
||||||
|
format_id = file_.get('formatCode')
|
||||||
formats.append({
|
formats.append({
|
||||||
'url': format_url,
|
'url': format_url,
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
'format_id': 'http',
|
'format_id': format_id,
|
||||||
'width': int_or_none(file_.get('width')),
|
'width': int_or_none(file_.get('width')),
|
||||||
'height': int_or_none(file_.get('height')),
|
'height': int_or_none(file_.get('height')),
|
||||||
|
'vbr': int_or_none(self._search_regex(r'_(\d+)\.mp4', format_url, 'vbr', default=None)),
|
||||||
|
'preference': 1 if format_id == '1001' else None,
|
||||||
})
|
})
|
||||||
self._sort_formats(formats)
|
self._sort_formats(formats)
|
||||||
|
|
||||||
|
@ -120,7 +148,7 @@ class MSNIE(InfoExtractor):
|
||||||
'url': format_url,
|
'url': format_url,
|
||||||
})
|
})
|
||||||
|
|
||||||
return {
|
entries.append({
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
'display_id': display_id,
|
'display_id': display_id,
|
||||||
'title': title,
|
'title': title,
|
||||||
|
@ -132,4 +160,12 @@ class MSNIE(InfoExtractor):
|
||||||
'creator': video.get('creator'),
|
'creator': video.get('creator'),
|
||||||
'subtitles': subtitles,
|
'subtitles': subtitles,
|
||||||
'formats': formats,
|
'formats': formats,
|
||||||
}
|
})
|
||||||
|
|
||||||
|
if not entries:
|
||||||
|
error = unescapeHTML(self._search_regex(
|
||||||
|
r'data-error=(["\'])(?P<error>.+?)\1',
|
||||||
|
webpage, 'error', group='error'))
|
||||||
|
raise ExtractorError('%s said: %s' % (self.IE_NAME, error), expected=True)
|
||||||
|
|
||||||
|
return self.playlist_result(entries, page_id)
|
||||||
|
|
Loading…
Reference in a new issue