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

Code before:
        'only_matching': True,
    }]

    @classmethod
    def _match_path(cls, url):
        return cls._match_valid_url(url).group('path')

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

        webpage = self._download_webpage(url, video_id)

        next_data = self._parse_json(self._search_regex(
            r'<script[^>]*__NEXT_DATA__[^>]*>\s*({.+?})\s*</script>',
            webpage, 'next data', default='{}'), video_id)

        build_id = next_data.get('buildId')
        if not build_id:
            raise ExtractorError(
                'Could not find build ID.', video_id=video_id)

        locale = next_data.get('locale', 'en')

        api_url = 'https://medal.tv/_next/data/{0}/{1}/{2}/{3}.json'.format(build_id, locale, path, video_id)
        api_response = self._download_json(api_url, video_id)

        clip = try_get(api_response, lambda x: x['pageProps']['clip'], dict) or {}
        if not clip:
            raise ExtractorError(
                'Could not find video information.', video_id=video_id)

        title = clip['contentTitle']

        source_width = int_or_none(clip.get('sourceWidth'))
        source_height = int_or_none(clip.get('sourceHeight'))

        aspect_ratio = source_width / source_height if source_width and source_height else 16 / 9

        def add_item(container, item_url, height, id_key='format_id', item_id=None):
            item_id = item_id or '%dp' % height
            if item_id not in item_url:
                return
            width = int(round(aspect_ratio * height))
            container.append({
                'url': item_url,
                id_key: item_id,
                'width': width,
                'height': height
            })


Review comment (suggestion):
```suggestion
        api_response = self._download_json(
            f'https://medal.tv/_next/data/{build_id}/{locale}/{path}/{video_id}.json', video_id)
```

Code after:
        'only_matching': True,
    }]

    def _real_extract(self, url):
        video_id = self._match_id(url)
        path = self._match_valid_url(url).group('path')

        webpage = self._download_webpage(url, video_id)

        next_data = self._search_json(
            '<script[^>]*__NEXT_DATA__[^>]*>', webpage,
            'next data', video_id, end_pattern='</script>', fatal=False)

        build_id = next_data.get('buildId')
        if not build_id:
            raise ExtractorError(
                'Could not find build ID.', video_id=video_id)

        locale = next_data.get('locale', 'en')

        api_response = self._download_json(
            f'https://medal.tv/_next/data/{build_id}/{locale}/{path}/{video_id}.json', video_id)

        clip = traverse_obj(api_response, ('pageProps', 'clip')) or {}
        if not clip:
            raise ExtractorError(
                'Could not find video information.', video_id=video_id)

        title = clip['contentTitle']

        source_width = int_or_none(clip.get('sourceWidth'))
        source_height = int_or_none(clip.get('sourceHeight'))

        aspect_ratio = source_width / source_height if source_width and source_height else 16 / 9

        def add_item(container, item_url, height, id_key='format_id', item_id=None):
            item_id = item_id or '%dp' % height
            if item_id not in item_url:
                return
            width = int(round(aspect_ratio * height))
            container.append({
                'url': item_url,
                id_key: item_id,
                'width': width,
                'height': height
            })

        formats = []
        thumbnails = []
        for k, v in clip.items():
            if not (v and isinstance(v, compat_str)):