]>
Commit | Line | Data |
---|---|---|
761fba6d HTL |
1 | from .common import InfoExtractor |
2 | from ..utils import js_to_json, urljoin | |
3 | ||
4 | ||
5 | class DaystarClipIE(InfoExtractor): | |
6 | IE_NAME = 'daystar:clip' | |
7 | _VALID_URL = r'https?://player\.daystar\.tv/(?P<id>\w+)' | |
8 | _TESTS = [{ | |
9 | 'url': 'https://player.daystar.tv/0MTO2ITM', | |
10 | 'info_dict': { | |
11 | 'id': '0MTO2ITM', | |
12 | 'ext': 'mp4', | |
13 | 'title': 'The Dark World of COVID Pt. 1 | Aaron Siri', | |
14 | 'description': 'a420d320dda734e5f29458df3606c5f4', | |
15 | 'thumbnail': r're:^https?://.+\.jpg', | |
16 | }, | |
17 | }] | |
18 | ||
19 | def _real_extract(self, url): | |
20 | video_id = self._match_id(url) | |
21 | webpage = self._download_webpage(url, video_id) | |
22 | ||
23 | src_iframe = self._search_regex(r'\<iframe[^>]+src="([^"]+)"', webpage, 'src iframe') | |
24 | webpage_iframe = self._download_webpage( | |
25 | src_iframe.replace('player.php', 'config2.php'), video_id, headers={'Referer': src_iframe}) | |
26 | ||
27 | sources = self._parse_json(self._search_regex( | |
28 | r'sources\:\s*(\[.*?\])', webpage_iframe, 'm3u8 source'), video_id, transform_source=js_to_json) | |
29 | ||
30 | formats, subtitles = [], {} | |
31 | for source in sources: | |
32 | file = source.get('file') | |
33 | if file and source.get('type') == 'm3u8': | |
34 | fmts, subs = self._extract_m3u8_formats_and_subtitles( | |
35 | urljoin('https://www.lightcast.com/embed/', file), | |
36 | video_id, 'mp4', fatal=False, headers={'Referer': src_iframe}) | |
37 | formats.extend(fmts) | |
38 | subtitles = self._merge_subtitles(subtitles, subs) | |
39 | self._sort_formats(formats) | |
40 | ||
41 | return { | |
42 | 'id': video_id, | |
43 | 'title': self._html_search_meta(['og:title', 'twitter:title'], webpage), | |
44 | 'description': self._html_search_meta(['og:description', 'twitter:description'], webpage), | |
45 | 'thumbnail': self._search_regex(r'image:\s*"([^"]+)', webpage_iframe, 'thumbnail'), | |
46 | 'formats': formats, | |
47 | 'subtitles': subtitles, | |
48 | } |