From 172bfb74b0b1e61e0f2b125a095186abf9159963 Mon Sep 17 00:00:00 2001 From: HobbyistDev Date: Sat, 10 Aug 2024 20:11:12 +0900 Subject: [PATCH] [extractor/piramidetv] Add PiramideTV extractor --- yt_dlp/extractor/_extractors.py | 1 + yt_dlp/extractor/piramidetv.py | 45 +++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 yt_dlp/extractor/piramidetv.py diff --git a/yt_dlp/extractor/_extractors.py b/yt_dlp/extractor/_extractors.py index 9b73fcd75..ca60a8df6 100644 --- a/yt_dlp/extractor/_extractors.py +++ b/yt_dlp/extractor/_extractors.py @@ -1522,6 +1522,7 @@ from .pinterest import ( PinterestCollectionIE, PinterestIE, ) +from .piramidetv import PiramideTVIE from .pixivsketch import ( PixivSketchIE, PixivSketchUserIE, diff --git a/yt_dlp/extractor/piramidetv.py b/yt_dlp/extractor/piramidetv.py new file mode 100644 index 000000000..15623a8a4 --- /dev/null +++ b/yt_dlp/extractor/piramidetv.py @@ -0,0 +1,45 @@ +from .common import InfoExtractor +from ..utils import unified_timestamp +from ..utils.traversal import traverse_obj + + +class PiramideTVIE(InfoExtractor): + _VALID_URL = [ + r'https?://piramide\.tv/video/(?P[^/]+)', + ] + _TESTS = [{ + 'url': 'https://piramide.tv/video/wcYn6li79NgN', + 'info_dict': { + 'id': 'wcYn6li79NgN', + 'ext': 'mp4', + 'channel': 'ARTA GAME', + 'channel_id': 'arta_game', + 'thumbnail_url': 'https://cdn.jwplayer.com/v2/media/cnEdGp5X/thumbnails/rHAaWfP7.jpg', + 'title': 'ACEPTO TENER UN BEBE CON MI NOVIA…? | Parte 1', + 'timestamp': 1703434976, + 'upload_date': '20231224', + }, + }] + + def _real_extract(self, url): + video_id = self._match_valid_url(url).group('video_id') + json_data = self._download_json( + f'https://hermes.piramide.tv/video/data/{video_id}', video_id)['video'] + + formats, subtitles = self._extract_m3u8_formats_and_subtitles( + f'https://cdn.piramide.tv/video/{video_id}/manifest.m3u8', video_id, + ) + + return { + 'id': video_id, + 'display_id': video_id, + 'formats': formats, + 'subtitles': subtitles, + **traverse_obj(json_data, { + 'title': 'title', + 'thumbnail_url': ('media', 'thumbnail'), + 'channel': ('channel', 'name'), + 'channel_id': ('channel', 'id'), + 'timestamp': ('date', {unified_timestamp}), + }), + }