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

Code before:
    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', ''),
                'formats': formats,
                'http_headers': {'X-Key': hashlib.sha256(username.encode('ascii')).hexdigest()},
                'thumbnail': content_json.get('cover_image'),
                'live_status': 'not_live',
            }
            entries.append(entry)

        return self.playlist_result(
            entries, playlist_id=video_id, playlist_title=content_json.get('title'))


class BrilliantpalaElearnIE(BrilliantpalaIE):
    IE_NAME = 'Brilliantpala:Elearn'
    IE_DESC = 'VoD on elearn.brilliantpala.org'
    _VALID_URL = r'https?://elearn\.brilliantpala\.org/courses/(?P<course_id>\d+)/contents/(?P<content_id>\d+)/?'
    _TESTS = [{
        'url': 'https://elearn.brilliantpala.org/courses/42/contents/12345/',
        'only_matching': True,
    }, {
        'url': 'https://elearn.brilliantpala.org/courses/98/contents/36683/',
        'info_dict': {
            'id': '23577',
            'ext': 'mp4',
            'title': 'Physical World, Units and Measurements  - 1',
            'thumbnail': 'https://d1j3vi2u94ebt0.cloudfront.net/institute/brilliantpalalms/chapter_contents/26237/e657f81b90874be19795c7ea081f8d5c.png',
            'live_status': 'not_live',
        },
        'params': {
            'skip_download': True,
        },
    }]

Review comment (suggestion):
```suggestion
            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()},
                'thumbnail': content_json.get('cover_image'),
            })
```

Code after:
        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()},
                'thumbnail': content_json.get('cover_image'),
            })

        return self.playlist_result(
            entries, playlist_id=video_id, playlist_title=content_json.get('title'))


class BrilliantpalaElearnIE(BrilliantpalaBaseIE):
    IE_NAME = 'Brilliantpala:Elearn'
    IE_DESC = 'VoD on elearn.brilliantpala.org'
    _VALID_URL = r'https?://elearn\.brilliantpala\.org/courses/(?P<course_id>\d+)/contents/(?P<content_id>\d+)/?'
    _TESTS = [{
        'url': 'https://elearn.brilliantpala.org/courses/42/contents/12345/',
        'only_matching': True,
    }, {
        'url': 'https://elearn.brilliantpala.org/courses/98/contents/36683/',
        'info_dict': {
            'id': '23577',
            'ext': 'mp4',
            'title': 'Physical World, Units and Measurements  - 1',
            'thumbnail': 'https://d1j3vi2u94ebt0.cloudfront.net/institute/brilliantpalalms/chapter_contents/26237/e657f81b90874be19795c7ea081f8d5c.png',
            'live_status': 'not_live',
        },
        'params': {
            'skip_download': True,
        },
    }]

    _DOMAIN = BrilliantpalaBaseIE._DOMAIN.format(subdomain='elearn')