]> jfr.im git - yt-dlp.git/blame - yt_dlp/extractor/daystar.py
[ie/youtube] Suppress "Unavailable videos are hidden" warning (#10159)
[yt-dlp.git] / yt_dlp / extractor / daystar.py
CommitLineData
761fba6d
HTL
1from .common import InfoExtractor
2from ..utils import js_to_json, urljoin
3
4
5class 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)
761fba6d
HTL
39
40 return {
41 'id': video_id,
42 'title': self._html_search_meta(['og:title', 'twitter:title'], webpage),
43 'description': self._html_search_meta(['og:description', 'twitter:description'], webpage),
44 'thumbnail': self._search_regex(r'image:\s*"([^"]+)', webpage_iframe, 'thumbnail'),
45 'formats': formats,
46 'subtitles': subtitles,
47 }