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

Code before:
    def _real_extract(self, url):
        video_id = self._match_id(url)

        doc = self._download_json("https://www.kika.de/_next-api/proxy/v1/videos/video%s" % (video_id), video_id)
        title = doc.get('title')
        timestamp = parse_iso8601(doc.get('date'))
        duration = parse_duration(doc.get('duration'))

        video_url = doc.get('assets').get('url')
        video_assets = self._download_json(video_url, video_id)
        formats = self._extract_formats(video_assets, video_id)

        subtitles = {}
        ttml_resource = video_assets.get('videoSubtitle')
        if ttml_resource:
            subtitles['de'] = [{
                'url': ttml_resource,
                'ext': 'ttml',
            }]
        webvtt_resource = video_assets.get('webvttUrl')
        if webvtt_resource:
            vtt = {
                'url': webvtt_resource,
                'ext': 'webvtt'
            }
            subtitles['de'].append(vtt)

        return {
            'id': video_id,
            'title': title,
            'description': doc['description'],
            'timestamp': timestamp,
            'duration': duration,
            'formats': formats,
            'subtitles': subtitles,
            'uploader': 'KIKA'
        }

    def _extract_formats(self, media_info, video_id):
        streams = media_info.get('assets', [])
        formats = []
        for num, media in enumerate(streams):
            stream_url = media.get("url")
            ext = determine_ext(stream_url)
            if ext == 'm3u8':
                formats.extend(self._extract_m3u8_formats(
                    stream_url, video_id, 'mp4', 'm3u8_native',
                    m3u8_id='hls', fatal=False))
            else:
                f = {
                    'url': stream_url,

Review comment (suggestion):
```suggestion
        subtitles = {}
        ttml_resource = video_assets.get('videoSubtitle')
        if ttml_resource:
            subtitles['de'] = [{
                'url': ttml_resource,
                'ext': 'ttml',
            }]
        webvtt_resource = video_assets.get('webvttUrl')
        if webvtt_resource:
            subtitles.setdefault('de', []).append({
                'url': webvtt_resource,
                'ext': 'vtt'
            })
```

Code after:
    }, {
        'url': 'https://www.kika.de/kaltstart/videos/video92498',
        'md5': '710ece827e5055094afeb474beacb7aa',
        'info_dict': {
            'id': 'video92498',
            'ext': 'mp4',
            'title': '7. Wo ist Leo?',
            'description': 'md5:fb48396a5b75068bcac1df74f1524920',
            'duration': 436,
            'timestamp': 1702926876,
            'upload_date': '20231218',
            'episode_number': 7,
            'modified_date': '20240319',
            'modified_timestamp': 1710880610,
            'episode': 'Episode 7',
            'season_number': 1,
            'season': 'Season 1',
        },
    }, {
        'url': 'https://www.kika.de/bernd-das-brot/astrobrot/videos/video90088',
        'md5': 'ffd1b700d7de0a6616a1d08544c77294',
        'info_dict': {
            'id': 'video90088',
            'ext': 'mp4',
            'upload_date': '20221102',
            'timestamp': 1667390580,
            'duration': 197,
            'modified_timestamp': 1711093771,
            'episode_number': 8,
            'title': 'Es ist nicht leicht, ein Astrobrot zu sein',
            'modified_date': '20240322',
            'description': 'md5:d3641deaf1b5515a160788b2be4159a9',
            'season_number': 1,
            'episode': 'Episode 8',
            'season': 'Season 1',
        },
    }]

    def _real_extract(self, url):
        video_id = self._match_id(url)

        doc = self._download_json(f'https://www.kika.de/_next-api/proxy/v1/videos/{video_id}', video_id)
        video_assets = self._download_json(doc['assets']['url'], video_id)

        subtitles = {}
        if ttml_resource := url_or_none(video_assets.get('videoSubtitle')):
            subtitles['de'] = [{
                'url': ttml_resource,
                'ext': 'ttml',
            }]
        if webvtt_resource := url_or_none(video_assets.get('webvttUrl')):