]>
Commit | Line | Data |
---|---|---|
8b85ac3f | 1 | # coding: utf-8 |
2 | from __future__ import unicode_literals | |
3 | ||
b12cf31b | 4 | import json |
8b85ac3f | 5 | import re |
6 | ||
7 | from .common import InfoExtractor | |
64f03e5b S |
8 | from ..compat import ( |
9 | compat_str, | |
10 | compat_HTTPError, | |
11 | ) | |
52f7c75c | 12 | from ..utils import ( |
13 | js_to_json, | |
14 | smuggle_url, | |
88bd486b | 15 | try_get, |
30afe4ae RA |
16 | xpath_text, |
17 | xpath_element, | |
18 | xpath_with_ns, | |
19 | find_xpath_attr, | |
f20f6365 | 20 | orderedSet, |
b12cf31b | 21 | parse_duration, |
30afe4ae RA |
22 | parse_iso8601, |
23 | parse_age_limit, | |
986c0b02 | 24 | strip_or_none, |
30afe4ae RA |
25 | int_or_none, |
26 | ExtractorError, | |
52f7c75c | 27 | ) |
8b85ac3f | 28 | |
29 | ||
30 | class CBCIE(InfoExtractor): | |
30afe4ae | 31 | IE_NAME = 'cbc.ca' |
043dc9d3 | 32 | _VALID_URL = r'https?://(?:www\.)?cbc\.ca/(?!player/)(?:[^/]+/)+(?P<id>[^/?#]+)' |
8b85ac3f | 33 | _TESTS = [{ |
34 | # with mediaId | |
35 | 'url': 'http://www.cbc.ca/22minutes/videos/clips-season-23/don-cherry-play-offs', | |
52f7c75c | 36 | 'md5': '97e24d09672fc4cf56256d6faa6c25bc', |
8b85ac3f | 37 | 'info_dict': { |
38 | 'id': '2682904050', | |
52f7c75c | 39 | 'ext': 'mp4', |
8b85ac3f | 40 | 'title': 'Don Cherry – All-Stars', |
41 | 'description': 'Don Cherry has a bee in his bonnet about AHL player John Scott because that guy’s got heart.', | |
52f7c75c | 42 | 'timestamp': 1454463000, |
8b85ac3f | 43 | 'upload_date': '20160203', |
52f7c75c | 44 | 'uploader': 'CBCC-NEW', |
8b85ac3f | 45 | }, |
21ba7d09 | 46 | 'skip': 'Geo-restricted to Canada', |
8b85ac3f | 47 | }, { |
88bd486b S |
48 | # with clipId, feed available via tpfeed.cbc.ca and feed.theplatform.com |
49 | 'url': 'http://www.cbc.ca/22minutes/videos/22-minutes-update/22-minutes-update-episode-4', | |
50 | 'md5': '162adfa070274b144f4fdc3c3b8207db', | |
51 | 'info_dict': { | |
52 | 'id': '2414435309', | |
53 | 'ext': 'mp4', | |
54 | 'title': '22 Minutes Update: What Not To Wear Quebec', | |
55 | 'description': "This week's latest Canadian top political story is What Not To Wear Quebec.", | |
56 | 'upload_date': '20131025', | |
57 | 'uploader': 'CBCC-NEW', | |
58 | 'timestamp': 1382717907, | |
59 | }, | |
60 | }, { | |
61 | # with clipId, feed only available via tpfeed.cbc.ca | |
8b85ac3f | 62 | 'url': 'http://www.cbc.ca/archives/entry/1978-robin-williams-freestyles-on-90-minutes-live', |
64413f75 | 63 | 'md5': '0274a90b51a9b4971fe005c63f592f12', |
8b85ac3f | 64 | 'info_dict': { |
65 | 'id': '2487345465', | |
52f7c75c | 66 | 'ext': 'mp4', |
8b85ac3f | 67 | 'title': 'Robin Williams freestyles on 90 Minutes Live', |
68 | 'description': 'Wacky American comedian Robin Williams shows off his infamous "freestyle" comedic talents while being interviewed on CBC\'s 90 Minutes Live.', | |
52f7c75c | 69 | 'upload_date': '19780210', |
0738187f | 70 | 'uploader': 'CBCC-NEW', |
52f7c75c | 71 | 'timestamp': 255977160, |
8b85ac3f | 72 | }, |
73 | }, { | |
74 | # multiple iframes | |
75 | 'url': 'http://www.cbc.ca/natureofthings/blog/birds-eye-view-from-vancouvers-burrard-street-bridge-how-we-got-the-shot', | |
76 | 'playlist': [{ | |
52f7c75c | 77 | 'md5': '377572d0b49c4ce0c9ad77470e0b96b4', |
8b85ac3f | 78 | 'info_dict': { |
79 | 'id': '2680832926', | |
52f7c75c | 80 | 'ext': 'mp4', |
8b85ac3f | 81 | 'title': 'An Eagle\'s-Eye View Off Burrard Bridge', |
82 | 'description': 'Hercules the eagle flies from Vancouver\'s Burrard Bridge down to a nearby park with a mini-camera strapped to his back.', | |
52f7c75c | 83 | 'upload_date': '20160201', |
84 | 'timestamp': 1454342820, | |
85 | 'uploader': 'CBCC-NEW', | |
8b85ac3f | 86 | }, |
87 | }, { | |
52f7c75c | 88 | 'md5': '415a0e3f586113894174dfb31aa5bb1a', |
8b85ac3f | 89 | 'info_dict': { |
90 | 'id': '2658915080', | |
52f7c75c | 91 | 'ext': 'mp4', |
8b85ac3f | 92 | 'title': 'Fly like an eagle!', |
93 | 'description': 'Eagle equipped with a mini camera flies from the world\'s tallest tower', | |
52f7c75c | 94 | 'upload_date': '20150315', |
95 | 'timestamp': 1426443984, | |
96 | 'uploader': 'CBCC-NEW', | |
8b85ac3f | 97 | }, |
98 | }], | |
21ba7d09 | 99 | 'skip': 'Geo-restricted to Canada', |
abe8cb76 S |
100 | }, { |
101 | # multiple CBC.APP.Caffeine.initInstance(...) | |
102 | 'url': 'http://www.cbc.ca/news/canada/calgary/dog-indoor-exercise-winter-1.3928238', | |
103 | 'info_dict': { | |
104 | 'title': 'Keep Rover active during the deep freeze with doggie pushups and other fun indoor tasks', | |
105 | 'id': 'dog-indoor-exercise-winter-1.3928238', | |
c95e2b59 | 106 | 'description': 'md5:c18552e41726ee95bd75210d1ca9194c', |
abe8cb76 S |
107 | }, |
108 | 'playlist_mincount': 6, | |
8b85ac3f | 109 | }] |
110 | ||
111 | @classmethod | |
112 | def suitable(cls, url): | |
113 | return False if CBCPlayerIE.suitable(url) else super(CBCIE, cls).suitable(url) | |
114 | ||
abe8cb76 S |
115 | def _extract_player_init(self, player_init, display_id): |
116 | player_info = self._parse_json(player_init, display_id, js_to_json) | |
117 | media_id = player_info.get('mediaId') | |
118 | if not media_id: | |
119 | clip_id = player_info['clipId'] | |
120 | feed = self._download_json( | |
121 | 'http://tpfeed.cbc.ca/f/ExhSPC/vms_5akSXx4Ng_Zn?byCustomValue={:mpsReleases}{%s}' % clip_id, | |
122 | clip_id, fatal=False) | |
123 | if feed: | |
124 | media_id = try_get(feed, lambda x: x['entries'][0]['guid'], compat_str) | |
125 | if not media_id: | |
126 | media_id = self._download_json( | |
127 | 'http://feed.theplatform.com/f/h9dtGB/punlNGjMlc1F?fields=id&byContent=byReleases%3DbyId%253D' + clip_id, | |
128 | clip_id)['entries'][0]['id'].split('/')[-1] | |
129 | return self.url_result('cbcplayer:%s' % media_id, 'CBCPlayer', media_id) | |
130 | ||
8b85ac3f | 131 | def _real_extract(self, url): |
132 | display_id = self._match_id(url) | |
133 | webpage = self._download_webpage(url, display_id) | |
986c0b02 PV |
134 | title = self._og_search_title(webpage, default=None) or self._html_search_meta( |
135 | 'twitter:title', webpage, 'title', default=None) or self._html_search_regex( | |
136 | r'<title>([^<]+)</title>', webpage, 'title', fatal=False) | |
abe8cb76 S |
137 | entries = [ |
138 | self._extract_player_init(player_init, display_id) | |
139 | for player_init in re.findall(r'CBC\.APP\.Caffeine\.initInstance\(({.+?})\);', webpage)] | |
f20f6365 S |
140 | media_ids = [] |
141 | for media_id_re in ( | |
142 | r'<iframe[^>]+src="[^"]+?mediaId=(\d+)"', | |
143 | r'<div[^>]+\bid=["\']player-(\d+)', | |
144 | r'guid["\']\s*:\s*["\'](\d+)'): | |
145 | media_ids.extend(re.findall(media_id_re, webpage)) | |
abe8cb76 S |
146 | entries.extend([ |
147 | self.url_result('cbcplayer:%s' % media_id, 'CBCPlayer', media_id) | |
f20f6365 | 148 | for media_id in orderedSet(media_ids)]) |
abe8cb76 | 149 | return self.playlist_result( |
986c0b02 | 150 | entries, display_id, strip_or_none(title), |
abe8cb76 | 151 | self._og_search_description(webpage)) |
8b85ac3f | 152 | |
153 | ||
154 | class CBCPlayerIE(InfoExtractor): | |
30afe4ae | 155 | IE_NAME = 'cbc.ca:player' |
8b85ac3f | 156 | _VALID_URL = r'(?:cbcplayer:|https?://(?:www\.)?cbc\.ca/(?:player/play/|i/caffeine/syndicate/\?mediaId=))(?P<id>\d+)' |
31a70191 | 157 | _TESTS = [{ |
8b85ac3f | 158 | 'url': 'http://www.cbc.ca/player/play/2683190193', |
64413f75 | 159 | 'md5': '64d25f841ddf4ddb28a235338af32e2c', |
8b85ac3f | 160 | 'info_dict': { |
161 | 'id': '2683190193', | |
52f7c75c | 162 | 'ext': 'mp4', |
8b85ac3f | 163 | 'title': 'Gerry Runs a Sweat Shop', |
164 | 'description': 'md5:b457e1c01e8ff408d9d801c1c2cd29b0', | |
52f7c75c | 165 | 'timestamp': 1455071400, |
8b85ac3f | 166 | 'upload_date': '20160210', |
52f7c75c | 167 | 'uploader': 'CBCC-NEW', |
8b85ac3f | 168 | }, |
21ba7d09 | 169 | 'skip': 'Geo-restricted to Canada', |
31a70191 YCH |
170 | }, { |
171 | # Redirected from http://www.cbc.ca/player/AudioMobile/All%20in%20a%20Weekend%20Montreal/ID/2657632011/ | |
172 | 'url': 'http://www.cbc.ca/player/play/2657631896', | |
173 | 'md5': 'e5e708c34ae6fca156aafe17c43e8b75', | |
174 | 'info_dict': { | |
175 | 'id': '2657631896', | |
176 | 'ext': 'mp3', | |
177 | 'title': 'CBC Montreal is organizing its first ever community hackathon!', | |
178 | 'description': 'The modern technology we tend to depend on so heavily, is never without it\'s share of hiccups and headaches. Next weekend - CBC Montreal will be getting members of the public for its first Hackathon.', | |
179 | 'timestamp': 1425704400, | |
180 | 'upload_date': '20150307', | |
181 | 'uploader': 'CBCC-NEW', | |
182 | }, | |
64413f75 | 183 | }, { |
64413f75 | 184 | 'url': 'http://www.cbc.ca/player/play/2164402062', |
c95e2b59 | 185 | 'md5': '33fcd8f6719b9dd60a5e73adcb83b9f6', |
64413f75 | 186 | 'info_dict': { |
187 | 'id': '2164402062', | |
c95e2b59 | 188 | 'ext': 'mp4', |
64413f75 | 189 | 'title': 'Cancer survivor four times over', |
190 | 'description': 'Tim Mayer has beaten three different forms of cancer four times in five years.', | |
191 | 'timestamp': 1320410746, | |
192 | 'upload_date': '20111104', | |
193 | 'uploader': 'CBCC-NEW', | |
194 | }, | |
31a70191 | 195 | }] |
8b85ac3f | 196 | |
197 | def _real_extract(self, url): | |
198 | video_id = self._match_id(url) | |
52f7c75c | 199 | return { |
200 | '_type': 'url_transparent', | |
201 | 'ie_key': 'ThePlatform', | |
202 | 'url': smuggle_url( | |
64413f75 | 203 | 'http://link.theplatform.com/s/ExhSPC/media/guid/2655402169/%s?mbr=true&formats=MPEG4,FLV,MP3' % video_id, { |
52f7c75c | 204 | 'force_smil_url': True |
205 | }), | |
206 | 'id': video_id, | |
207 | } | |
30afe4ae RA |
208 | |
209 | ||
210 | class CBCWatchBaseIE(InfoExtractor): | |
211 | _device_id = None | |
212 | _device_token = None | |
213 | _API_BASE_URL = 'https://api-cbc.cloud.clearleap.com/cloffice/client/' | |
214 | _NS_MAP = { | |
215 | 'media': 'http://search.yahoo.com/mrss/', | |
216 | 'clearleap': 'http://www.clearleap.com/namespace/clearleap/1.0/', | |
217 | } | |
0830f3e0 | 218 | _GEO_COUNTRIES = ['CA'] |
30afe4ae RA |
219 | |
220 | def _call_api(self, path, video_id): | |
221 | url = path if path.startswith('http') else self._API_BASE_URL + path | |
64f03e5b S |
222 | for _ in range(2): |
223 | try: | |
224 | result = self._download_xml(url, video_id, headers={ | |
225 | 'X-Clearleap-DeviceId': self._device_id, | |
226 | 'X-Clearleap-DeviceToken': self._device_token, | |
227 | }) | |
228 | except ExtractorError as e: | |
229 | if isinstance(e.cause, compat_HTTPError) and e.cause.code == 401: | |
230 | # Device token has expired, re-acquiring device token | |
231 | self._register_device() | |
232 | continue | |
233 | raise | |
30afe4ae RA |
234 | error_message = xpath_text(result, 'userMessage') or xpath_text(result, 'systemMessage') |
235 | if error_message: | |
236 | raise ExtractorError('%s said: %s' % (self.IE_NAME, error_message)) | |
237 | return result | |
238 | ||
239 | def _real_initialize(self): | |
64f03e5b S |
240 | if self._valid_device_token(): |
241 | return | |
242 | device = self._downloader.cache.load('cbcwatch', 'device') or {} | |
243 | self._device_id, self._device_token = device.get('id'), device.get('token') | |
244 | if self._valid_device_token(): | |
245 | return | |
246 | self._register_device() | |
247 | ||
248 | def _valid_device_token(self): | |
249 | return self._device_id and self._device_token | |
250 | ||
251 | def _register_device(self): | |
252 | self._device_id = self._device_token = None | |
253 | result = self._download_xml( | |
254 | self._API_BASE_URL + 'device/register', | |
255 | None, 'Acquiring device token', | |
256 | data=b'<device><type>web</type></device>') | |
257 | self._device_id = xpath_text(result, 'deviceId', fatal=True) | |
258 | self._device_token = xpath_text(result, 'deviceToken', fatal=True) | |
259 | self._downloader.cache.store( | |
260 | 'cbcwatch', 'device', { | |
261 | 'id': self._device_id, | |
262 | 'token': self._device_token, | |
263 | }) | |
30afe4ae RA |
264 | |
265 | def _parse_rss_feed(self, rss): | |
266 | channel = xpath_element(rss, 'channel', fatal=True) | |
267 | ||
268 | def _add_ns(path): | |
269 | return xpath_with_ns(path, self._NS_MAP) | |
270 | ||
271 | entries = [] | |
272 | for item in channel.findall('item'): | |
273 | guid = xpath_text(item, 'guid', fatal=True) | |
274 | title = xpath_text(item, 'title', fatal=True) | |
275 | ||
276 | media_group = xpath_element(item, _add_ns('media:group'), fatal=True) | |
277 | content = xpath_element(media_group, _add_ns('media:content'), fatal=True) | |
278 | content_url = content.attrib['url'] | |
279 | ||
280 | thumbnails = [] | |
281 | for thumbnail in media_group.findall(_add_ns('media:thumbnail')): | |
282 | thumbnail_url = thumbnail.get('url') | |
283 | if not thumbnail_url: | |
284 | continue | |
285 | thumbnails.append({ | |
286 | 'id': thumbnail.get('profile'), | |
287 | 'url': thumbnail_url, | |
288 | 'width': int_or_none(thumbnail.get('width')), | |
289 | 'height': int_or_none(thumbnail.get('height')), | |
290 | }) | |
291 | ||
292 | timestamp = None | |
293 | release_date = find_xpath_attr( | |
294 | item, _add_ns('media:credit'), 'role', 'releaseDate') | |
295 | if release_date is not None: | |
296 | timestamp = parse_iso8601(release_date.text) | |
297 | ||
298 | entries.append({ | |
299 | '_type': 'url_transparent', | |
300 | 'url': content_url, | |
301 | 'id': guid, | |
302 | 'title': title, | |
303 | 'description': xpath_text(item, 'description'), | |
304 | 'timestamp': timestamp, | |
305 | 'duration': int_or_none(content.get('duration')), | |
306 | 'age_limit': parse_age_limit(xpath_text(item, _add_ns('media:rating'))), | |
307 | 'episode': xpath_text(item, _add_ns('clearleap:episode')), | |
308 | 'episode_number': int_or_none(xpath_text(item, _add_ns('clearleap:episodeInSeason'))), | |
309 | 'series': xpath_text(item, _add_ns('clearleap:series')), | |
310 | 'season_number': int_or_none(xpath_text(item, _add_ns('clearleap:season'))), | |
311 | 'thumbnails': thumbnails, | |
312 | 'ie_key': 'CBCWatchVideo', | |
313 | }) | |
314 | ||
315 | return self.playlist_result( | |
316 | entries, xpath_text(channel, 'guid'), | |
317 | xpath_text(channel, 'title'), | |
318 | xpath_text(channel, 'description')) | |
319 | ||
320 | ||
321 | class CBCWatchVideoIE(CBCWatchBaseIE): | |
322 | IE_NAME = 'cbc.ca:watch:video' | |
323 | _VALID_URL = r'https?://api-cbc\.cloud\.clearleap\.com/cloffice/client/web/play/?\?.*?\bcontentId=(?P<id>[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12})' | |
0830f3e0 S |
324 | _TEST = { |
325 | # geo-restricted to Canada, bypassable | |
326 | 'url': 'https://api-cbc.cloud.clearleap.com/cloffice/client/web/play/?contentId=3c84472a-1eea-4dee-9267-2655d5055dcf&categoryId=ebc258f5-ee40-4cca-b66b-ba6bd55b7235', | |
327 | 'only_matching': True, | |
328 | } | |
30afe4ae RA |
329 | |
330 | def _real_extract(self, url): | |
331 | video_id = self._match_id(url) | |
332 | result = self._call_api(url, video_id) | |
333 | ||
334 | m3u8_url = xpath_text(result, 'url', fatal=True) | |
335 | formats = self._extract_m3u8_formats(re.sub(r'/([^/]+)/[^/?]+\.m3u8', r'/\1/\1.m3u8', m3u8_url), video_id, 'mp4', fatal=False) | |
336 | if len(formats) < 2: | |
337 | formats = self._extract_m3u8_formats(m3u8_url, video_id, 'mp4') | |
81aeafeb RA |
338 | for f in formats: |
339 | format_id = f.get('format_id') | |
340 | if format_id.startswith('AAC'): | |
341 | f['acodec'] = 'aac' | |
342 | elif format_id.startswith('AC3'): | |
343 | f['acodec'] = 'ac-3' | |
30afe4ae RA |
344 | self._sort_formats(formats) |
345 | ||
346 | info = { | |
347 | 'id': video_id, | |
348 | 'title': video_id, | |
349 | 'formats': formats, | |
350 | } | |
351 | ||
352 | rss = xpath_element(result, 'rss') | |
353 | if rss: | |
354 | info.update(self._parse_rss_feed(rss)['entries'][0]) | |
355 | del info['url'] | |
356 | del info['_type'] | |
357 | del info['ie_key'] | |
358 | return info | |
359 | ||
360 | ||
361 | class CBCWatchIE(CBCWatchBaseIE): | |
362 | IE_NAME = 'cbc.ca:watch' | |
363 | _VALID_URL = r'https?://watch\.cbc\.ca/(?:[^/]+/)+(?P<id>[0-9a-f-]+)' | |
364 | _TESTS = [{ | |
0830f3e0 | 365 | # geo-restricted to Canada, bypassable |
30afe4ae RA |
366 | 'url': 'http://watch.cbc.ca/doc-zone/season-6/customer-disservice/38e815a-009e3ab12e4', |
367 | 'info_dict': { | |
0830f3e0 | 368 | 'id': '9673749a-5e77-484c-8b62-a1092a6b5168', |
30afe4ae RA |
369 | 'ext': 'mp4', |
370 | 'title': 'Customer (Dis)Service', | |
371 | 'description': 'md5:8bdd6913a0fe03d4b2a17ebe169c7c87', | |
372 | 'upload_date': '20160219', | |
373 | 'timestamp': 1455840000, | |
374 | }, | |
375 | 'params': { | |
376 | # m3u8 download | |
377 | 'skip_download': True, | |
378 | 'format': 'bestvideo', | |
379 | }, | |
30afe4ae | 380 | }, { |
0830f3e0 | 381 | # geo-restricted to Canada, bypassable |
30afe4ae RA |
382 | 'url': 'http://watch.cbc.ca/arthur/all/1ed4b385-cd84-49cf-95f0-80f004680057', |
383 | 'info_dict': { | |
384 | 'id': '1ed4b385-cd84-49cf-95f0-80f004680057', | |
385 | 'title': 'Arthur', | |
386 | 'description': 'Arthur, the sweetest 8-year-old aardvark, and his pals solve all kinds of problems with humour, kindness and teamwork.', | |
387 | }, | |
388 | 'playlist_mincount': 30, | |
30afe4ae RA |
389 | }] |
390 | ||
391 | def _real_extract(self, url): | |
392 | video_id = self._match_id(url) | |
393 | rss = self._call_api('web/browse/' + video_id, video_id) | |
394 | return self._parse_rss_feed(rss) | |
b12cf31b RA |
395 | |
396 | ||
397 | class CBCOlympicsIE(InfoExtractor): | |
398 | IE_NAME = 'cbc.ca:olympics' | |
399 | _VALID_URL = r'https?://olympics\.cbc\.ca/video/[^/]+/(?P<id>[^/?#]+)' | |
400 | _TESTS = [{ | |
401 | 'url': 'https://olympics.cbc.ca/video/whats-on-tv/olympic-morning-featuring-the-opening-ceremony/', | |
402 | 'only_matching': True, | |
403 | }] | |
404 | ||
405 | def _real_extract(self, url): | |
406 | display_id = self._match_id(url) | |
407 | webpage = self._download_webpage(url, display_id) | |
408 | video_id = self._hidden_inputs(webpage)['videoId'] | |
409 | video_doc = self._download_xml( | |
410 | 'https://olympics.cbc.ca/videodata/%s.xml' % video_id, video_id) | |
411 | title = xpath_text(video_doc, 'title', fatal=True) | |
412 | is_live = xpath_text(video_doc, 'kind') == 'Live' | |
413 | if is_live: | |
414 | title = self._live_title(title) | |
415 | ||
416 | formats = [] | |
417 | for video_source in video_doc.findall('videoSources/videoSource'): | |
418 | uri = xpath_text(video_source, 'uri') | |
419 | if not uri: | |
420 | continue | |
421 | tokenize = self._download_json( | |
422 | 'https://olympics.cbc.ca/api/api-akamai/tokenize', | |
423 | video_id, data=json.dumps({ | |
424 | 'VideoSource': uri, | |
425 | }).encode(), headers={ | |
426 | 'Content-Type': 'application/json', | |
427 | 'Referer': url, | |
428 | # d3.VideoPlayer._init in https://olympics.cbc.ca/components/script/base.js | |
429 | 'Cookie': '_dvp=TK:C0ObxjerU', # AKAMAI CDN cookie | |
430 | }, fatal=False) | |
431 | if not tokenize: | |
432 | continue | |
433 | content_url = tokenize['ContentUrl'] | |
434 | video_source_format = video_source.get('format') | |
435 | if video_source_format == 'IIS': | |
436 | formats.extend(self._extract_ism_formats( | |
437 | content_url, video_id, ism_id=video_source_format, fatal=False)) | |
438 | else: | |
439 | formats.extend(self._extract_m3u8_formats( | |
440 | content_url, video_id, 'mp4', | |
441 | 'm3u8' if is_live else 'm3u8_native', | |
442 | m3u8_id=video_source_format, fatal=False)) | |
443 | self._sort_formats(formats) | |
444 | ||
445 | return { | |
446 | 'id': video_id, | |
447 | 'display_id': display_id, | |
448 | 'title': title, | |
449 | 'description': xpath_text(video_doc, 'description'), | |
450 | 'thumbnail': xpath_text(video_doc, 'thumbnailUrl'), | |
451 | 'duration': parse_duration(xpath_text(video_doc, 'duration')), | |
452 | 'formats': formats, | |
453 | 'is_live': is_live, | |
454 | } |