add vodcast/podcast and some more fix

- vodcast: slides and main video are shown side by side
- podcast: audio only
- add one more acceptable slide file name template
- provide playbackTicket in slide image url
This commit is contained in:
kclauhk 2024-12-24 16:38:08 +08:00
parent 518bc52224
commit 04c4c807a2

View file

@ -6,6 +6,7 @@ from .common import InfoExtractor
from ..utils import ( from ..utils import (
ExtractorError, ExtractorError,
float_or_none, float_or_none,
join_nonempty,
mimetype2ext, mimetype2ext,
smuggle_url, smuggle_url,
str_or_none, str_or_none,
@ -93,16 +94,12 @@ class MediasiteIE(InfoExtractor):
'ext': 'mp4', 'ext': 'mp4',
'title': 'Practical Prevention, Detection and Responses to the New Threat Landscape', 'title': 'Practical Prevention, Detection and Responses to the New Threat Landscape',
'description': r're:^The bad guys arent standing still, and neither is Okta', 'description': r're:^The bad guys arent standing still, and neither is Okta',
'thumbnail': 'https://events7.mediasite.com/Mediasite/FileServer/Presentation/a7812390a2d44739ae857527e05776091d/16e2f205-41a7-4ea5-a031-5c6152afc7bf.jpg?playbackTicket=be2577e1d1fa4629abc0a2f56465b1a7', 'thumbnail': r're:^https://events7\.mediasite\.com/Mediasite/FileServer/Presentation/a7812390a2d44739ae857527e05776091d/16e2f205-41a7-4ea5-a031-5c6152afc7bf\.jpg',
'cast': ['Franklin Rosado', 'Alex Bovee'], 'cast': ['Franklin Rosado', 'Alex Bovee'],
'duration': 2415.487, 'duration': 2415.487,
'timestamp': 1472567400, 'timestamp': 1472567400,
'upload_date': '20160830', 'upload_date': '20160830',
}, },
'params': {
# frag 1 too small (only 768B)
'skip_download': True,
},
}, },
{ {
'url': 'https://collegerama.tudelft.nl/Mediasite/Showcase/livebroadcast/Presentation/ada7020854f743c49fbb45c9ec7dbb351d', 'url': 'https://collegerama.tudelft.nl/Mediasite/Showcase/livebroadcast/Presentation/ada7020854f743c49fbb45c9ec7dbb351d',
@ -135,9 +132,9 @@ class MediasiteIE(InfoExtractor):
def __extract_slides(self, *, stream_id, snum, stream, duration, images): def __extract_slides(self, *, stream_id, snum, stream, duration, images):
slide_base_url = stream['SlideBaseUrl'] slide_base_url = stream['SlideBaseUrl']
playback_ticket = stream.get('SlidePlaybackTicketId')
fname_template = stream['SlideImageFileNameTemplate'] fname_template = stream['SlideImageFileNameTemplate']
if fname_template != 'slide_{0:D4}.jpg': if fname_template != 'slide_{0:D4}.jpg' and fname_template != 'slide_%s_{0:D4}.jpg' % stream_id:
self.report_warning('Unusual slide file name template; report a bug if slide downloading fails') self.report_warning('Unusual slide file name template; report a bug if slide downloading fails')
fname_template = re.sub(r'\{0:D([0-9]+)\}', r'{0:0\1}', fname_template) fname_template = re.sub(r'\{0:D([0-9]+)\}', r'{0:0\1}', fname_template)
@ -163,7 +160,8 @@ class MediasiteIE(InfoExtractor):
expected_type=(int, float)) expected_type=(int, float))
fragments.append({ fragments.append({
'path': fname_template.format(slide.get('Number', i + 1)), 'path': join_nonempty(fname_template.format(slide.get('Number', i + 1)),
playback_ticket, delim='?playbackTicket='),
'duration': (next_time - slide['Time']) / 1000, 'duration': (next_time - slide['Time']) / 1000,
}) })
@ -209,13 +207,13 @@ class MediasiteIE(InfoExtractor):
}).encode())['d'] }).encode())['d']
presentation = player_options['Presentation'] presentation = player_options['Presentation']
title = presentation['Title']
if presentation is None: if presentation is None:
raise ExtractorError( raise ExtractorError(
'Mediasite says: {}'.format(player_options['PlayerPresentationStatusMessage']), 'Mediasite says: {}'.format(player_options['PlayerPresentationStatusMessage']),
expected=True) expected=True)
title = (presentation.get('Title')
or self._html_extract_title(webpage, 'title', fatal=False))
thumbnails = [] thumbnails = []
formats = [] formats = []
for snum, stream in enumerate(presentation['Streams']): for snum, stream in enumerate(presentation['Streams']):
@ -251,7 +249,7 @@ class MediasiteIE(InfoExtractor):
fatal=False)) fatal=False))
elif ext in ('m3u', 'm3u8'): elif ext in ('m3u', 'm3u8'):
stream_formats.extend(self._extract_m3u8_formats( stream_formats.extend(self._extract_m3u8_formats(
video_url, resource_id, video_url, resource_id, media_type.lower(),
m3u8_id=f'{stream_id}-{snum}.{unum}', m3u8_id=f'{stream_id}-{snum}.{unum}',
fatal=False)) fatal=False))
else: else:
@ -261,7 +259,8 @@ class MediasiteIE(InfoExtractor):
'ext': ext, 'ext': ext,
}) })
images = traverse_obj(player_options, ('PlayerLayoutOptions', 'Images', {dict}), default={}) images = traverse_obj(
player_options, ('PlayerLayoutOptions', 'Images', {dict}), default={})
if stream.get('HasSlideContent'): if stream.get('HasSlideContent'):
stream_formats.append(self.__extract_slides( stream_formats.append(self.__extract_slides(
stream_id=stream_id, stream_id=stream_id,
@ -285,6 +284,15 @@ class MediasiteIE(InfoExtractor):
}) })
formats.extend(stream_formats) formats.extend(stream_formats)
for i, cast_url in enumerate(('PodcastUrl', 'VodcastUrl')):
if url_or_none(presentation.get(cast_url)):
formats.append({
'format_id': cast_url.lower().replace('url', ''),
'url': presentation.get(cast_url).split('?attachmentName=')[0],
'vcodec': None if i else 'none',
'preference': None if i else -2,
})
# XXX: Presentation['Presenters'] # XXX: Presentation['Presenters']
# XXX: Presentation['Transcript'] # XXX: Presentation['Transcript']