From 882e3b753c79c7799ce135c3a5edb72494b576af Mon Sep 17 00:00:00 2001 From: "lauren n. liberda" Date: Sat, 10 Feb 2024 00:11:34 +0100 Subject: [PATCH] [ie/tvp] Support livestreams (#8860) Closes #8824 Authored by: selfisekai --- yt_dlp/extractor/tvp.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/yt_dlp/extractor/tvp.py b/yt_dlp/extractor/tvp.py index 2aa0dd870a6..a8d00e243ad 100644 --- a/yt_dlp/extractor/tvp.py +++ b/yt_dlp/extractor/tvp.py @@ -21,7 +21,7 @@ class TVPIE(InfoExtractor): IE_NAME = 'tvp' IE_DESC = 'Telewizja Polska' - _VALID_URL = r'https?://(?:[^/]+\.)?(?:tvp(?:parlament)?\.(?:pl|info)|tvpworld\.com|swipeto\.pl)/(?:(?!\d+/)[^/]+/)*(?P\d+)' + _VALID_URL = r'https?://(?:[^/]+\.)?(?:tvp(?:parlament)?\.(?:pl|info)|tvpworld\.com|swipeto\.pl)/(?:(?!\d+/)[^/]+/)*(?P\d+)(?:[/?#]|$)' _TESTS = [{ # TVPlayer 2 in js wrapper @@ -514,7 +514,7 @@ def _parse_video(self, video, with_url=True): class TVPVODVideoIE(TVPVODBaseIE): IE_NAME = 'tvp:vod' - _VALID_URL = r'https?://vod\.tvp\.pl/[a-z\d-]+,\d+/[a-z\d-]+(?\d+)(?:\?[^#]+)?(?:#.+)?$' + _VALID_URL = r'https?://vod\.tvp\.pl/(?P[a-z\d-]+,\d+)/[a-z\d-]+(?\d+)/?(?:[?#]|$)' _TESTS = [{ 'url': 'https://vod.tvp.pl/dla-dzieci,24/laboratorium-alchemika-odcinki,309338/odcinek-24,S01E24,311357', @@ -560,12 +560,23 @@ class TVPVODVideoIE(TVPVODBaseIE): 'thumbnail': 're:https?://.+', }, 'params': {'skip_download': 'm3u8'}, + }, { + 'url': 'https://vod.tvp.pl/live,1/tvp-world,399731', + 'info_dict': { + 'id': '399731', + 'ext': 'mp4', + 'title': r're:TVP WORLD \d{4}-\d{2}-\d{2} \d{2}:\d{2}', + 'live_status': 'is_live', + 'thumbnail': 're:https?://.+', + }, }] def _real_extract(self, url): - video_id = self._match_id(url) + category, video_id = self._match_valid_url(url).group('category', 'id') - info_dict = self._parse_video(self._call_api(f'vods/{video_id}', video_id), with_url=False) + is_live = category == 'live,1' + entity = 'lives' if is_live else 'vods' + info_dict = self._parse_video(self._call_api(f'{entity}/{video_id}', video_id), with_url=False) playlist = self._call_api(f'{video_id}/videos/playlist', video_id, query={'videoType': 'MOVIE'}) @@ -582,6 +593,8 @@ def _real_extract(self, url): 'ext': 'ttml', }) + info_dict['is_live'] = is_live + return info_dict