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

Code before:
        video_id = self._match_id(url)
        webpage = self._download_webpage(url, video_id)

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

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

        # The player is configured with a number of options that are then added to the format URLs,
        # but we always get all formats back no matter what options we send
        hls_formats = self._extract_m3u8_formats(
            f'{base_media_url}&format=hls', video_id, m3u8_id='hls', fatal=False)
        hls_formats.extend(self._extract_m3u8_formats(
            f'{base_media_url}&format=hls-vnext', video_id, m3u8_id='hls-vnext', fatal=False))
        for hls_format in hls_formats:
            hls_format['preference'] = -2
        formats = self._extract_mpd_formats(
            f'{base_media_url}&format=dash', video_id, mpd_id='dash', fatal=False)
        formats.extend(hls_formats)

        return {
            'id': video_id,
            'formats': formats,
            'title': video.get('name'),
            'duration': traverse_obj(
                video, ('MediaServiceFastMetadata', {json.loads}, 'media', 'duration', {lambda x: x / 10000000})
            ),
        }


Review comment (suggestion):
```suggestion
            hls_format['quality'] = -2
```

Code after:
            '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)
        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)))