1 from .common
import InfoExtractor
2 from .once
import OnceIE
3 from ..compat
import compat_urllib_parse_unquote
12 class VoxMediaVolumeIE(OnceIE
):
13 _VALID_URL
= r
'https?://volume\.vox-cdn\.com/embed/(?P<id>[0-9a-f]{9})'
15 def _real_extract(self
, url
):
16 video_id
= self
._match
_id
(url
)
17 webpage
= self
._download
_webpage
(url
, video_id
)
19 setup
= self
._parse
_json
(self
._search
_regex
(
20 r
'setup\s*=\s*({.+});', webpage
, 'setup'), video_id
)
21 player_setup
= setup
.get('player_setup') or setup
22 video_data
= player_setup
.get('video') or {}
23 formatted_metadata
= video_data
.get('formatted_metadata') or {}
26 'title': player_setup
.get('title') or video_data
.get('title_short'),
27 'description': video_data
.get('description_long') or video_data
.get('description_short'),
28 'thumbnail': formatted_metadata
.get('thumbnail') or video_data
.get('brightcove_thumbnail'),
29 'timestamp': unified_timestamp(formatted_metadata
.get('video_publish_date')),
31 asset
= try_get(setup
, lambda x
: x
['embed_assets']['chorus'], dict) or {}
34 hls_url
= asset
.get('hls_url')
36 formats
.extend(self
._extract
_m
3u8_formats
(
37 hls_url
, video_id
, 'mp4', 'm3u8_native', m3u8_id
='hls', fatal
=False))
38 mp4_url
= asset
.get('mp4_url')
40 tbr
= self
._search
_regex
(r
'-(\d+)k\.', mp4_url
, 'bitrate', default
=None)
43 format_id
+= '-' + tbr
45 'format_id': format_id
,
47 'tbr': int_or_none(tbr
),
50 self
._sort
_formats
(formats
)
51 info
['formats'] = formats
52 info
['duration'] = int_or_none(asset
.get('duration'))
55 for provider_video_type
in ('ooyala', 'youtube', 'brightcove'):
56 provider_video_id
= video_data
.get('%s_id' % provider_video_type
)
57 if not provider_video_id
:
59 if provider_video_type
== 'brightcove':
60 info
['formats'] = self
._extract
_once
_formats
(provider_video_id
)
61 self
._sort
_formats
(info
['formats'])
64 '_type': 'url_transparent',
65 'url': provider_video_id
if provider_video_type
== 'youtube' else '%s:%s' % (provider_video_type
, provider_video_id
),
66 'ie_key': provider_video_type
.capitalize(),
69 raise ExtractorError('Unable to find provider video id')
72 class VoxMediaIE(InfoExtractor
):
73 _VALID_URL
= r
'https?://(?:www\.)?(?:(?:theverge|vox|sbnation|eater|polygon|curbed|racked|funnyordie)\.com|recode\.net)/(?:[^/]+/)*(?P<id>[^/?]+)'
75 # Volume embed, Youtube
76 'url': 'http://www.theverge.com/2014/6/27/5849272/material-world-how-google-discovered-what-software-is-made-of',
80 'title': 'Material world: how Google discovered what software is made of',
81 'description': 'md5:dfc17e7715e3b542d66e33a109861382',
82 'upload_date': '20190710',
83 'uploader_id': 'TheVerge',
84 'uploader': 'The Verge',
86 'add_ie': ['Youtube'],
88 # Volume embed, Youtube
89 'url': 'http://www.theverge.com/2014/10/21/7025853/google-nexus-6-hands-on-photos-video-android-phablet',
90 'md5': 'fd19aa0cf3a0eea515d4fd5c8c0e9d68',
94 'title': 'The Nexus 6: hands-on with Google\'s phablet',
95 'description': 'md5:d9f0216e5fb932dd2033d6db37ac3f1d',
96 'uploader_id': 'TheVerge',
97 'upload_date': '20141021',
98 'uploader': 'The Verge',
99 'timestamp': 1413907200,
101 'add_ie': ['Youtube'],
102 'skip': 'similar to the previous test',
104 # Volume embed, Youtube
105 'url': 'http://www.vox.com/2016/3/31/11336640/mississippi-lgbt-religious-freedom-bill',
109 'title': "Mississippi's laws are so bad that its anti-LGBTQ law isn't needed to allow discrimination",
110 'description': 'md5:fc1317922057de31cd74bce91eb1c66c',
111 'upload_date': '20150915',
112 'timestamp': 1442332800,
115 'add_ie': ['Youtube'],
116 'skip': 'similar to the previous test',
119 'url': 'http://www.vox.com/2016/3/24/11291692/robot-dance',
120 'md5': '83b3080489fb103941e549352d3e0977',
124 'title': 'How "the robot" became the greatest novelty dance of all time',
125 'description': 'md5:b081c0d588b8b2085870cda55e6da176',
126 'upload_date': '20160324',
127 'uploader_id': 'voxdotcom',
130 'add_ie': ['Youtube'],
131 'skip': 'Page no longer contain videos',
133 # SBN.VideoLinkset.entryGroup multiple ooyala embeds
134 'url': 'http://www.sbnation.com/college-football-recruiting/2015/2/3/7970291/national-signing-day-rationalizations-itll-be-ok-itll-be-ok',
136 'id': 'national-signing-day-rationalizations-itll-be-ok-itll-be-ok',
137 'title': '25 lies you will tell yourself on National Signing Day',
138 'description': 'It\'s the most self-delusional time of the year, and everyone\'s gonna tell the same lies together!',
141 'md5': '721fededf2ab74ae4176c8c8cbfe092e',
143 'id': 'p3cThlMjE61VDi_SD9JlIteSNPWVDBB9',
145 'title': 'Buddy Hield vs Steph Curry (and the world)',
146 'description': 'Let’s dissect only the most important Final Four storylines.',
149 'md5': 'bf0c5cc115636af028be1bab79217ea9',
151 'id': 'BmbmVjMjE6esPHxdALGubTrouQ0jYLHj',
153 'title': 'Chasing Cinderella 2016: Syracuse basketball',
154 'description': 'md5:e02d56b026d51aa32c010676765a690d',
157 'skip': 'Page no longer contain videos',
159 # volume embed, Brightcove Once
160 'url': 'https://www.recode.net/2014/6/17/11628066/post-post-pc-ceo-the-full-code-conference-video-of-microsofts-satya',
161 'md5': '2dbc77b8b0bff1894c2fce16eded637d',
165 'title': 'Post-Post-PC CEO: The Full Code Conference Video of Microsoft\'s Satya Nadella',
166 'description': 'The longtime veteran was chosen earlier this year as the software giant\'s third leader in its history.',
167 'timestamp': 1402938000,
168 'upload_date': '20140616',
171 'add_ie': ['VoxMediaVolume'],
174 def _real_extract(self
, url
):
175 display_id
= self
._match
_id
(url
)
176 webpage
= compat_urllib_parse_unquote(self
._download
_webpage
(url
, display_id
))
178 def create_entry(provider_video_id
, provider_video_type
, title
=None, description
=None):
181 'ooyala': 'ooyala:%s',
182 'volume': 'http://volume.vox-cdn.com/embed/%s',
183 }[provider_video_type
] % provider_video_id
185 '_type': 'url_transparent',
187 'title': title
or self
._og
_search
_title
(webpage
),
188 'description': description
or self
._og
_search
_description
(webpage
),
192 entries_data
= self
._search
_regex
([
193 r
'Chorus\.VideoContext\.addVideo\((\[{.+}\])\);',
194 r
'var\s+entry\s*=\s*({.+});',
195 r
'SBN\.VideoLinkset\.entryGroup\(\s*(\[.+\])',
196 ], webpage
, 'video data', default
=None)
198 entries_data
= self
._parse
_json
(entries_data
, display_id
)
199 if isinstance(entries_data
, dict):
200 entries_data
= [entries_data
]
201 for video_data
in entries_data
:
202 provider_video_id
= video_data
.get('provider_video_id')
203 provider_video_type
= video_data
.get('provider_video_type')
204 if provider_video_id
and provider_video_type
:
205 entries
.append(create_entry(
206 provider_video_id
, provider_video_type
,
207 video_data
.get('title'), video_data
.get('description')))
209 provider_video_id
= self
._search
_regex
(
210 r
'data-ooyala-id="([^"]+)"', webpage
, 'ooyala id', default
=None)
211 if provider_video_id
:
212 entries
.append(create_entry(provider_video_id
, 'ooyala'))
214 volume_uuid
= self
._search
_regex
(
215 r
'data-volume-uuid="([^"]+)"', webpage
, 'volume uuid', default
=None)
217 entries
.append(create_entry(volume_uuid
, 'volume'))
219 if len(entries
) == 1:
222 return self
.playlist_result(entries
, display_id
, self
._og
_search
_title
(webpage
), self
._og
_search
_description
(webpage
))