]> jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/webcamerapl.py
[ie/orf:on] Improve extraction (#9677)
[yt-dlp.git] / yt_dlp / extractor / webcamerapl.py
1 import codecs
2
3 from .common import InfoExtractor
4
5
6 class WebcameraplIE(InfoExtractor):
7 _VALID_URL = r'https?://(?P<id>[\w-]+)\.webcamera\.pl'
8 _TESTS = [{
9 'url': 'https://warszawa-plac-zamkowy.webcamera.pl',
10 'info_dict': {
11 'id': 'warszawa-plac-zamkowy',
12 'ext': 'mp4',
13 'title': r're:WIDOK NA PLAC ZAMKOWY W WARSZAWIE \d{4}-\d{2}-\d{2} \d{2}:\d{2}$',
14 'live_status': 'is_live',
15 }
16 }, {
17 'url': 'https://gdansk-stare-miasto.webcamera.pl/',
18 'info_dict': {
19 'id': 'gdansk-stare-miasto',
20 'ext': 'mp4',
21 'title': r're:GDAƃSK - widok na Stare Miasto \d{4}-\d{2}-\d{2} \d{2}:\d{2}$',
22 'live_status': 'is_live',
23 }
24 }]
25
26 def _real_extract(self, url):
27 video_id = self._match_id(url)
28 webpage = self._download_webpage(url, video_id)
29
30 rot13_m3u8_url = self._search_regex(r'data-src\s*=\s*"(uggc[^"]+\.z3h8)"',
31 webpage, 'm3u8 url', default=None)
32 if not rot13_m3u8_url:
33 self.raise_no_formats('No video/audio found at the provided url', expected=True)
34
35 m3u8_url = codecs.decode(rot13_m3u8_url, 'rot-13')
36 formats, subtitles = self._extract_m3u8_formats_and_subtitles(m3u8_url, video_id, live=True)
37
38 return {
39 'id': video_id,
40 'title': self._html_search_regex(r'<h1\b[^>]*>([^>]+)</h1>', webpage, 'title'),
41 'formats': formats,
42 'subtitles': subtitles,
43 'is_live': True,
44 }