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

Code before:
            'modified_date': '20231020',
            'release_timestamp': 1697261769,
            'release_date': '20231014',
            'channel': 'アイドルマスター',
            'channel_id': 'idolmaster',
        },
    }]

    def _get_survapi_header(self, video_id):
        request_token = self._download_json(
            'https://asobichannel-api.asobistore.jp/api/v1/vspf/token', video_id,
            note='Retrieving API token')
        return {'Authorization': f'Bearer {request_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._get_survapi_header(video_id), note='Downloading vod data')

        m3u8_url = vod_data['ex_content']['streaming_url']

        return {
            'formats': self._extract_m3u8_formats(m3u8_url, video_id),
        }

    def _process_live(self, video_id, metadata):
        now_ts = datetime.datetime.now().timestamp()

        content_id = metadata['contents']['video_id']

        live_start = traverse_obj(metadata, ('period', 'start', {parse_iso8601}))
        if live_start is None:
            live_status = None
        elif now_ts < live_start:
            live_status = 'is_upcoming'
        else:
            live_status = 'is_live'

        event_data = self._download_json(
            f'https://survapi.channel.or.jp/ex/events/{content_id}?embed=channel', video_id,
            headers=self._get_survapi_header(video_id), note='Downloading event data')

        live_url = event_data['data']['Channel']['Custom_live_url']

        return {
            'live_status': live_status,
            'formats': self._extract_m3u8_formats(live_url, video_id),
        }


Review comment (refactor):
No need for single use variables
```suggestion
        return {
            'formats': self._extract_m3u8_formats(vod_data['ex_content']['streaming_url'], video_id),
        }
```

Code after:
            'ext': 'mp4',
            'title': '【おまけ放送】アイドルマスター ミリオンライブ！ 765プロch 原っぱ通信 #1',
            'description': 'md5:7d9cd35fb54425a6967822bd564ea2d9',
            'thumbnail': 'https://images.microcms-assets.io/assets/d2420de4b9194e11beb164f99edb1f95/20e5c1d6184242eebc2512a5dec59bf0/P1_%E5%8E%9F%E3%81%A3%E3%81%B1%E3%82%B5%E3%83%A0%E3%83%8D.png',
            'modified_timestamp': 1697797125,
            'modified_date': '20231020',
            'timestamp': 1697261769,
            'upload_date': '20231014',
            'channel': 'アイドルマスター',
            'channel_id': 'idolmaster',
        },
    }]

    _survapi_header = None

    def _real_initialize(self):
        token = self._download_json(
            '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 {