]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/msn.py
650731fdc3617fd8b9680ee97e40b8dfefc7c4e4
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
7 from ..compat
import compat_str
16 class MSNIE(InfoExtractor
):
17 _VALID_URL
= r
'https?://(?:www\.)?msn\.com/(?:[^/]+/)+(?P<display_id>[^/]+)/[a-z]{2}-(?P<id>[\da-zA-Z]+)'
19 'url': 'http://www.msn.com/en-ae/foodanddrink/joinourtable/criminal-minds-shemar-moore-shares-a-touching-goodbye-message/vp-BBqQYNE',
20 'md5': '8442f66c116cbab1ff7098f986983458',
23 'display_id': 'criminal-minds-shemar-moore-shares-a-touching-goodbye-message',
25 'title': 'Criminal Minds - Shemar Moore Shares A Touching Goodbye Message',
26 'description': 'md5:e8e89b897b222eb33a6b5067a8f1bc25',
28 'uploader': 'CBS Entertainment',
29 'uploader_id': 'IT0X5aoJ6bJgYerJXSDCgFmYPB1__54v',
32 'url': 'http://www.msn.com/en-ae/news/offbeat/meet-the-nine-year-old-self-made-millionaire/ar-BBt6ZKf',
33 'only_matching': True,
35 'url': 'http://www.msn.com/en-ae/video/watch/obama-a-lot-of-people-will-be-disappointed/vi-AAhxUMH',
36 'only_matching': True,
39 'url': 'http://www.msn.com/en-ae/foodanddrink/joinourtable/the-first-fart-makes-you-laugh-the-last-fart-makes-you-cry/vp-AAhzIBU',
40 'only_matching': True,
42 'url': 'http://www.msn.com/en-ae/entertainment/bollywood/watch-how-salman-khan-reacted-when-asked-if-he-would-apologize-for-his-‘raped-woman’-comment/vi-AAhvzW6',
43 'only_matching': True,
46 def _real_extract(self
, url
):
47 mobj
= re
.match(self
._VALID
_URL
, url
)
48 video_id
, display_id
= mobj
.group('id', 'display_id')
50 webpage
= self
._download
_webpage
(url
, display_id
)
52 video
= self
._parse
_json
(
54 r
'data-metadata\s*=\s*(["\'])(?P
<data
>.+?
)\
1',
55 webpage, 'video data
', default='{}', group='data
'),
56 display_id, transform_source=unescapeHTML)
59 error = unescapeHTML(self._search_regex(
60 r'data
-error
=(["\'])(?P<error>.+?)\1',
61 webpage, 'error', group='error'))
62 raise ExtractorError('%s said: %s' % (self.IE_NAME, error), expected=True)
64 title = video['title']
67 for file_ in video.get('videoFiles', []):
68 format_url = file_.get('url')
71 if 'm3u8' in format_url:
72 # m3u8_native should not be used here until
73 # https://github.com/rg3/youtube-dl/issues/9913 is fixed
74 m3u8_formats = self._extract_m3u8_formats(
75 format_url, display_id, 'mp4',
76 m3u8_id='hls', fatal=False)
77 formats.extend(m3u8_formats)
78 elif determine_ext(format_url) == 'ism':
79 formats.extend(self._extract_ism_formats(
80 format_url + '/Manifest', display_id, 'mss', fatal=False))
86 'width': int_or_none(file_.get('width')),
87 'height': int_or_none(file_.get('height')),
89 self._sort_formats(formats)
92 for file_ in video.get('files', []):
93 format_url = file_.get('url')
94 format_code = file_.get('formatCode')
95 if not format_url or not format_code:
97 if compat_str(format_code) == '3100':
98 subtitles.setdefault(file_.get('culture', 'en'), []).append({
99 'ext': determine_ext(format_url, 'ttml'),
105 'display_id': display_id,
107 'description': video.get('description'),
108 'thumbnail': video.get('headlineImage', {}).get('url'),
109 'duration': int_or_none(video.get('durationSecs')),
110 'uploader': video.get('sourceFriendly'),
111 'uploader_id': video.get('providerId'),
112 'creator': video.get('creator'),
113 'subtitles': subtitles,