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

Code before:
        if self._LOGIN_API == self._og_search_property('url', webpage):
            self.raise_login_required()
        return self._html_search_regex(
            r'"username":\s*"(?P<username>[^"]+)"', webpage, 'stream page info', 'username')

    def _perform_login(self, username, password):
        login_form = self._hidden_inputs(self._download_webpage(
            self._LOGIN_API, None, 'Downloading login page'))
        login_form.update({
            'username': username,
            'password': password,
        })
        self._set_cookie(self._DOMAIN, 'csrftoken', login_form['csrfmiddlewaretoken'])

        logged_page = self._download_webpage(
            self._LOGIN_API, None, note='Logging in', headers={'Referer': self._LOGIN_API},
            data=urlencode_postdata(login_form))

        if self._html_search_regex(
            r'(?P<warning>Your username / email and password)', logged_page,
                'authentication failure warning', group='warning', fatal=False, default=''):
            raise ExtractorError('wrong username or password', expected=True)

        if self._html_search_regex(
            r'(?P<button_text>Logout Other Devices)', logged_page, 'logout device button',
                group='button_text', fatal=False, default=''):
            logout_device_form = self._hidden_inputs(logged_page)
            self._download_webpage(
                self._LOGOUT_DEVICES_API, None, headers={'Referer': self._LOGIN_API},
                note='Logging out other devices', data=urlencode_postdata(logout_device_form))

    def _real_extract(self, url):
        course_id, content_id = self._match_valid_url(url).group('course_id', 'content_id')
        video_id = f'{course_id}-{content_id}'

        username = self._get_logged_in_username(self._download_webpage(url, video_id))

        content_json = self._download_json(
            self._CONTENT_API.format(content_id=content_id), video_id,
            note='Fetching content info', errnote='Unable to fetch content info')

        entries = []
        for stream in traverse_obj(content_json, ('video', 'streams')):
            formats = self._extract_m3u8_formats(
                m3u8_url=stream['url'], video_id=video_id)
            for format in formats:
                format['hls_aes'] = {
                    'uri': self._HLS_AES_URI.format(content_id=content_id)}
            entry = {
                'id': str(stream['id']),
                'title': dict_get(content_json, 'title', ''),

Review comment (suggestion):
same as above
```suggestion
        if self._html_search_regex(
            r'(Logout Other Devices)', logged_page, 'logout devices button', default=None):
```

Code after:
        if self._LOGIN_API == urlh.url:
            self.raise_login_required()
        return self._html_search_regex(
            r'"username"\s*:\s*"(?P<username>[^"]+)"', webpage, 'stream page info', 'username')

    def _perform_login(self, username, password):
        login_form = self._hidden_inputs(self._download_webpage(
            self._LOGIN_API, None, 'Downloading login page'))
        login_form.update({
            'username': username,
            'password': password,
        })
        self._set_cookie(self._DOMAIN, 'csrftoken', login_form['csrfmiddlewaretoken'])

        logged_page = self._download_webpage(
            self._LOGIN_API, None, note='Logging in', headers={'Referer': self._LOGIN_API},
            data=urlencode_postdata(login_form))

        if self._html_search_regex(
                r'(Your username / email and password)', logged_page, 'auth fail', default=None):
            raise ExtractorError('wrong username or password', expected=True)

        # the maximum number of logins is one
        if self._html_search_regex(
                r'(Logout Other Devices)', logged_page, 'logout devices button', default=None):
            logout_device_form = self._hidden_inputs(logged_page)
            self._download_webpage(
                self._LOGOUT_DEVICES_API, None, headers={'Referer': self._LOGIN_API},
                note='Logging out other devices', data=urlencode_postdata(logout_device_form))

    def _real_extract(self, url):
        course_id, content_id = self._match_valid_url(url).group('course_id', 'content_id')
        video_id = f'{course_id}-{content_id}'

        username = self._get_logged_in_username(url, video_id)

        content_json = self._download_json(
            self._CONTENT_API.format(content_id=content_id), video_id,
            note='Fetching content info', errnote='Unable to fetch content info')

        entries = []
        for stream in traverse_obj(content_json, ('video', 'streams', lambda _, v: v['id'] and v['url'])):
            formats = self._extract_m3u8_formats(stream['url'], video_id, fatal=False)
            if not formats:
                continue
            entries.append({
                'id': str(stream['id']),
                'title': content_json.get('title'),
                'formats': formats,
                'hls_aes': {'uri': self._HLS_AES_URI.format(content_id=content_id)},
                'http_headers': {'X-Key': hashlib.sha256(username.encode('ascii')).hexdigest()},