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

Code before:
        'params': {
            'noplaylist': False,
        }
    }, {
        'url': 'https://now.naver.com/show/4759?shareHightlight=1078#highlight=',
        'info_dict': {
            'id': '4759',
            'title': '아이키의 떰즈업',
        },
        'playlist_mincount': 48,
        'params': {
            'noplaylist': False,
        }
    }]

    def _extract_replay(self, show_id, replay_id):
        vod_info = self._download_json(f'{self._API_URL}/shows/{show_id}/vod/{replay_id}', replay_id)
        in_key = self._download_json(f'{self._API_URL}/shows/{show_id}/vod/{replay_id}/inkey', replay_id)['inKey']
        return merge_dicts(
            {
                'id': f'{show_id}-{replay_id}',
                'title': traverse_obj(vod_info, ('episode', 'title')),
                'timestamp': unified_timestamp(traverse_obj(vod_info, ('episode', 'start_time'))),
                'thumbnail': vod_info.get('thumbnail_image_url'),
            },
            self._extract_video_info(replay_id, vod_info['video_id'], in_key))

    def _extract_highlight(self, show_id, highlight_id, highlights=None):
        page = 0
        while True:
            highlights_videos = highlights or self._download_json(
                f'{self._API_URL}/shows/{show_id}/highlights/videos/', highlight_id,
                query={'offset': page * self._PAGE_SIZE, 'limit': self._PAGE_SIZE},
                note=f'Downloading JSON highlights for show {show_id} - page {page}')
            highlight = [
                v for v in highlights_videos.get('results', [])
                if v.get('id', -1) == int(highlight_id)
            ]
            if highlight or highlights_videos.get('count', 0) <= self._PAGE_SIZE * (page + 1):
                break
            page += 1

        if not highlight:
            raise ExtractorError(f'Unable to find highlight {highlight_id} for show {show_id}')

        highlight = highlight[0]
        return merge_dicts(
            {
                'id': f'{show_id}-{highlight_id}',
                'title': highlight.get('title'),
                'timestamp': unified_timestamp(highlight.get('regdate')),

Review comment (refactor):
```suggestion
        return merge_dicts({
            'id': f'{show_id}-{replay_id}',
            'title': traverse_obj(vod_info, ('episode', 'title')),
            'timestamp': unified_timestamp(traverse_obj(vod_info, ('episode', 'start_time'))),
            'thumbnail': vod_info.get('thumbnail_image_url'),
            }, self._extract_video_info(replay_id, vod_info['video_id'], in_key))
```

Code after:
        },
        'playlist_mincount': 48,
    }]

    def _extract_replay(self, show_id, replay_id):
        vod_info = self._download_json(f'{self._API_URL}/shows/{show_id}/vod/{replay_id}', replay_id)
        in_key = self._download_json(f'{self._API_URL}/shows/{show_id}/vod/{replay_id}/inkey', replay_id)['inKey']
        return merge_dicts({
            'id': f'{show_id}-{replay_id}',
            'title': traverse_obj(vod_info, ('episode', 'title')),
            'timestamp': unified_timestamp(traverse_obj(vod_info, ('episode', 'start_time'))),
            'thumbnail': vod_info.get('thumbnail_image_url'),
        }, self._extract_video_info(replay_id, vod_info['video_id'], in_key))

    def _extract_show_replays(self, show_id):
        page = 0
        while True:
            show_vod_info = self._download_json(
                f'{self._API_URL}/vod-shows/{show_id}', show_id,
                query={'offset': page * self._PAGE_SIZE, 'limit': self._PAGE_SIZE},
                note=f'Downloading JSON vod list for show {show_id} - page {page}'
            )['response']['result']
            for v in show_vod_info.get('vod_list') or []:
                yield self._extract_replay(show_id, v['id'])

            if try_call(lambda: show_vod_info['count'] <= self._PAGE_SIZE * (page + 1)):
                break
            page += 1

    def _extract_show_highlights(self, show_id, highlight_id=None):
        page = 0
        while True:
            highlights_videos = self._download_json(
                f'{self._API_URL}/shows/{show_id}/highlights/videos/', show_id,
                query={'offset': page * self._PAGE_SIZE, 'limit': self._PAGE_SIZE},
                note=f'Downloading JSON highlights for show {show_id} - page {page}')

            for highlight in highlights_videos.get('results') or []:
                if highlight_id and highlight.get('id') != int(highlight_id):
                    continue
                yield merge_dicts({
                    'id': f'{show_id}-{highlight["id"]}',
                    'title': highlight.get('title'),
                    'timestamp': unified_timestamp(highlight.get('regdate')),
                    'thumbnail': highlight.get('thumbnail_url'),
                }, self._extract_video_info(highlight['id'], highlight['video_id'], highlight['video_inkey']))

            if try_call(lambda: highlights_videos['count'] <= self._PAGE_SIZE * (page + 1)):
                break
            page += 1