2 from __future__
import unicode_literals
4 from .common
import InfoExtractor
5 from .once
import OnceIE
6 from ..compat
import compat_urllib_parse_unquote
15 class VoxMediaVolumeIE(OnceIE
):
16 _VALID_URL
= r
'https?://volume\.vox-cdn\.com/embed/(?P<id>[0-9a-f]{9})'
18 def _real_extract(self
, url
):
19 video_id
= self
._match
_id
(url
)
20 webpage
= self
._download
_webpage
(url
, video_id
)
22 setup
= self
._parse
_json
(self
._search
_regex
(
23 r
'setup\s*=\s*({.+});', webpage
, 'setup'), video_id
)
24 player_setup
= setup
.get('player_setup') or setup
25 video_data
= player_setup
.get('video') or {}
26 formatted_metadata
= video_data
.get('formatted_metadata') or {}
29 'title': player_setup
.get('title') or video_data
.get('title_short'),
30 'description': video_data
.get('description_long') or video_data
.get('description_short'),
31 'thumbnail': formatted_metadata
.get('thumbnail') or video_data
.get('brightcove_thumbnail'),
32 'timestamp': unified_timestamp(formatted_metadata
.get('video_publish_date')),
34 asset
= try_get(setup
, lambda x
: x
['embed_assets']['chorus'], dict) or {}
37 hls_url
= asset
.get('hls_url')
39 formats
.extend(self
._extract
_m
3u8_formats
(
40 hls_url
, video_id
, 'mp4', 'm3u8_native', m3u8_id
='hls', fatal
=False))
41 mp4_url
= asset
.get('mp4_url')
43 tbr
= self
._search
_regex
(r
'-(\d+)k\.', mp4_url
, 'bitrate', default
=None)
46 format_id
+= '-' + tbr
48 'format_id': format_id
,
50 'tbr': int_or_none(tbr
),
53 self
._sort
_formats
(formats
)
54 info
['formats'] = formats
55 info
['duration'] = int_or_none(asset
.get('duration'))
58 for provider_video_type
in ('ooyala', 'youtube', 'brightcove'):
59 provider_video_id
= video_data
.get('%s_id' % provider_video_type
)
60 if not provider_video_id
:
62 if provider_video_type
== 'brightcove':
63 info
['formats'] = self
._extract
_once
_formats
(provider_video_id
)
64 self
._sort
_formats
(info
['formats'])
67 '_type': 'url_transparent',
68 'url': provider_video_id
if provider_video_type
== 'youtube' else '%s:%s' % (provider_video_type
, provider_video_id
),
69 'ie_key': provider_video_type
.capitalize(),
72 raise ExtractorError('Unable to find provider video id')
75 class VoxMediaIE(InfoExtractor
):
76 _VALID_URL
= r
'https?://(?:www\.)?(?:(?:theverge|vox|sbnation|eater|polygon|curbed|racked|funnyordie)\.com|recode\.net)/(?:[^/]+/)*(?P<id>[^/?]+)'
78 # Volume embed, Youtube
79 'url': 'http://www.theverge.com/2014/6/27/5849272/material-world-how-google-discovered-what-software-is-made-of',
83 'title': 'Material world: how Google discovered what software is made of',
84 'description': 'md5:dfc17e7715e3b542d66e33a109861382',
85 'upload_date': '20190710',
86 'uploader_id': 'TheVerge',
87 'uploader': 'The Verge',
89 'add_ie': ['Youtube'],
91 # Volume embed, Youtube
92 'url': 'http://www.theverge.com/2014/10/21/7025853/google-nexus-6-hands-on-photos-video-android-phablet',
93 'md5': 'fd19aa0cf3a0eea515d4fd5c8c0e9d68',
97 'title': 'The Nexus 6: hands-on with Google\'s phablet',
98 'description': 'md5:d9f0216e5fb932dd2033d6db37ac3f1d',
99 'uploader_id': 'TheVerge',
100 'upload_date': '20141021',
101 'uploader': 'The Verge',
102 'timestamp': 1413907200,
104 'add_ie': ['Youtube'],
105 'skip': 'similar to the previous test',
107 # Volume embed, Youtube
108 'url': 'http://www.vox.com/2016/3/31/11336640/mississippi-lgbt-religious-freedom-bill',
112 'title': "Mississippi's laws are so bad that its anti-LGBTQ law isn't needed to allow discrimination",
113 'description': 'md5:fc1317922057de31cd74bce91eb1c66c',
114 'upload_date': '20150915',
115 'timestamp': 1442332800,
118 'add_ie': ['Youtube'],
119 'skip': 'similar to the previous test',
122 'url': 'http://www.vox.com/2016/3/24/11291692/robot-dance',
123 'md5': '83b3080489fb103941e549352d3e0977',
127 'title': 'How "the robot" became the greatest novelty dance of all time',
128 'description': 'md5:b081c0d588b8b2085870cda55e6da176',
129 'upload_date': '20160324',
130 'uploader_id': 'voxdotcom',
133 'add_ie': ['Youtube'],
134 'skip': 'Page no longer contain videos',
136 # SBN.VideoLinkset.entryGroup multiple ooyala embeds
137 'url': 'http://www.sbnation.com/college-football-recruiting/2015/2/3/7970291/national-signing-day-rationalizations-itll-be-ok-itll-be-ok',
139 'id': 'national-signing-day-rationalizations-itll-be-ok-itll-be-ok',
140 'title': '25 lies you will tell yourself on National Signing Day',
141 'description': 'It\'s the most self-delusional time of the year, and everyone\'s gonna tell the same lies together!',
144 'md5': '721fededf2ab74ae4176c8c8cbfe092e',
146 'id': 'p3cThlMjE61VDi_SD9JlIteSNPWVDBB9',
148 'title': 'Buddy Hield vs Steph Curry (and the world)',
149 'description': 'Let’s dissect only the most important Final Four storylines.',
152 'md5': 'bf0c5cc115636af028be1bab79217ea9',
154 'id': 'BmbmVjMjE6esPHxdALGubTrouQ0jYLHj',
156 'title': 'Chasing Cinderella 2016: Syracuse basketball',
157 'description': 'md5:e02d56b026d51aa32c010676765a690d',
160 'skip': 'Page no longer contain videos',
162 # volume embed, Brightcove Once
163 'url': 'https://www.recode.net/2014/6/17/11628066/post-post-pc-ceo-the-full-code-conference-video-of-microsofts-satya',
164 'md5': '2dbc77b8b0bff1894c2fce16eded637d',
168 'title': 'Post-Post-PC CEO: The Full Code Conference Video of Microsoft\'s Satya Nadella',
169 'description': 'The longtime veteran was chosen earlier this year as the software giant\'s third leader in its history.',
170 'timestamp': 1402938000,
171 'upload_date': '20140616',
174 'add_ie': ['VoxMediaVolume'],
177 def _real_extract(self
, url
):
178 display_id
= self
._match
_id
(url
)
179 webpage
= compat_urllib_parse_unquote(self
._download
_webpage
(url
, display_id
))
181 def create_entry(provider_video_id
, provider_video_type
, title
=None, description
=None):
184 'ooyala': 'ooyala:%s',
185 'volume': 'http://volume.vox-cdn.com/embed/%s',
186 }[provider_video_type
] % provider_video_id
188 '_type': 'url_transparent',
190 'title': title
or self
._og
_search
_title
(webpage
),
191 'description': description
or self
._og
_search
_description
(webpage
),
195 entries_data
= self
._search
_regex
([
196 r
'Chorus\.VideoContext\.addVideo\((\[{.+}\])\);',
197 r
'var\s+entry\s*=\s*({.+});',
198 r
'SBN\.VideoLinkset\.entryGroup\(\s*(\[.+\])',
199 ], webpage
, 'video data', default
=None)
201 entries_data
= self
._parse
_json
(entries_data
, display_id
)
202 if isinstance(entries_data
, dict):
203 entries_data
= [entries_data
]
204 for video_data
in entries_data
:
205 provider_video_id
= video_data
.get('provider_video_id')
206 provider_video_type
= video_data
.get('provider_video_type')
207 if provider_video_id
and provider_video_type
:
208 entries
.append(create_entry(
209 provider_video_id
, provider_video_type
,
210 video_data
.get('title'), video_data
.get('description')))
212 provider_video_id
= self
._search
_regex
(
213 r
'data-ooyala-id="([^"]+)"', webpage
, 'ooyala id', default
=None)
214 if provider_video_id
:
215 entries
.append(create_entry(provider_video_id
, 'ooyala'))
217 volume_uuid
= self
._search
_regex
(
218 r
'data-volume-uuid="([^"]+)"', webpage
, 'volume uuid', default
=None)
220 entries
.append(create_entry(volume_uuid
, 'volume'))
222 if len(entries
) == 1:
225 return self
.playlist_result(entries
, display_id
, self
._og
_search
_title
(webpage
), self
._og
_search
_description
(webpage
))