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