]>
Commit | Line | Data |
---|---|---|
1 | from .common import InfoExtractor | |
2 | from ..utils import traverse_obj | |
3 | ||
4 | ||
5 | class Screen9IE(InfoExtractor): | |
6 | _VALID_URL = r'https?://(?:\w+\.screen9\.(?:tv|com)|play\.su\.se)/(?:embed|media)/(?P<id>[^?#/]+)' | |
7 | _TESTS = [ | |
8 | { | |
9 | 'url': 'https://api.screen9.com/embed/8kTNEjvoXGM33dmWwF0uDA', | |
10 | 'md5': 'd60d23f8980583b930724b01fa6ddb41', | |
11 | 'info_dict': { | |
12 | 'id': '8kTNEjvoXGM33dmWwF0uDA', | |
13 | 'ext': 'mp4', | |
14 | 'title': 'Östersjön i förändrat klimat', | |
15 | 'thumbnail': r're:^https?://.+\.jpg', | |
16 | }, | |
17 | }, | |
18 | { | |
19 | 'url': 'https://folkhogskolekanalen.screen9.tv/media/gy35PKLHe-5K29RYHga2bw/ett-starkare-samhalle-en-snabbguide-om-sveriges-folkhogskolor', | |
20 | 'md5': 'c9389806e78573ea34fc48b6f94465dc', | |
21 | 'info_dict': { | |
22 | 'id': 'gy35PKLHe-5K29RYHga2bw', | |
23 | 'ext': 'mp4', | |
24 | 'title': 'Ett starkare samhälle - en snabbguide om Sveriges folkhögskolor', | |
25 | 'thumbnail': r're:^https?://.+\.jpg', | |
26 | }, | |
27 | }, | |
28 | { | |
29 | 'url': 'https://play.su.se/media/H1YA0EYNCxiesrSU1kaRBQ/baltic-breakfast', | |
30 | 'md5': '2b817647c3058002526269deff4c0683', | |
31 | 'info_dict': { | |
32 | 'id': 'H1YA0EYNCxiesrSU1kaRBQ', | |
33 | 'ext': 'mp4', | |
34 | 'title': 'Baltic Breakfast', | |
35 | 'thumbnail': r're:^https?://.+\.jpg', | |
36 | }, | |
37 | }, | |
38 | ] | |
39 | ||
40 | def _real_extract(self, url): | |
41 | video_id = self._match_id(url) | |
42 | webpage = self._download_webpage(f'https://api.screen9.com/embed/{video_id}', video_id) | |
43 | config = self._search_json(r'var\s+config\s*=', webpage, 'config', video_id) | |
44 | formats, subtitles = self._extract_m3u8_formats_and_subtitles( | |
45 | traverse_obj(config, ('src', lambda _, v: v['type'] == 'application/x-mpegURL', 'src'), get_all=False), | |
46 | video_id, ext='mp4') | |
47 | formats.append({ | |
48 | 'url': traverse_obj(config, ('src', lambda _, v: v['type'] == 'video/mp4', 'src'), get_all=False), | |
49 | 'format': 'mp4', | |
50 | }) | |
51 | ||
52 | return { | |
53 | 'id': video_id, | |
54 | 'title': traverse_obj( | |
55 | config, | |
56 | ('plugins', (('title', 'title'), ('googleAnalytics', 'title'), ('share', 'mediaTitle'))), | |
57 | get_all=False), | |
58 | 'description': traverse_obj(config, ('plugins', 'title', 'description')), | |
59 | 'thumbnail': traverse_obj(config, ('poster')), | |
60 | 'formats': formats, | |
61 | 'subtitles': subtitles, | |
62 | } |