From 97c9016f68f16ecf505cc943fe0f040de34a58f0 Mon Sep 17 00:00:00 2001 From: DTrombett Date: Sun, 22 Dec 2024 18:00:03 +0100 Subject: [PATCH] [ie/plutotvlive] Add pluto tv live --- yt_dlp/extractor/_extractors.py | 2 +- yt_dlp/extractor/plutotv.py | 52 +++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 1 deletion(-) diff --git a/yt_dlp/extractor/_extractors.py b/yt_dlp/extractor/_extractors.py index 967010826e..1065951c4a 100644 --- a/yt_dlp/extractor/_extractors.py +++ b/yt_dlp/extractor/_extractors.py @@ -1550,7 +1550,7 @@ from .pluralsight import ( PluralsightCourseIE, PluralsightIE, ) -from .plutotv import PlutoTVIE +from .plutotv import PlutoTVIE, PlutoTVLiveIE from .podbayfm import ( PodbayFMChannelIE, PodbayFMIE, diff --git a/yt_dlp/extractor/plutotv.py b/yt_dlp/extractor/plutotv.py index 234ee987b6..89ddf87588 100644 --- a/yt_dlp/extractor/plutotv.py +++ b/yt_dlp/extractor/plutotv.py @@ -190,3 +190,55 @@ class PlutoTVIE(InfoExtractor): playlist_id=video_json.get('_id', info_slug), playlist_title=playlist_title) return self._get_video_info(video_json, info_slug) + + +class PlutoTVLiveIE(InfoExtractor): + _VALID_URL = r'https?://(?:www\.)?pluto\.tv(?:/[^/]+)?/live-tv/(?P.+)' + _TESTS = [{ + 'url': 'https://pluto.tv/live-tv/6093f9281db477000759fce0', + 'info_dict': { + 'id': '6093f9281db477000759fce0', + 'ext': 'mp4', + 'live_status': 'is_live', + 'thumbnail': 'http://images.pluto.tv/channels/6093f9281db477000759fce0/featuredImage.jpg?fm=png&q=100', + 'title': r're:Super! SpongeBob', + 'display_id': 'super-spongebob-it', + }, + }] + + def _real_extract(self, url): + slug = self._match_id(url) + start = self._download_json('https://boot.pluto.tv/v4/start?appName=web&appVersion=10.0.0&clientID=88eb6ea8-2fcd-4e69-8caa-f543a79e509a&clientModelNumber=1.0.0&serverSideAds=false&deviceVersion=132.0.0&deviceModel=web&deviceMake=chrome&deviceType=web&channelSlug=' + slug, slug, 'Downloading info json') + channel = start['EPG'][0] + formats, subtitles = self._extract_m3u8_formats_and_subtitles(start['servers']['stitcher'] + '/v2' + channel['stitched']['path'] + '?' + start['stitcherParams'] + '&jwt=' + start['sessionToken'], channel['id']) + thumbnails = [] + for f in formats: + f['url'] += '&jwt=' + start['sessionToken'] + if f.get('vcodec') is None: + f['vcodec'] = 'avc1.64001f' + if f.get('acodec') is None: + f['acodec'] = 'mp4a.40.2' + if f.get('fps') is None: + f['fps'] = 30 + for image in channel['images']: + if image['type'] == 'featuredImage': + thumbnails.append({ + 'id': 'original', + 'url': re.sub(r'\?.*$', '?fm=png&q=100', image['url']), + 'preference': 1, + }) + thumbnails.append({ + 'id': image['type'], + 'url': image['url'], + 'width': image['defaultWidth'], + 'height': image['defaultHeight'], + }) + return { + 'id': channel['id'], + 'title': channel['name'], + 'display_id': channel['slug'], + 'thumbnails': thumbnails, + 'formats': formats, + 'subtitles': subtitles, + 'is_live': True, + }