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

Code before:
        '''Returns the videos of the playlist'''
        webpage = self._download_webpage(url, name, 'Downloading playlist webpage')
        json = self._extract_info(webpage, 'json')

        playlist = try_get(json, lambda x: x['props']['pageProps']['playlist'], dict)
        playlist_id = playlist.get('id')
        playlist_entries = self._parse_playlist(playlist)

        return self.playlist_result(
            playlist_entries, playlist_id=playlist_id,
            playlist_title=self._og_search_title(webpage, fatal=False),
            playlist_description=self._og_search_description(webpage))

    def _series_videos_info(self, url, name, season):
        '''Returns the videos of the series playlist'''
        webpage = self._download_webpage(url, name, 'Downloading series webpage')
        json = self._extract_info(webpage, 'json')
        series = try_get(json, lambda x: x['props']['pageProps']['series'])
        series_id = series.get('id')

        seasonlist = try_get(json, lambda x: x['props']['pageProps']['seasons'], list)

        playlist_entries = []
        if season:
            for s in [playlist for playlist in seasonlist if playlist['seasonNumber'] == season]:
                playlist_entries.extend(self._parse_playlist(s))
        else:
            playlist_entries = self._parse_playlist(seasonlist[0])

        return self.playlist_result(
            playlist_entries, playlist_id=series_id,
            playlist_title=self._og_search_title(webpage, fatal=False),
            playlist_description=self._og_search_description(webpage))

    def _talk_info(self, url, video_name):
        webpage = self._download_webpage(url, video_name)
        json = self._extract_info(webpage, video_name)
        talk_info = try_get(json, lambda x: x['props']['pageProps']['videoData'], dict)

        video_id = talk_info.get('id')
        title = talk_info.get('title') or self._og_search_title(webpage)
        uploader = talk_info.get('presenterDisplayName')
        release_date = unified_strdate(talk_info.get('recordedOn'))
        upload_date = unified_strdate(talk_info.get('publishedAt'))
        view_count = str_to_int(talk_info.get('viewedCount'))
        duration = parse_duration(talk_info.get('duration')) or parse_duration(self._og_search_property('video:duration', webpage))
        description = parse_duration(talk_info.get('description')) or self._og_search_description(webpage)

        playerData = self._parse_json(talk_info.get('playerData'), video_id)
        resources_ = playerData.get('resources')
        http_url = None

Review comment (suggestion):
```suggestion
            playlist_entries = [self._parse_playlist(s) for s in seasonlist if s.get('seasonNumber') == season]
```

Code after:
                    continue
                bitrate_url = re.sub(r'\d+k', bitrate, http_url)
                if not self._is_valid_url(
                        bitrate_url, video_id, '%s bitrate' % bitrate):
                    continue
                f = m3u8_format.copy()
                f.update({
                    'url': bitrate_url,
                    'format_id': m3u8_format['format_id'].replace('hls', 'http'),
                    'protocol': 'http',
                })
                if f.get('acodec') == 'none':
                    del f['acodec']
                formats.append(f)

        audio_download = talk_info.get('audioDownload')
        if audio_download:
            formats.append({
                'url': audio_download,
                'format_id': 'audio',
                'vcodec': 'none',
            })

        if not formats:
            external = playerData.get('external') or {}
            service = external.get('service') or ''
            ext_url = external.get('code') if service.lower() == 'youtube' else None
            return self.url_result(ext_url or external['uri'])

        self._sort_formats(formats)

        thumbnail = playerData.get('thumb') or self._og_search_property('image', webpage)
        if thumbnail:
            # trim thumbnail resize parameters
            thumbnail = thumbnail.split('?')[0]

        return {
            'id': video_id,
            'title': talk_info.get('title') or self._og_search_title(webpage),
            'uploader': talk_info.get('presenterDisplayName'),
            'thumbnail': thumbnail,
            'description': talk_info.get('description') or self._og_search_description(webpage),
            'subtitles': subtitles,
            'formats': formats,
            'duration': talk_info.get('duration') or parse_duration(self._og_search_property('video:duration', webpage)),
            'view_count': str_to_int(talk_info.get('viewedCount')),
            'upload_date': unified_strdate(talk_info.get('publishedAt')),
            'release_date': unified_strdate(talk_info.get('recordedOn')),
            'tags': try_get(playerData, lambda x: x['targeting']['tag'].split(',')),
        }