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

Code before:
            **traverse_obj(episode, ({
                'description': 'description',
                'release_timestamp': ('first_broadcasted_at', {unified_timestamp}),
                'categories': ('categories', ..., 'name'),
                'tags': ('tags', ..., 'name'),
                'thumbnails': ('images', ..., {
                    'url': ('url', {lambda x: urljoin(url, x)}, {url_or_none}),
                    'width': 'width',
                    'height': 'height',
                }),
            })),
        }

        # FOOLISH ASSUMPTION: an episode can't be video and audio at the same time
        stream_info = traverse_obj(episode, (('video', 'audio'), any))
        if not stream_info:
            self.raise_no_formats('Stream not found; it has most likely expired', expected=True)
        else:
            stream_url = stream_info.get('url')
            if is_video:
                formats, subtitles = self._extract_m3u8_formats_and_subtitles(stream_url, video_id)
                info.update({
                    'formats': formats,
                    'subtitles': subtitles,
                    **traverse_obj(stream_info, ({
                        'duration': 'duration',
                        'timestamp': ('published_at', {unified_timestamp}),
                    })),
                })
            else:
                # From https://www3.nhk.or.jp/nhkworld/common/player/radio/inline/rod.html
                audio_path = remove_end(stream_url, '.m4a')
                info['formats'] = self._extract_m3u8_formats(
                    f'{urljoin("https://vod-stream.nhk.jp", audio_path)}/index.m3u8',
                    episode_id, 'm4a', entry_protocol='m3u8_native',
                    m3u8_id='hls', fatal=False)
                for f in info['formats']:
                    f['language'] = lang

            info.update({
                'extractor_key': NhkVodIE.ie_key(),
                'extractor': NhkVodIE.ie_key(),
            })

        return info


class NhkVodIE(NhkBaseIE):
    _VALID_URL = [
        rf'{NhkBaseIE._BASE_URL_REGEX}shows/(?:(?P<type>video)/)?(?P<id>\d{{4}}[\da-z]\d+)/?(?:$|[?#])',
        rf'{NhkBaseIE._BASE_URL_REGEX}(?:ondemand|shows)/(?P<type>audio)/(?P<id>[^/?#]+?-\d{{8}}-[\da-z]+)',

Review comment (suggestion):
```suggestion
                        'duration': ('duration', {int_or_none}),
```

Code after:
        if not stream_info.get('url'):
            self.raise_no_formats('Stream not found; it has most likely expired', expected=True)
        else:
            stream_url = stream_info['url']
            if is_video:
                formats, subtitles = self._extract_m3u8_formats_and_subtitles(stream_url, video_id)
                info.update({
                    'formats': formats,
                    'subtitles': subtitles,
                    **traverse_obj(stream_info, ({
                        'duration': ('duration', {int_or_none}),
                        'timestamp': ('published_at', {unified_timestamp}),
                    })),
                })
            else:
                # From https://www3.nhk.or.jp/nhkworld/common/player/radio/inline/rod.html
                audio_path = remove_end(stream_url, '.m4a')
                info['formats'] = self._extract_m3u8_formats(
                    f'{urljoin("https://vod-stream.nhk.jp", audio_path)}/index.m3u8',
                    episode_id, 'm4a', entry_protocol='m3u8_native',
                    m3u8_id='hls', fatal=False)
                for f in info['formats']:
                    f['language'] = lang

        return info


class NhkVodIE(NhkBaseIE):
    _VALID_URL = [
        rf'{NhkBaseIE._BASE_URL_REGEX}shows/(?:(?P<type>video)/)?(?P<id>\d{{4}}[\da-z]\d+)/?(?:$|[?#])',
        rf'{NhkBaseIE._BASE_URL_REGEX}(?:ondemand|shows)/(?P<type>audio)/(?P<id>[^/?#]+?-\d{{8}}-[\da-z]+)',
        rf'{NhkBaseIE._BASE_URL_REGEX}ondemand/(?P<type>video)/(?P<id>\d{{4}}[\da-z]\d+)',  # deprecated
    ]
    # Content available only for a limited period of time. Visit
    # https://www3.nhk.or.jp/nhkworld/en/ondemand/ for working samples.
    _TESTS = [{
        'url': 'https://www3.nhk.or.jp/nhkworld/en/shows/2049165/',
        'info_dict': {
            'id': '2049165-en',
            'ext': 'mp4',
            'title': 'Japan Railway Journal - Choshi Electric Railway: Fighting to Get Back on Track',
            'description': 'md5:ab57df2fca7f04245148c2e787bb203d',
            'thumbnail': r're:https://.+/.+\.jpg',
            'episode': 'Choshi Electric Railway: Fighting to Get Back on Track',
            'series': 'Japan Railway Journal',
            'duration': 1680,
            'categories': ['Biz & Tech'],
            'tags': ['Akita', 'Chiba', 'Trains', 'Transcript', 'All (Japan Navigator)'],
            'timestamp': 1759055880,
            'upload_date': '20250928',
            'release_timestamp': 1758810600,