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

Code before:
            'start_time': 1696867320,
            'title': 're:^언제 어디서나! KBS 뉴스 24 [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}$',
            'description': 'md5:6ad419c0bf2f332829bda3f79c295284',
            'thumbnail': r're:^https?://.*\.(jpg|jpeg|png)',
            'like_count': int,
        },
    }, {
        'url': 'https://tv.naver.com/l/54887',
        'only_matching': True,
    }]

    def _real_extract(self, url):
        video_id = self._match_id(url)
        data = self._call_api(f'/live-end/normal/{video_id}/play-info?renewLastPlayDate=true', video_id)

        status = traverse_obj(data, ('live', 'liveStatus'))
        if status == 'CLOSED':
            raise ExtractorError('Stream is offline.', expected=True)
        elif status != 'OPENED':
            raise ExtractorError(f'Unknown status {status}')

        playback_info = traverse_obj(data, ('playbackBody', {json.loads}))

        return {
            'id': video_id,
            'formats': self._extract_m3u8_formats(traverse_obj(playback_info, ('media', 0, 'path')), video_id, live=True),
            **traverse_obj(data, ('live', {
                'title': 'title',
                'channel': 'channelName',
                'channel_id': 'channelId',
                'description': 'description',
                'like_count': (('likeCount', 'likeItCount'), {int_or_none}),
                'thumbnail': ('thumbnailImageUrl', {url_or_none}),
                'start_time': (('startTime', 'startDateTime', 'startYmdt'), {parse_iso8601}),
            }), get_all=False),
            'is_live': True
        }


class NaverNowIE(NaverBaseIE):
    IE_NAME = 'navernow'
    _VALID_URL = r'https?://now\.naver\.com/s/now\.(?P<id>\w+)'
    _API_URL = 'https://apis.naver.com/now_web/oldnow_web/v4'
    _TESTS = [{
        'url': 'https://now.naver.com/s/now.4759?shareReplayId=26331132#replay=',
        'md5': 'e05854162c21c221481de16b2944a0bc',
        'info_dict': {
            'id': '4759-26331132',
            'title': '아이키X노제\r\n💖꽁냥꽁냥💖(1)',
            'ext': 'mp4',
            'thumbnail': r're:^https?://.*\.jpg',

Review comment (refactor):
could inline `playback_info`
```suggestion
            'formats': self._extract_m3u8_formats(
                traverse_obj(data, ('playbackBody', {json.loads}, 'media', 0, 'path')), video_id, live=True),
```

Code after:
            'start_time': 1696867320,
            'title': 're:^언제 어디서나! KBS 뉴스 24 [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}$',
            'description': 'md5:6ad419c0bf2f332829bda3f79c295284',
            'thumbnail': r're:^https?://.*\.(jpg|jpeg|png)',
            'like_count': int,
        },
    }, {
        'url': 'https://tv.naver.com/l/54887',
        'only_matching': True,
    }]

    def _real_extract(self, url):
        video_id = self._match_id(url)
        data = self._call_api(f'/live-end/normal/{video_id}/play-info?renewLastPlayDate=true', video_id)

        status = traverse_obj(data, ('live', 'liveStatus'))
        if status == 'CLOSED':
            raise ExtractorError('Stream is offline.', expected=True)
        elif status != 'OPENED':
            raise ExtractorError(f'Unknown status {status!r}')

        return {
            'id': video_id,
            'formats': self._extract_m3u8_formats(
                traverse_obj(data, ('playbackBody', {json.loads}, 'media', 0, 'path')), video_id, live=True),
            **traverse_obj(data, ('live', {
                'title': 'title',
                'channel': 'channelName',
                'channel_id': 'channelId',
                'description': 'description',
                'like_count': (('likeCount', 'likeItCount'), {int_or_none}),
                'thumbnail': ('thumbnailImageUrl', {url_or_none}),
                'start_time': (('startTime', 'startDateTime', 'startYmdt'), {parse_iso8601}),
            }), get_all=False),
            'is_live': True
        }


class NaverNowIE(NaverBaseIE):
    IE_NAME = 'navernow'
    _VALID_URL = r'https?://now\.naver\.com/s/now\.(?P<id>\w+)'
    _API_URL = 'https://apis.naver.com/now_web/oldnow_web/v4'
    _TESTS = [{
        'url': 'https://now.naver.com/s/now.4759?shareReplayId=26331132#replay=',
        'md5': 'e05854162c21c221481de16b2944a0bc',
        'info_dict': {
            'id': '4759-26331132',
            'title': '아이키X노제\r\n💖꽁냥꽁냥💖(1)',
            'ext': 'mp4',
            'thumbnail': r're:^https?://.*\.jpg',
            'timestamp': 1650369600,