summaryrefslogtreecommitdiffstats
path: root/yt_dlp/extractor/peertv.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 16:49:24 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 16:49:24 +0000
commit2415e66f889f38503b73e8ebc5f43ca342390e5c (patch)
treeac48ab69d1d96bae3d83756134921e0d90593aa5 /yt_dlp/extractor/peertv.py
parentInitial commit. (diff)
downloadyt-dlp-2415e66f889f38503b73e8ebc5f43ca342390e5c.tar.xz
yt-dlp-2415e66f889f38503b73e8ebc5f43ca342390e5c.zip
Adding upstream version 2024.03.10.upstream/2024.03.10
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'yt_dlp/extractor/peertv.py')
-rw-r--r--yt_dlp/extractor/peertv.py52
1 files changed, 52 insertions, 0 deletions
diff --git a/yt_dlp/extractor/peertv.py b/yt_dlp/extractor/peertv.py
new file mode 100644
index 0000000..a709e21
--- /dev/null
+++ b/yt_dlp/extractor/peertv.py
@@ -0,0 +1,52 @@
+from .common import InfoExtractor
+from ..utils import js_to_json
+
+
+class PeerTVIE(InfoExtractor):
+ IE_NAME = 'peer.tv'
+ _VALID_URL = r'https?://(?:www\.)?peer\.tv/(?:de|it|en)/(?P<id>\d+)'
+ _TESTS = [{
+ 'url': 'https://www.peer.tv/de/841',
+ 'info_dict': {
+ 'id': '841',
+ 'ext': 'mp4',
+ 'title': 'Die Brunnenburg',
+ 'description': 'md5:4395f6142b090338340ab88a3aae24ed',
+ },
+ }, {
+ 'url': 'https://www.peer.tv/it/404',
+ 'info_dict': {
+ 'id': '404',
+ 'ext': 'mp4',
+ 'title': 'Cascate di ghiaccio in Val Gardena',
+ 'description': 'md5:e8e5907f236171842674e8090e3577b8',
+ },
+ }]
+
+ def _real_extract(self, url):
+ video_id = self._match_id(url)
+ webpage = self._download_webpage(url, video_id)
+
+ video_key = self._html_search_regex(r'player\.peer\.tv/js/([a-zA-Z0-9]+)', webpage, 'video key')
+
+ js = self._download_webpage(f'https://player.peer.tv/js/{video_key}/', video_id,
+ headers={'Referer': 'https://www.peer.tv/'}, note='Downloading session id')
+
+ session_id = self._search_regex(r'["\']session_id["\']:\s*["\']([a-zA-Z0-9]+)["\']', js, 'session id')
+
+ player_webpage = self._download_webpage(
+ f'https://player.peer.tv/jsc/{video_key}/{session_id}?jsr=aHR0cHM6Ly93d3cucGVlci50di9kZS84NDE=&cs=UTF-8&mq=2&ua=0&webm=p&mp4=p&hls=1',
+ video_id, note='Downloading player webpage')
+
+ m3u8_url = self._search_regex(r'["\']playlist_url["\']:\s*(["\'][^"\']+["\'])', player_webpage, 'm3u8 url')
+ m3u8_url = self._parse_json(m3u8_url, video_id, transform_source=js_to_json)
+
+ formats = self._extract_m3u8_formats(m3u8_url, video_id, m3u8_id='hls')
+
+ return {
+ 'id': video_id,
+ 'title': self._html_search_regex(r'<h1>(.+?)</h1>', webpage, 'title').replace('\xa0', ' '),
+ 'formats': formats,
+ 'description': self._html_search_meta(('og:description', 'description'), webpage),
+ 'thumbnail': self._html_search_meta(('og:image', 'image'), webpage)
+ }