From 8cd0f510eec1e560b6e44f8e86839fff2e3afbc7 Mon Sep 17 00:00:00 2001 From: Iuri Campos Date: Fri, 16 May 2025 13:09:14 +0100 Subject: [PATCH 1/5] [ie/pandavideo] Add extractor Fixes #13109 Implementation of extractor for video host provider pandavideo. Works on direct urls or embedded videos in websites. Closes #13109 Co-authored-by: Miguel Noronha --- yt_dlp/extractor/_extractors.py | 1 + yt_dlp/extractor/pandavideo.py | 76 +++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 yt_dlp/extractor/pandavideo.py diff --git a/yt_dlp/extractor/_extractors.py b/yt_dlp/extractor/_extractors.py index bb1c3db16e..dc4dd28d70 100644 --- a/yt_dlp/extractor/_extractors.py +++ b/yt_dlp/extractor/_extractors.py @@ -1488,6 +1488,7 @@ PalcoMP3IE, PalcoMP3VideoIE, ) +from .pandavideo import PandaVideoIE from .panopto import ( PanoptoIE, PanoptoListIE, diff --git a/yt_dlp/extractor/pandavideo.py b/yt_dlp/extractor/pandavideo.py new file mode 100644 index 0000000000..0b609c9053 --- /dev/null +++ b/yt_dlp/extractor/pandavideo.py @@ -0,0 +1,76 @@ +from .common import InfoExtractor + + +class PandaVideoIE(InfoExtractor): + _VALID_URL = r'https?://(?P[\w-]+)\.tv\.pandavideo\.com\.br/embed/?\?(?:[^#]*&)?v=(?P[\da-f-]+)' + _EMBED_REGEX = [rf']+\bsrc=[\'"](?P{_VALID_URL})'] + _WEBPAGE_TESTS = [{ + # Embedebd video test + 'url': 'https://www.pandavideo.com/', + 'info_dict': { + 'id': '1234567890', + 'ext': 'mp4', + 'title': 'Panda Video - Hospedagem de video', + }, + }, { + # Embedebd video test + 'url': 'https://help.pandavideo.com/pt-br/article/panda-video-e-mais-seguro-que-vimeo-1dicmr5/', + 'info_dict': { + 'id': '1234567890', + 'ext': 'mp4', + 'title': 'Panda Video - Hospedagem de video', + }, + }] + _TESTS = [{ + # Direct Link to video + 'url': 'https://player-vz-12fdccf8-e93.tv.pandavideo.com.br/embed/?v=fc6c9c66-ecc7-4828-a63a-5f3e6f481d7f', + 'info_dict': { + 'id': 'fc6c9c66-ecc7-4828-a63a-5f3e6f481d7f', + 'ext': 'mp4', + 'title': 'Panda Video - Hospedagem de video', + }, + }, { + # Direct Link to video + 'url': 'https://player-vz-ded14ebd-85a.tv.pandavideo.com.br/embed/?v=79cb9b0e-a64b-4485-8a44-47f36b292e4c', + 'info_dict': { + 'id': '79cb9b0e-a64b-4485-8a44-47f36b292e4c', + 'ext': 'mp4', + 'title': 'Panda Video - Hospedagem de video', + }, + }, { + # Direct Link to video + 'url': 'https://player-vz-ded14ebd-85a.tv.pandavideo.com.br/embed/?v=2bf42e2c-e804-4637-94c3-81f0b06dc64d', + 'info_dict': { + 'id': '2bf42e2c-e804-4637-94c3-81f0b06dc64d', + 'ext': 'mp4', + 'title': 'Panda Video - Hospedagem de video', + }, + }, { + # Invalid Link to video + 'url': 'https://player-vz-ded14ebd-85a.tv.pandavideo.com.br/embed/?v=2bf42e2c-e804-4637-94c3', + 'info_dict': { + 'id': '2bf42e2c-e804-4637-94c3', + 'ext': 'mp4', + 'title': 'pandavideo_2bf42e2c-e804-4637-94c3', + }, + }, { + # Direct Link to video + 'url': 'https://player-vz-ded14ebd-85a.tv.pandavideo.com.br/embed/?v=3b101f05-84aa-4de0-9b64-71f1855388af', + 'info_dict': { + 'id': '3b101f05-84aa-4de0-9b64-71f1855388af', + 'ext': 'mp4', + 'title': 'pandavideo_3b101f05-84aa-4de0-9b64-71f1855388af', + }, + }] + + def _real_extract(self, url: str) -> dict: + server, video_id = self._match_valid_url(url).groups() + manifest_url = f'https://{server}.tv.pandavideo.com.br/{video_id}/playlist.m3u8' + webpage = self._download_webpage(url, video_id) + return { + 'id': video_id, + 'url': url, + 'title': self._html_search_regex(r'([^<]+)', webpage, 'title', default=f'pandavideo_{video_id}', fatal=False), + 'description': self._html_search_meta('description', webpage, 'description', default=None, fatal=False), + 'formats': self._extract_m3u8_formats(manifest_url, video_id), + } From 24a6366f5eddea09b78b464fffa6a5022ce3e392 Mon Sep 17 00:00:00 2001 From: Iuri Campos Date: Sun, 1 Jun 2025 18:13:19 +0100 Subject: [PATCH 2/5] Update yt_dlp/extractor/pandavideo.py Co-authored-by: bashonly <88596187+bashonly@users.noreply.github.com> --- yt_dlp/extractor/pandavideo.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/yt_dlp/extractor/pandavideo.py b/yt_dlp/extractor/pandavideo.py index 0b609c9053..c241442790 100644 --- a/yt_dlp/extractor/pandavideo.py +++ b/yt_dlp/extractor/pandavideo.py @@ -65,11 +65,12 @@ class PandaVideoIE(InfoExtractor): def _real_extract(self, url: str) -> dict: server, video_id = self._match_valid_url(url).groups() - manifest_url = f'https://{server}.tv.pandavideo.com.br/{video_id}/playlist.m3u8' webpage = self._download_webpage(url, video_id) + return { 'id': video_id, - 'url': url, + 'formats': self._extract_m3u8_formats( + f'https://{server}.tv.pandavideo.com.br/{video_id}/playlist.m3u8', video_id, 'mp4', m3u8_id='hls'), 'title': self._html_search_regex(r'([^<]+)', webpage, 'title', default=f'pandavideo_{video_id}', fatal=False), 'description': self._html_search_meta('description', webpage, 'description', default=None, fatal=False), 'formats': self._extract_m3u8_formats(manifest_url, video_id), From 31c6081b7cdc4f8fbe8bda015131d6b5c8a248b6 Mon Sep 17 00:00:00 2001 From: Iuri Campos Date: Sun, 1 Jun 2025 18:22:45 +0100 Subject: [PATCH 3/5] removed extra line 'formats' --- yt_dlp/extractor/pandavideo.py | 1 - 1 file changed, 1 deletion(-) diff --git a/yt_dlp/extractor/pandavideo.py b/yt_dlp/extractor/pandavideo.py index c241442790..7fc2ad8a68 100644 --- a/yt_dlp/extractor/pandavideo.py +++ b/yt_dlp/extractor/pandavideo.py @@ -73,5 +73,4 @@ def _real_extract(self, url: str) -> dict: f'https://{server}.tv.pandavideo.com.br/{video_id}/playlist.m3u8', video_id, 'mp4', m3u8_id='hls'), 'title': self._html_search_regex(r'([^<]+)', webpage, 'title', default=f'pandavideo_{video_id}', fatal=False), 'description': self._html_search_meta('description', webpage, 'description', default=None, fatal=False), - 'formats': self._extract_m3u8_formats(manifest_url, video_id), } From 2156f3da0e4793d35eb76837b0d4bafe1b1085e1 Mon Sep 17 00:00:00 2001 From: Iuri Campos Date: Sun, 1 Jun 2025 20:41:06 +0100 Subject: [PATCH 4/5] Update yt_dlp/extractor/pandavideo.py Co-authored-by: bashonly <88596187+bashonly@users.noreply.github.com> --- yt_dlp/extractor/pandavideo.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/yt_dlp/extractor/pandavideo.py b/yt_dlp/extractor/pandavideo.py index 7fc2ad8a68..27451b2786 100644 --- a/yt_dlp/extractor/pandavideo.py +++ b/yt_dlp/extractor/pandavideo.py @@ -2,8 +2,8 @@ class PandaVideoIE(InfoExtractor): - _VALID_URL = r'https?://(?P[\w-]+)\.tv\.pandavideo\.com\.br/embed/?\?(?:[^#]*&)?v=(?P[\da-f-]+)' - _EMBED_REGEX = [rf']+\bsrc=[\'"](?P{_VALID_URL})'] + _VALID_URL = r'https?://(?P[\w-]+)\.tv\.pandavideo\.com\.br/embed/?\?(?:[^#"\']*&)?v=(?P[\da-f-]+)' + _EMBED_REGEX = [rf']+\bsrc=["\'](?P{_VALID_URL})'] _WEBPAGE_TESTS = [{ # Embedebd video test 'url': 'https://www.pandavideo.com/', From af61db38f39bea2345c1e29f1389ba8556b7a7da Mon Sep 17 00:00:00 2001 From: Iuri Campos Date: Sun, 1 Jun 2025 20:41:32 +0100 Subject: [PATCH 5/5] Update yt_dlp/extractor/pandavideo.py Co-authored-by: bashonly <88596187+bashonly@users.noreply.github.com> --- yt_dlp/extractor/pandavideo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yt_dlp/extractor/pandavideo.py b/yt_dlp/extractor/pandavideo.py index 27451b2786..5dd0df23c5 100644 --- a/yt_dlp/extractor/pandavideo.py +++ b/yt_dlp/extractor/pandavideo.py @@ -64,7 +64,7 @@ class PandaVideoIE(InfoExtractor): }] def _real_extract(self, url: str) -> dict: - server, video_id = self._match_valid_url(url).groups() + server, video_id = self._match_valid_url(url).group('server', 'id') webpage = self._download_webpage(url, video_id) return {