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

Code before:
        thumbnails_list = json_ld.get('image')
        if not thumbnails_list:
            try:
                thumbnails_list = self._html_search_regex(
                    r'["\']image["\']:\s*["\']([^"\']+)["\']', webpage, 'images', default='')
                thumbnails_list = thumbnails_list.replace('[', '').replace(']', '').split(',')
                thumbnails_list = [thumbnail.strip() for thumbnail in thumbnails_list]
            except not KeyboardInterrupt:
                pass
        thumbnails = []
        for thumbnail in thumbnails_list:
            width_a, height_a, width = self._search_regex(
                r'/images/image/private/t_(?P<width_a>\d+)-(?P<height_a>\d+)_(?P<width>\d+)/primary/[\W\w\d]+',
                thumbnail,
                'thumb', group=(1, 2, 3), default=(None, None, None))
            if None not in (width_a, height_a, width):
                width_a, height_a, width = int(width_a), int(height_a), int(width)
                thumbnails.append({
                    'url': thumbnail,
                    'width': width,
                    'height': int(width * height_a / width_a)
                })
            else:
                thumbnails.append({
                    'url': thumbnail
                })
        m3u8_url = self._download_json(
            f'https://olympics.com/tokenGenerator?url={m3u8_url}', uuid, note='Downloading m3u8 url')
        formats, subtitles = self._extract_m3u8_formats_and_subtitles(m3u8_url, uuid, m3u8_id='hls')
        self._sort_formats(formats)

        return {
            'id': uuid,
            'title': title,
            'timestamp': json_ld.get('timestamp'),
            'description': json_ld.get('description'),
            'thumbnails': thumbnails,
            'duration': json_ld.get('duration'),
            'formats': formats,
            'subtitles': subtitles,
        }


Review comment (suggestion):
```suggestion
            width_a, height_a, width = int_or_none(width_a), int_or_none(height_a), int_or_none(width)
            thumbnails.append({
                'url': thumbnail,
                'width': width,
                'height': try_get(width, lambda x: x * height_a / width_a)
            })
```

Code after:
        title = self._html_search_meta(('title', 'og:title', 'twitter:title'), webpage)
        uuid = self._html_search_meta('episode_uid', webpage)
        m3u8_url = self._html_search_meta('video_url', webpage)
        json_ld = self._search_json_ld(webpage, uuid)
        thumbnails_list = json_ld.get('image')
        if not thumbnails_list:
            thumbnails_list = self._html_search_regex(
                r'["\']image["\']:\s*["\']([^"\']+)["\']', webpage, 'images', default='')
            thumbnails_list = thumbnails_list.replace('[', '').replace(']', '').split(',')
            thumbnails_list = [thumbnail.strip() for thumbnail in thumbnails_list]
        thumbnails = []
        for thumbnail in thumbnails_list:
            width_a, height_a, width = self._search_regex(
                r'/images/image/private/t_(?P<width_a>\d+)-(?P<height_a>\d+)_(?P<width>\d+)/primary/[\W\w\d]+',
                thumbnail, 'thumb', group=(1, 2, 3), default=(None, None, None))
            width_a, height_a, width = int_or_none(width_a), int_or_none(height_a), int_or_none(width)
            thumbnails.append({
                'url': thumbnail,
                'width': width,
                'height': int_or_none(try_get(width, lambda x: x * height_a / width_a))
            })
        m3u8_url = self._download_json(
            f'https://olympics.com/tokenGenerator?url={m3u8_url}', uuid, note='Downloading m3u8 url')
        formats, subtitles = self._extract_m3u8_formats_and_subtitles(m3u8_url, uuid, m3u8_id='hls')
        self._sort_formats(formats)

        return {
            'id': uuid,
            'title': title,
            'timestamp': json_ld.get('timestamp'),
            'description': json_ld.get('description'),
            'thumbnails': thumbnails,
            'duration': json_ld.get('duration'),
            'formats': formats,
            'subtitles': subtitles,
        }