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

Code before:

        vod_data = self._download_json(
            f'https://survapi.channel.or.jp/proxy/v1/contents/{content_id}/get_by_cuid', video_id,
            headers=self._survapi_header, note='Downloading vod data')

        return {
            'formats': self._extract_m3u8_formats(vod_data['ex_content']['streaming_url'], video_id),
        }

    def _process_live(self, video_id, metadata):
        content_id = metadata['contents']['video_id']
        event_data = self._download_json(
            f'https://survapi.channel.or.jp/ex/events/{content_id}?embed=channel', video_id,
            headers=self._survapi_header, note='Downloading event data')

        player_type = traverse_obj(event_data, ('data', 'Player_type'))
        if player_type == 'poster':
            self.raise_no_formats('Live event has not yet started', expected=True)
            live_status = 'is_upcoming'
            formats = []
        elif player_type == 'player':
            live_status = 'is_live'
            formats = self._extract_m3u8_formats(
                event_data['data']['Channel']['Custom_live_url'], video_id, live=True)
        else:
            raise ExtractorError('Unexpected player type')

        return {
            'release_timestamp': traverse_obj(metadata, ('period', 'start', {parse_iso8601})),
            'live_status': live_status,
            'formats': formats,
        }

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

        metadata = self._download_json(
            f'https://channel.microcms.io/api/v1/media/{video_id}', video_id,
            headers=self._MICROCMS_HEADER)

        info = self._extract_info(metadata)

        video_type = traverse_obj(metadata, ('contents', 'video_type', 0))
        if video_type == 'VOD':
            return merge_dicts(info, self._process_vod(video_id, metadata))
        if video_type == 'LIVE':
            return merge_dicts(info, self._process_live(video_id, metadata))

        raise ExtractorError(f'Unexpected video type {video_type}', expected=False)



Review comment (refactor):
include unsupported player type in error msg
```suggestion
            raise ExtractorError('Unsupported player type {player_type!r}')
```

Code after:
            'https://asobichannel-api.asobistore.jp/api/v1/vspf/token', None,
            note='Retrieving API token')
        self._survapi_header = {'Authorization': f'Bearer {token}'}

    def _process_vod(self, video_id, metadata):
        content_id = metadata['contents']['video_id']

        vod_data = self._download_json(
            f'https://survapi.channel.or.jp/proxy/v1/contents/{content_id}/get_by_cuid', video_id,
            headers=self._survapi_header, note='Downloading vod data')

        return {
            'formats': self._extract_m3u8_formats(vod_data['ex_content']['streaming_url'], video_id),
        }

    def _process_live(self, video_id, metadata):
        content_id = metadata['contents']['video_id']
        event_data = self._download_json(
            f'https://survapi.channel.or.jp/ex/events/{content_id}?embed=channel', video_id,
            headers=self._survapi_header, note='Downloading event data')

        player_type = traverse_obj(event_data, ('data', 'Player_type', {str}))
        if player_type == 'poster':
            self.raise_no_formats('Live event has not yet started', expected=True)
            live_status = 'is_upcoming'
            formats = []
        elif player_type == 'player':
            live_status = 'is_live'
            formats = self._extract_m3u8_formats(
                event_data['data']['Channel']['Custom_live_url'], video_id, live=True)
        else:
            raise ExtractorError('Unsupported player type {player_type!r}')

        return {
            'release_timestamp': traverse_obj(metadata, ('period', 'start', {parse_iso8601})),
            'live_status': live_status,
            'formats': formats,
        }

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

        metadata = self._download_json(
            f'https://channel.microcms.io/api/v1/media/{video_id}', video_id,
            headers=self._MICROCMS_HEADER)

        info = self._extract_info(metadata)

        video_type = traverse_obj(metadata, ('contents', 'video_type', 0, {str}))
        if video_type == 'VOD':
            return merge_dicts(info, self._process_vod(video_id, metadata))