]> jfr.im git - yt-dlp.git/blame - yt_dlp/extractor/slideslive.py
[test/download] Fallback test to `bv`
[yt-dlp.git] / yt_dlp / extractor / slideslive.py
CommitLineData
d0f2d641
JW
1# coding: utf-8
2from __future__ import unicode_literals
3
4from .common import InfoExtractor
29f7c58a 5from ..utils import (
6 bool_or_none,
7 smuggle_url,
8 try_get,
9 url_or_none,
10)
d0f2d641
JW
11
12
13class SlidesLiveIE(InfoExtractor):
14 _VALID_URL = r'https?://slideslive\.com/(?P<id>[0-9]+)'
15 _TESTS = [{
aa1d5eb9 16 # video_service_name = YOUTUBE
d0f2d641
JW
17 'url': 'https://slideslive.com/38902413/gcc-ia16-backend',
18 'md5': 'b29fcd6c6952d0c79c5079b0e7a07e6f',
19 'info_dict': {
20 'id': 'LMtgR8ba0b0',
21 'ext': 'mp4',
b33a05d2
RA
22 'title': 'GCC IA16 backend',
23 'description': 'Watch full version of this video at https://slideslive.com/38902413.',
24 'uploader': 'SlidesLive Videos - A',
d0f2d641 25 'uploader_id': 'UC62SdArr41t_-_fX40QCLRw',
29f7c58a 26 'timestamp': 1597615266,
d0f2d641
JW
27 'upload_date': '20170925',
28 }
29f7c58a 29 }, {
30 # video_service_name = yoda
31 'url': 'https://slideslive.com/38935785',
32 'md5': '575cd7a6c0acc6e28422fe76dd4bcb1a',
33 'info_dict': {
34 'id': 'RMraDYN5ozA_',
35 'ext': 'mp4',
36 'title': 'Offline Reinforcement Learning: From Algorithms to Practical Challenges',
37 },
aa1d5eb9
RA
38 }, {
39 # video_service_name = youtube
40 'url': 'https://slideslive.com/38903721/magic-a-scientific-resurrection-of-an-esoteric-legend',
41 'only_matching': True,
73d8f3a6
RA
42 }, {
43 # video_service_name = url
44 'url': 'https://slideslive.com/38922070/learning-transferable-skills-1',
45 'only_matching': True,
46 }, {
47 # video_service_name = vimeo
48 'url': 'https://slideslive.com/38921896/retrospectives-a-venue-for-selfreflection-in-ml-research-3',
49 'only_matching': True,
d0f2d641
JW
50 }]
51
52 def _real_extract(self, url):
53 video_id = self._match_id(url)
54 video_data = self._download_json(
b33a05d2 55 'https://ben.slideslive.com/player/' + video_id, video_id)
aa1d5eb9 56 service_name = video_data['video_service_name'].lower()
29f7c58a 57 assert service_name in ('url', 'yoda', 'vimeo', 'youtube')
73d8f3a6 58 service_id = video_data['video_service_id']
29f7c58a 59 subtitles = {}
60 for sub in try_get(video_data, lambda x: x['subtitles'], list) or []:
61 if not isinstance(sub, dict):
62 continue
63 webvtt_url = url_or_none(sub.get('webvtt_url'))
64 if not webvtt_url:
65 continue
66 lang = sub.get('language') or 'en'
67 subtitles.setdefault(lang, []).append({
68 'url': webvtt_url,
69 })
73d8f3a6
RA
70 info = {
71 'id': video_id,
72 'thumbnail': video_data.get('thumbnail'),
29f7c58a 73 'is_live': bool_or_none(video_data.get('is_live')),
74 'subtitles': subtitles,
73d8f3a6 75 }
29f7c58a 76 if service_name in ('url', 'yoda'):
73d8f3a6 77 info['title'] = video_data['title']
29f7c58a 78 if service_name == 'url':
79 info['url'] = service_id
80 else:
81 formats = []
82 _MANIFEST_PATTERN = 'https://01.cdn.yoda.slideslive.com/%s/master.%s'
83 # use `m3u8` entry_protocol until EXT-X-MAP is properly supported by `m3u8_native` entry_protocol
84 formats.extend(self._extract_m3u8_formats(
85 _MANIFEST_PATTERN % (service_id, 'm3u8'),
86 service_id, 'mp4', m3u8_id='hls', fatal=False))
87 formats.extend(self._extract_mpd_formats(
88 _MANIFEST_PATTERN % (service_id, 'mpd'), service_id,
89 mpd_id='dash', fatal=False))
90 self._sort_formats(formats)
91 info.update({
92 'id': service_id,
93 'formats': formats,
94 })
73d8f3a6
RA
95 else:
96 info.update({
b33a05d2 97 '_type': 'url_transparent',
29f7c58a 98 'url': service_id,
73d8f3a6 99 'ie_key': service_name.capitalize(),
b33a05d2 100 'title': video_data.get('title'),
73d8f3a6
RA
101 })
102 if service_name == 'vimeo':
103 info['url'] = smuggle_url(
104 'https://player.vimeo.com/video/' + service_id,
105 {'http_headers': {'Referer': url}})
106 return info