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

Code before:
            content_type = 'clips'
        else:
            content_type = 'episodes'

        if not is_episode:
            extra_page = f'/{content_format}_{content_type}'
        else:
            extra_page = ''
            page_type = content_type

        return self._download_json(self._API_URL_TEMPLATE.format(
            lang=lang,
            content_format=content_format,
            page_type=page_type,
            m_id=m_id,
            extra_page=extra_page,
        ), video_id=join_nonempty(m_id, lang),
        )

        # FOR EXAMPLE:
        # https://api.nhkworld.jp/showsapi/v1/en/video_episodes/2024117
        # https://api.nhkworld.jp/showsapi/v1/en/audio_episodes/r_l_japannews-20250203-1
        # https://api.nhkworld.jp/showsapi/v1/en/video_clips/9999011
        # https://api.nhkworld.jp/showsapi/v1/en/video_programs/dwc/video_episodes
        # https://api.nhkworld.jp/showsapi/v1/en/audio_programs/livinginjapan/audio_episodes
        # no such thing as an audio_clips afaict

    def _extract_episode_info(self, url, episode=None):
        fetch_episode = episode is None
        lang, m_type, episode_id = NhkVodIE._match_valid_url(url).group('lang', 'type', 'id')
        is_video = m_type != 'audio'

        if fetch_episode:
            episode = self._call_api(
                episode_id, lang, is_video, is_episode=True, is_clip=episode_id[:4] == '9999')

        video_id = join_nonempty('id', 'lang', from_dict=episode)

        title = episode.get('title')
        series = traverse_obj(episode, (('video_program', 'audio_program'), any, 'title'))

        episode_name = title
        if series and title:
            title = f'{series} - {title}'
        elif series and not title:
            title = series
            series = None
            episode_name = None
        else:  # title, no series
            episode_name = None


Review comment (suggestion):
I don't understand this comment, so it's not helpful here IMO. Add them as tests if you need them as examples
```suggestion
```

Code after:
            extra_page = ''
            page_type = content_type

        return self._download_json(
            self._API_URL_TEMPLATE.format(
                lang=lang, content_format=content_format, page_type=page_type,
                m_id=m_id, extra_page=extra_page),
            join_nonempty(m_id, lang))

    def _extract_episode_info(self, url, episode=None):
        fetch_episode = episode is None
        lang, m_type, episode_id = NhkVodIE._match_valid_url(url).group('lang', 'type', 'id')
        is_video = m_type != 'audio'

        if fetch_episode:
            episode = self._call_api(
                episode_id, lang, is_video, is_episode=True, is_clip=episode_id[:4] == '9999')

        video_id = join_nonempty('id', 'lang', from_dict=episode)

        title = episode.get('title')
        series = traverse_obj(episode, (('video_program', 'audio_program'), any, 'title'))

        episode_name = title
        if series and title:
            title = f'{series} - {title}'
        elif series and not title:
            title = series
            series = None
            episode_name = None
        else:  # title, no series
            episode_name = None

        info = {
            'id': video_id,
            'title': title,
            'series': series,
            'episode': episode_name,
            **traverse_obj(episode, {
                'description': ('description', {str}),
                'release_timestamp': ('first_broadcasted_at', {unified_timestamp}),
                'categories': ('categories', ..., 'name', {str}),
                'tags': ('tags', ..., 'name', {str}),
                'thumbnails': ('images', lambda _, v: v['url'], {
                    'url': ('url', {urljoin(url)}),
                    'width': ('width', {int_or_none}),
                    'height': ('height', {int_or_none}),
                }),
                'webpage_url': ('url', {urljoin(url)}),
            }),
            'extractor_key': NhkVodIE.ie_key(),