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

Code before:
                'quality': -1,
                'format_note': 'Audio description',
                'source_preference': -2,
                **extra_fields
            }))
        if data.get(key_format % 'ad_low'):
            formats.extend(self._assemble_formats(data[key_format % 'ad_low'], 'ad_low', display_id, token, {
                'quality': -2,
                'format_note': 'Audio description',
                'source_preference': -2,
                **extra_fields
            }))
        return formats

    def _perform_login(self, username, password):
        login_res = self._download_json(
            'https://api.brainpop.com/api/login', None,
            data=json.dumps({'username': username, 'password': password}).encode('utf-8'),
            headers={
                'Content-Type': 'application/json',
                'Referer': self._ORIGIN
            }, note='Logging in', errnote='Unable to log in', expected_status=400)
        status_code = int_or_none(login_res['status_code'])
        if status_code != 1505:
            self.report_warning('Unable to login: %s' % (self._LOGIN_ERRORS.get(status_code)
                                or login_res.get('message') or f'Got status code {status_code}'))


class BrainPOPIE(BrainPOPBaseIE):
    _VALID_URL = r'https?://(?:www\.)?brainpop\.com\/(?P<slug>[^/]+/[^/]+/(?P<id>[^/?#&]+))'
    _VIDEO_URL = 'https://svideos.brainpop.com'
    _HLS_URL = 'https://hls.brainpop.com'
    _CDN_URL = 'https://cdn.brainpop.com'
    _ORIGIN = 'https://www.brainpop.com'
    _TESTS = [{
        'url': 'https://www.brainpop.com/health/conflictresolution/martinlutherkingjr/movie?ref=null',
        'md5': '3ead374233ae74c7f1b0029a01c972f0',
        'info_dict': {
            'id': '1f3259fa457292b4',
            'ext': 'mp4',
            'title': 'Martin Luther King, Jr.',
            'display_id': 'martinlutherkingjr',
            'description': 'md5:f403dbb2bf3ccc7cf4c59d9e43e3c349',
        },
    }, {
        'url': 'https://www.brainpop.com/science/space/bigbang/',
        'md5': '9a1ff0e77444dd9e437354eb669c87ec',
        'info_dict': {
            'id': 'acae52cd48c99acf',
            'ext': 'mp4',
            'title': 'Big Bang',

Review comment (suggestion):
```suggestion
            self.report_warning(
                f'Unable to login: {self._LOGIN_ERRORS.get(status_code) or login_res.get("message")}'
                or f'Got status code {status_code}')
```

Code after:
                'format_note': 'Audio description',
                'source_preference': -2
            }
        }
        for additional_key_format, additional_key_fields in additional_key_formats.items():
            for key_quality, key_index in enumerate(('high', 'low')):
                full_key_index = additional_key_format % (key_format % key_index)
                if data.get(full_key_index):
                    formats.extend(self._assemble_formats(data[full_key_index], full_key_index, display_id, token, {
                        'quality': -1 - key_quality,
                        **additional_key_fields,
                        **extra_fields
                    }))
        return formats

    def _perform_login(self, username, password):
        login_res = self._download_json(
            'https://api.brainpop.com/api/login', None,
            data=json.dumps({'username': username, 'password': password}).encode(),
            headers={
                'Content-Type': 'application/json',
                'Referer': self._ORIGIN
            }, note='Logging in', errnote='Unable to log in', expected_status=400)
        status_code = int_or_none(login_res['status_code'])
        if status_code != 1505:
            self.report_warning(
                f'Unable to login: {self._LOGIN_ERRORS.get(status_code) or login_res.get("message")}'
                or f'Got status code {status_code}')


class BrainPOPIE(BrainPOPBaseIE):
    _ORIGIN = 'https://www.brainpop.com'
    _VIDEO_URL = 'https://svideos.brainpop.com'
    _HLS_URL = 'https://hls.brainpop.com'
    _CDN_URL = 'https://cdn.brainpop.com'
    _TESTS = [{
        'url': 'https://www.brainpop.com/health/conflictresolution/martinlutherkingjr/movie?ref=null',
        'md5': '3ead374233ae74c7f1b0029a01c972f0',
        'info_dict': {
            'id': '1f3259fa457292b4',
            'ext': 'mp4',
            'title': 'Martin Luther King, Jr.',
            'display_id': 'martinlutherkingjr',
            'description': 'md5:f403dbb2bf3ccc7cf4c59d9e43e3c349',
        },
    }, {
        'url': 'https://www.brainpop.com/science/space/bigbang/',
        'md5': '9a1ff0e77444dd9e437354eb669c87ec',
        'info_dict': {
            'id': 'acae52cd48c99acf',
            'ext': 'mp4',