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

Code before:
            'url': 'https://www.dropbox.com/sh/2mgpiuq7kv8nqdf/AABy-fW4dkydT4GmWi2mdOUDa?dl=0&preview=Drone+Shot.mp4',
            'only_matching': True,
        }, {
            'url': 'https://www.dropbox.com/scl/fi/r2kd2skcy5ylbbta5y1pz/DJI_0003.MP4?dl=0&rlkey=wcdgqangn7t3lnmmv6li9mu9h',
            'only_matching': True,
        }, {
            'url': 'https://www.dropbox.com/e/scl/fi/r2kd2skcy5ylbbta5y1pz/DJI_0003.MP4?dl=0&rlkey=wcdgqangn7t3lnmmv6li9mu9h',
            'only_matching': True,
        },
    ]

    def _yield_decoded_parts(self, webpage):
        for encoded in reversed(re.findall(r'registerStreamedPrefetch\s*\(\s*"[\w/+=]+"\s*,\s*"([\w/+=]+)"', webpage)):
            yield base64.b64decode(encoded).decode('utf-8', 'ignore')

    def _real_extract(self, url):
        mobj = self._match_valid_url(url)
        video_id = mobj.group('id')
        webpage = self._download_webpage(url, video_id)
        fn = urllib.parse.unquote(url_basename(url))
        title = os.path.splitext(fn)[0]
        content_id = None

        for part in self._yield_decoded_parts(webpage):
            if '/sm/password' in part:
                content_id = self._search_regex(r'content_id=([\w-]+)', part, 'content ID')
                break

        if content_id and not self._get_cookies('https://dropbox.com/').get('sm_auth'):
            password = self.get_param('videopassword')
            if not password:
                raise ExtractorError('Password protected video, use --video-password <password>', expected=True)

            response = self._download_json(
                'https://www.dropbox.com/sm/auth', video_id, 'POSTing video password',
                data=urlencode_postdata({
                    'is_xhr': 'true',
                    't': self._get_cookies('https://www.dropbox.com')['t'].value,
                    'content_id': content_id,
                    'password': password,
                    'url': update_url(url, scheme='', netloc=''),
                }))
            if response.get('status') != 'authed':
                raise ExtractorError('Invalid password', expected=True)

            webpage = self._download_webpage(url, video_id)

        formats, subtitles = [], {}
        has_anonymous_download = False
        thumbnail = None
        for part in self._yield_decoded_parts(webpage):

Review comment (suggestion):
```suggestion
                content_id = self._search_regex(r'content_id=([\w.+=/-]+)', part, 'content ID')
```

Code after:
            'url': 'https://www.dropbox.com/sh/2mgpiuq7kv8nqdf/AABy-fW4dkydT4GmWi2mdOUDa?dl=0&preview=Drone+Shot.mp4',
            'only_matching': True,
        }, {
            'url': 'https://www.dropbox.com/scl/fi/r2kd2skcy5ylbbta5y1pz/DJI_0003.MP4?dl=0&rlkey=wcdgqangn7t3lnmmv6li9mu9h',
            'only_matching': True,
        }, {
            'url': 'https://www.dropbox.com/e/scl/fi/r2kd2skcy5ylbbta5y1pz/DJI_0003.MP4?dl=0&rlkey=wcdgqangn7t3lnmmv6li9mu9h',
            'only_matching': True,
        },
    ]

    def _yield_decoded_parts(self, webpage):
        for encoded in reversed(re.findall(r'registerStreamedPrefetch\s*\(\s*"[\w/+=]+"\s*,\s*"([\w/+=]+)"', webpage)):
            yield base64.b64decode(encoded).decode('utf-8', 'ignore')

    def _real_extract(self, url):
        mobj = self._match_valid_url(url)
        video_id = mobj.group('id')
        webpage = self._download_webpage(url, video_id)
        fn = urllib.parse.unquote(url_basename(url))
        title = os.path.splitext(fn)[0]
        content_id = None

        for part in self._yield_decoded_parts(webpage):
            if '/sm/password' in part:
                content_id = self._search_regex(r'content_id=([\w.+=/-]+)', part, 'content ID')
                break

        if content_id:
            password = self.get_param('videopassword')
            if not password:
                raise ExtractorError('Password protected video, use --video-password <password>', expected=True)

            response = self._download_json(
                'https://www.dropbox.com/sm/auth', video_id, 'POSTing video password',
                data=urlencode_postdata({
                    'is_xhr': 'true',
                    't': self._get_cookies('https://www.dropbox.com')['t'].value,
                    'content_id': content_id,
                    'password': password,
                    'url': update_url(url, scheme='', netloc=''),
                }))
            if response.get('status') != 'authed':
                raise ExtractorError('Invalid password', expected=True)

            webpage = self._download_webpage(url, video_id)

        formats, subtitles = [], {}
        has_anonymous_download = False
        thumbnail = None
        for part in self._yield_decoded_parts(webpage):