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

Code before:
            if password:
                content_id = self._search_regex(r'''content_id=(.*?)[\"\']''', webpage, 'content_id')
                payload = f'is_xhr=true&t={self._get_cookies("https://www.dropbox.com").get("t").value}&content_id={content_id}&password={password}&url={url}'
                response = self._download_json('https://www.dropbox.com/sm/auth', video_id, 'POSTing video password', data=payload.encode('UTF-8'), headers={'content-type': 'application/x-www-form-urlencoded; charset=UTF-8'})

                if response.get('status') == 'authed':
                    webpage = self._download_webpage(url, video_id)
                else:
                    raise ExtractorError('Authentication failed!', expected=True)

            elif self._get_cookies('https://dropbox.com').get('sm_auth'):
                webpage = self._download_webpage(url, video_id)

            else:
                raise ExtractorError('Password protected video, use --video-password <password>')

        json_string = self._html_search_regex(r'InitReact\.mountComponent.+ "props":(.+), "elem_id"', webpage, 'Info JSON')
        info_json = self._parse_json(json_string, video_id)
        transcode_url = traverse_obj(info_json, ((None, 'preview'), 'file', 'preview', 'content', 'transcode_url'), get_all=False)
        formats, subtitles = self._extract_m3u8_formats_and_subtitles(transcode_url, video_id)

        # downloads enabled we can get the original file
        if 'anonymous' in (try_get(info_json, lambda x: x['sharePermission']['canDownloadRoles']) or []):
            video_url = re.sub(r'[?&]dl=0', '', url)
            video_url += ('?' if '?' not in video_url else '&') + 'dl=1'
            formats.append({'url': video_url, 'format_id': 'original', 'format_note': 'Original'})

        return {
            'id': video_id,
            'title': title,
            'formats': formats,
            'subtitles': subtitles
        }


Review comment (suggestion):
```suggestion
            formats.append({'url': video_url, 'format_id': 'original', 'format_note': 'Original', 'quality': 1})
        self._sort_formats(formats)
```
if there are multiple formats, sort_formats must be called

Code after:
            if password:
                content_id = self._search_regex(r'content_id=(.*?)["\']', webpage, 'content_id')
                payload = f'is_xhr=true&t={self._get_cookies("https://www.dropbox.com").get("t").value}&content_id={content_id}&password={password}&url={url}'
                response = self._download_json(
                    'https://www.dropbox.com/sm/auth', video_id, 'POSTing video password', data=payload.encode('UTF-8'),
                    headers={'content-type': 'application/x-www-form-urlencoded; charset=UTF-8'})

                if response.get('status') != 'authed':
                    raise ExtractorError('Authentication failed!', expected=True)
                webpage = self._download_webpage(url, video_id)
            elif self._get_cookies('https://dropbox.com').get('sm_auth'):
                webpage = self._download_webpage(url, video_id)
            else:
                raise ExtractorError('Password protected video, use --video-password <password>', expected=True)

        json_string = self._html_search_regex(r'InitReact\.mountComponent.+ "props":(.+), "elem_id"', webpage, 'Info JSON')
        info_json = self._parse_json(json_string, video_id)
        transcode_url = traverse_obj(info_json, ((None, 'preview'), 'file', 'preview', 'content', 'transcode_url'), get_all=False)
        formats, subtitles = self._extract_m3u8_formats_and_subtitles(transcode_url, video_id)

        # downloads enabled we can get the original file
        if 'anonymous' in (try_get(info_json, lambda x: x['sharePermission']['canDownloadRoles']) or []):
            video_url = re.sub(r'[?&]dl=0', '', url)
            video_url += ('?' if '?' not in video_url else '&') + 'dl=1'
            formats.append({'url': video_url, 'format_id': 'original', 'format_note': 'Original', 'quality': 1})
        self._sort_formats(formats)

        return {
            'id': video_id,
            'title': title,
            'formats': formats,
            'subtitles': subtitles
        }