Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/sharepoint.py (Python)

Code before:
            'params': {'skip_download': 'm3u8'}
        },
    ]

    def _parse_mediapackage(self, video, video_id):
        formats = []

        base_media_url = video['.transformUrl'].replace('/thumbnail?', '/videomanifest?')
        base_media_url += f"&cTag={video['.ctag']}&action=Access&part=index"

        metadata = json.loads(video.get('MediaServiceFastMetadata'))

        # Normally the player is configured with all possible options added to the format URLs,
        # but we always get all formats back no matter what settings you send
        formats.extend(self._extract_mpd_formats(
            f"{base_media_url}&format=dash", video_id, mpd_id='dash', fatal=False
        ))
        formats.extend(self._extract_m3u8_formats(
            f"{base_media_url}&format=hls", video_id, m3u8_id='hls', entry_protocol='m3u8_native',
            fatal=False
        ))
        # HLSv6
        formats.extend(self._extract_m3u8_formats(
            f"{base_media_url}&format=hls-vnext", video_id, m3u8_id='hls-vnext',
            entry_protocol='m3u8_native', fatal=False
        ))

        # Most formats are found multiple times, we remove the occurrences without metadata
        formats = [x for x in formats if x.get('ext') is not None]

        return {
            'id': video_id,
            'formats': formats,
            'title': video.get('name'),
            'duration': float_or_none(traverse_obj(metadata, ('media', 'duration')), scale=10000000),
        }

    def _real_extract(self, url):
        video_id = self._match_valid_url(url).group('id')
        webpage = self._download_webpage(url, video_id)

        player_config = self._search_json(r'g_fileInfo\s*=', webpage, 'player config', video_id)

        return self._parse_mediapackage(player_config, video_id)


Review comment (refactor):
```suggestion
        formats = self._extract_mpd_formats(
            f'{base_media_url}&format=dash', video_id, mpd_id='dash', fatal=False)
        formats.extend(self._extract_m3u8_formats(
            f'{base_media_url}&format=hls', video_id, m3u8_id='hls', fatal=False))
        formats.extend(self._extract_m3u8_formats(
            f'{base_media_url}&format=hls-vnext', video_id, m3u8_id='hls-vnext', fatal=False))
```

Code after:
            'title': 'CmvpJST',
            'duration': 54.567,
            'thumbnail': r're:https://.+/thumbnail',
            'uploader_id': '8dcec565-a956-4b91-95e5-bacfb8bc015f',
        },
    }, {
        'url': 'https://greaternyace.sharepoint.com/:v:/s/acementornydrive/ETski5eAfNVEoPRZUAyy1wEBpLgVFYWso5bjbZjfBLlPUg?e=PQUfVb',
        'md5': 'c496a01644223273bff12e93e501afd1',
        'info_dict': {
            'id': '01QI4AVTZ3ESFZPAD42VCKB5CZKAGLFVYB',
            'display_id': 'ETski5eAfNVEoPRZUAyy1wEBpLgVFYWso5bjbZjfBLlPUg',
            'ext': 'mp4',
            'title': '930103681233985536',
            'duration': 3797.326,
            'thumbnail': r're:https://.+/thumbnail',
        },
    }, {
        'url': 'https://lut-my.sharepoint.com/personal/juha_eerola_student_lab_fi/_layouts/15/stream.aspx?id=%2Fpersonal%2Fjuha_eerola_student_lab_fi%2FDocuments%2FM-DL%2FCmvpJST.mp4&ga=1&referrer=StreamWebApp.Web&referrerScenario=AddressBarCopied.view',
        'info_dict': {
            'id': '01EQRS7EKKYCNLSLLPQZGIKRYY6SOY7KGB',
            'display_id': '/personal/juha_eerola_student_lab_fi/Documents/M-DL/CmvpJST.mp4',
            'ext': 'mp4',
            'title': 'CmvpJST',
            'duration': 54.567,
            'thumbnail': r're:https://.+/thumbnail',
            'uploader_id': '8dcec565-a956-4b91-95e5-bacfb8bc015f',
        },
        'skip': 'Session cookies needed',
    }, {
        'url': 'https://izoobasisschool.sharepoint.com/:v:/g/Eaqleq8COVBIvIPvod0U27oBypC6aWOkk8ptuDpmJ6arHw',
        'only_matching': True,
    }, {
        'url': 'https://uskudaredutr-my.sharepoint.com/:v:/g/personal/songul_turkaydin_uskudar_edu_tr/EbTf-VRUIbtGuIN73tx1MuwBCHBOmNcWNqSLw61Fd2_o0g?e=n5Vkof',
        'only_matching': True,
    }, {
        'url': 'https://epam-my.sharepoint.com/:v:/p/dzmitry_tamashevich/Ec4ZOs-rATZHjFYZWVxjczEB649FCoYFKDV_x3RxZiWAGA?e=4hswgA',
        'only_matching': True,
    }, {
        'url': 'https://microsoft.sharepoint.com/:v:/t/MicrosoftSPARKRecordings-MSFTInternal/EWCyeqByVWBAt8wDvNZdV-UB0BvU5YVbKm0UHgdrUlI6dg?e=QbPck6',
        'only_matching': True,
    }]

    def _real_extract(self, url):
        display_id = urllib.parse.unquote(self._match_id(url))
        webpage, urlh = self._download_webpage_handle(url, display_id)
        if urllib.parse.urlparse(urlh.url).hostname == 'login.microsoftonline.com':
            self.raise_login_required(
                'Session cookies are required for this URL and can be passed '
                'with the --cookies option. The --cookies-from-browser option will not work', method=None)

        video_data = self._search_json(r'g_fileInfo\s*=', webpage, 'player config', display_id)