]>
Commit | Line | Data |
---|---|---|
27c0f899 | 1 | import urllib.parse |
2 | ||
3 | from .common import InfoExtractor | |
4 | from ..utils import traverse_obj, update_url_query | |
5 | ||
6 | ||
7 | class ScreencastifyIE(InfoExtractor): | |
8 | _VALID_URL = r'https?://watch\.screencastify\.com/v/(?P<id>[^/?#]+)' | |
9 | _TESTS = [{ | |
10 | 'url': 'https://watch.screencastify.com/v/sYVkZip3quLKhHw4Ybk8', | |
11 | 'info_dict': { | |
12 | 'id': 'sYVkZip3quLKhHw4Ybk8', | |
13 | 'ext': 'mp4', | |
14 | 'title': 'Inserting and Aligning the Case Top and Bottom', | |
15 | 'description': '', | |
16 | 'uploader': 'Paul Gunn', | |
17 | 'extra_param_to_segment_url': str, | |
18 | }, | |
19 | 'params': { | |
20 | 'skip_download': 'm3u8', | |
21 | }, | |
22 | }] | |
23 | ||
24 | def _real_extract(self, url): | |
25 | video_id = self._match_id(url) | |
26 | info = self._download_json( | |
27 | f'https://umbrella.svc.screencastify.com/api/umbrellaService/watch/{video_id}', video_id) | |
28 | ||
29 | query_string = traverse_obj(info, ('manifest', 'auth', 'query')) | |
30 | query = urllib.parse.parse_qs(query_string) | |
31 | formats = [] | |
32 | dash_manifest_url = traverse_obj(info, ('manifest', 'url')) | |
33 | if dash_manifest_url: | |
34 | formats.extend( | |
35 | self._extract_mpd_formats( | |
36 | dash_manifest_url, video_id, mpd_id='dash', query=query, fatal=False)) | |
37 | hls_manifest_url = traverse_obj(info, ('manifest', 'hlsUrl')) | |
38 | if hls_manifest_url: | |
39 | formats.extend( | |
40 | self._extract_m3u8_formats( | |
41 | hls_manifest_url, video_id, ext='mp4', m3u8_id='hls', query=query, fatal=False)) | |
42 | for f in formats: | |
43 | f['url'] = update_url_query(f['url'], query) | |
44 | ||
45 | return { | |
46 | 'id': video_id, | |
47 | 'title': info.get('title'), | |
48 | 'description': info.get('description'), | |
49 | 'uploader': info.get('userName'), | |
50 | 'formats': formats, | |
51 | 'extra_param_to_segment_url': query_string, | |
52 | } |