[cleanup] Misc (#8968)
[yt-dlp.git] / yt_dlp / extractor / webcamerapl.py
bloba02d9519c622134919da9040cc9178ff0e803fbf
1 import codecs
3 from .common import InfoExtractor
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',
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',
26 def _real_extract(self, url):
27 video_id = self._match_id(url)
28 webpage = self._download_webpage(url, video_id)
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)
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)
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,