2 from __future__ import unicode_literals
4 from .common import InfoExtractor
5 from .once import OnceIE
6 from ..compat import compat_urllib_parse_unquote
13 class VoxMediaVolumeIE(OnceIE):
14 _VALID_URL = r'https?://volume\.vox-cdn\.com/embed/(?P<id>[0-9a-f]{9})'
16 def _real_extract(self, url):
17 video_id = self._match_id(url)
18 webpage = self._download_webpage(url, video_id)
20 setup = self._parse_json(self._search_regex(
21 r'setup\s*=\s*({.+});', webpage, 'setup'), video_id)
22 video_data = setup.get('video') or {}
25 'title': video_data.get('title_short'),
26 'description': video_data.get('description_long') or video_data.get('description_short'),
27 'thumbnail': video_data.get('brightcove_thumbnail')
29 asset = setup.get('asset') or setup.get('params') or {}
32 hls_url = asset.get('hls_url')
34 formats.extend(self._extract_m3u8_formats(
35 hls_url, video_id, 'mp4', 'm3u8_native', m3u8_id='hls', fatal=False))
36 mp4_url = asset.get('mp4_url')
38 tbr = self._search_regex(r'-(\d+)k\.', mp4_url, 'bitrate', default=None)
41 format_id += '-' + tbr
43 'format_id': format_id,
45 'tbr': int_or_none(tbr),
48 self._sort_formats(formats)
49 info['formats'] = formats
52 for provider_video_type in ('ooyala', 'youtube', 'brightcove'):
53 provider_video_id = video_data.get('%s_id' % provider_video_type)
54 if not provider_video_id:
56 if provider_video_type == 'brightcove':
57 info['formats'] = self._extract_once_formats(provider_video_id)
58 self._sort_formats(info['formats'])
61 '_type': 'url_transparent',
62 'url': provider_video_id if provider_video_type == 'youtube' else '%s:%s' % (provider_video_type, provider_video_id),
63 'ie_key': provider_video_type.capitalize(),
66 raise ExtractorError('Unable to find provider video id')
69 class VoxMediaIE(InfoExtractor):
70 _VALID_URL = r'https?://(?:www\.)?(?:(?:theverge|vox|sbnation|eater|polygon|curbed|racked|funnyordie)\.com|recode\.net)/(?:[^/]+/)*(?P<id>[^/?]+)'
72 # Volume embed, Youtube
73 'url': 'http://www.theverge.com/2014/6/27/5849272/material-world-how-google-discovered-what-software-is-made-of',
77 'title': 'Material world: how Google discovered what software is made of',
78 'description': 'md5:dfc17e7715e3b542d66e33a109861382',
79 'upload_date': '20190710',
80 'uploader_id': 'TheVerge',
81 'uploader': 'The Verge',
83 'add_ie': ['Youtube'],
85 # Volume embed, Youtube
86 'url': 'http://www.theverge.com/2014/10/21/7025853/google-nexus-6-hands-on-photos-video-android-phablet',
87 'md5': '4c8f4a0937752b437c3ebc0ed24802b5',
91 'title': 'The Nexus 6: hands-on with Google\'s phablet',
92 'description': 'md5:d9f0216e5fb932dd2033d6db37ac3f1d',
93 'uploader_id': 'TheVerge',
94 'upload_date': '20141021',
95 'uploader': 'The Verge',
97 'add_ie': ['Youtube'],
98 'skip': 'similar to the previous test',
100 # Volume embed, Youtube
101 'url': 'http://www.vox.com/2016/3/31/11336640/mississippi-lgbt-religious-freedom-bill',
105 'title': "Mississippi's laws are so bad that its anti-LGBTQ law isn't needed to allow discrimination",
106 'description': 'md5:fc1317922057de31cd74bce91eb1c66c',
107 'uploader_id': 'voxdotcom',
108 'upload_date': '20150915',
111 'add_ie': ['Youtube'],
112 'skip': 'similar to the previous test',
115 'url': 'http://www.vox.com/2016/3/24/11291692/robot-dance',
116 'md5': '83b3080489fb103941e549352d3e0977',
120 'title': 'How "the robot" became the greatest novelty dance of all time',
121 'description': 'md5:b081c0d588b8b2085870cda55e6da176',
122 'upload_date': '20160324',
123 'uploader_id': 'voxdotcom',
126 'add_ie': ['Youtube'],
127 'skip': 'Page no longer contain videos',
129 # SBN.VideoLinkset.entryGroup multiple ooyala embeds
130 'url': 'http://www.sbnation.com/college-football-recruiting/2015/2/3/7970291/national-signing-day-rationalizations-itll-be-ok-itll-be-ok',
132 'id': 'national-signing-day-rationalizations-itll-be-ok-itll-be-ok',
133 'title': '25 lies you will tell yourself on National Signing Day',
134 'description': 'It\'s the most self-delusional time of the year, and everyone\'s gonna tell the same lies together!',
137 'md5': '721fededf2ab74ae4176c8c8cbfe092e',
139 'id': 'p3cThlMjE61VDi_SD9JlIteSNPWVDBB9',
141 'title': 'Buddy Hield vs Steph Curry (and the world)',
142 'description': 'Let’s dissect only the most important Final Four storylines.',
145 'md5': 'bf0c5cc115636af028be1bab79217ea9',
147 'id': 'BmbmVjMjE6esPHxdALGubTrouQ0jYLHj',
149 'title': 'Chasing Cinderella 2016: Syracuse basketball',
150 'description': 'md5:e02d56b026d51aa32c010676765a690d',
153 'skip': 'Page no longer contain videos',
155 # volume embed, Brightcove Once
156 'url': 'https://www.recode.net/2014/6/17/11628066/post-post-pc-ceo-the-full-code-conference-video-of-microsofts-satya',
157 'md5': '2dbc77b8b0bff1894c2fce16eded637d',
161 'title': 'Post-Post-PC CEO: The Full Code Conference Video of Microsoft\'s Satya Nadella',
162 'description': 'The longtime veteran was chosen earlier this year as the software giant\'s third leader in its history.',
164 'add_ie': ['VoxMediaVolume'],
167 def _real_extract(self, url):
168 display_id = self._match_id(url)
169 webpage = compat_urllib_parse_unquote(self._download_webpage(url, display_id))
171 def create_entry(provider_video_id, provider_video_type, title=None, description=None):
174 'ooyala': 'ooyala:%s',
175 'volume': 'http://volume.vox-cdn.com/embed/%s',
176 }[provider_video_type] % provider_video_id
178 '_type': 'url_transparent',
180 'title': title or self._og_search_title(webpage),
181 'description': description or self._og_search_description(webpage),
185 entries_data = self._search_regex([
186 r'Chorus\.VideoContext\.addVideo\((\[{.+}\])\);',
187 r'var\s+entry\s*=\s*({.+});',
188 r'SBN\.VideoLinkset\.entryGroup\(\s*(\[.+\])',
189 ], webpage, 'video data', default=None)
191 entries_data = self._parse_json(entries_data, display_id)
192 if isinstance(entries_data, dict):
193 entries_data = [entries_data]
194 for video_data in entries_data:
195 provider_video_id = video_data.get('provider_video_id')
196 provider_video_type = video_data.get('provider_video_type')
197 if provider_video_id and provider_video_type:
198 entries.append(create_entry(
199 provider_video_id, provider_video_type,
200 video_data.get('title'), video_data.get('description')))
202 provider_video_id = self._search_regex(
203 r'data-ooyala-id="([^"]+)"', webpage, 'ooyala id', default=None)
204 if provider_video_id:
205 entries.append(create_entry(provider_video_id, 'ooyala'))
207 volume_uuid = self._search_regex(
208 r'data-volume-uuid="([^"]+)"', webpage, 'volume uuid', default=None)
210 entries.append(create_entry(volume_uuid, 'volume'))
212 if len(entries) == 1:
215 return self.playlist_result(entries, display_id, self._og_search_title(webpage), self._og_search_description(webpage))