]> jfr.im git - yt-dlp.git/commitdiff
[extractor/webcamerapl] Add extractor (#5715)
authormilkknife <redacted>
Thu, 8 Dec 2022 16:56:36 +0000 (17:56 +0100)
committerGitHub <redacted>
Thu, 8 Dec 2022 16:56:36 +0000 (22:26 +0530)
Authored by: milkknife

yt_dlp/extractor/_extractors.py
yt_dlp/extractor/webcamerapl.py [new file with mode: 0644]

index b1d0a9fb0249dc266abddbbd30fd82cac407c6d1..c3eb2bb77908851ef311f9f20fb07a17ac5eafeb 100644 (file)
     WDRElefantIE,
     WDRMobileIE,
 )
+from .webcamerapl import WebcameraplIE
 from .webcaster import (
     WebcasterIE,
     WebcasterFeedIE,
diff --git a/yt_dlp/extractor/webcamerapl.py b/yt_dlp/extractor/webcamerapl.py
new file mode 100644 (file)
index 0000000..a02d951
--- /dev/null
@@ -0,0 +1,44 @@
+import codecs
+
+from .common import InfoExtractor
+
+
+class WebcameraplIE(InfoExtractor):
+    _VALID_URL = r'https?://(?P<id>[\w-]+)\.webcamera\.pl'
+    _TESTS = [{
+        'url': 'https://warszawa-plac-zamkowy.webcamera.pl',
+        'info_dict': {
+            'id': 'warszawa-plac-zamkowy',
+            'ext': 'mp4',
+            'title': r're:WIDOK NA PLAC ZAMKOWY W WARSZAWIE \d{4}-\d{2}-\d{2} \d{2}:\d{2}$',
+            'live_status': 'is_live',
+        }
+    }, {
+        'url': 'https://gdansk-stare-miasto.webcamera.pl/',
+        'info_dict': {
+            'id': 'gdansk-stare-miasto',
+            'ext': 'mp4',
+            'title': r're:GDAƃSK - widok na Stare Miasto \d{4}-\d{2}-\d{2} \d{2}:\d{2}$',
+            'live_status': 'is_live',
+        }
+    }]
+
+    def _real_extract(self, url):
+        video_id = self._match_id(url)
+        webpage = self._download_webpage(url, video_id)
+
+        rot13_m3u8_url = self._search_regex(r'data-src\s*=\s*"(uggc[^"]+\.z3h8)"',
+                                            webpage, 'm3u8 url', default=None)
+        if not rot13_m3u8_url:
+            self.raise_no_formats('No video/audio found at the provided url', expected=True)
+
+        m3u8_url = codecs.decode(rot13_m3u8_url, 'rot-13')
+        formats, subtitles = self._extract_m3u8_formats_and_subtitles(m3u8_url, video_id, live=True)
+
+        return {
+            'id': video_id,
+            'title': self._html_search_regex(r'<h1\b[^>]*>([^>]+)</h1>', webpage, 'title'),
+            'formats': formats,
+            'subtitles': subtitles,
+            'is_live': True,
+        }