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

Code before:
        # 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 (suggestion):
```suggestion
        video_id = self._match_id(url)
```

Code after:
            '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)
        video_id = video_data['VroomItemId']

        parsed_url = urllib.parse.urlparse(video_data['.transformUrl'])
        base_media_url = urllib.parse.urlunparse(parsed_url._replace(
            path=urllib.parse.urljoin(f'{parsed_url.path}/', '../videomanifest'),
            query=urllib.parse.urlencode({
                **urllib.parse.parse_qs(parsed_url.query),
                'cTag': video_data['.ctag'],
                'action': 'Access',
                'part': 'index',
            }, doseq=True)))

        # Web player adds more params to the format URLs but we still get all formats without them