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

Code before:
                self.raise_login_required('Login is required for this stream')
            elif error_code == 'needCoinPurchase':
                raise ExtractorError('Coin purchase is required for this stream', expected=True)
            elif error_code == 'needUnlimitItem':
                raise ExtractorError('Ticket purchase is required for this stream', expected=True)
            elif error_code == 'needPw':
                raise ExtractorError('Password protected video, use --video-password <password>', expected=True)
            elif error_code == 'wrongPw':
                raise ExtractorError('Wrong password', expected=True)
            else:
                error_msg = video_meta.get('message')
                raise ExtractorError(f'API returned an error code: {error_code} with error message: {error_msg}')

        http_headers = {'Origin': 'https://www.pandalive.co.kr'}

        return {
            'id': channel_id,
            'is_live': True,
            'formats': self._extract_m3u8_formats(
                video_meta['PlayList']['hls'][0]['url'], channel_id, 'mp4', headers=http_headers, live=True),
            'http_headers': http_headers,
            **traverse_obj(video_meta, ('media', {
                'title': ('title', {str}),
                'release_timestamp': ('startTime', {parse_iso8601(delim=' ')}),
                'thumbnail': ('ivsThumbnail', {url_or_none}),
                'channel': ('userNick', {str}),
                'concurrent_view_count': ('user', {int_or_none}),
                'like_count': ('likeCnt', {int_or_none}),
            })),
        }


Review comment (refactor):
I'm guessing these are pre-muxed video+audio formats?

Returning `http_headers` in the info dict root won't work with ffmpeg if there are separate video and audio formats being downloaded

Though this is arguably a core problem and not this extractor's problem

Code after:
                self.raise_login_required('Adult verification is required for this stream')
            elif error_code == 'needLogin':
                self.raise_login_required('Login is required for this stream')
            elif error_code == 'needCoinPurchase':
                raise ExtractorError('Coin purchase is required for this stream', expected=True)
            elif error_code == 'needUnlimitItem':
                raise ExtractorError('Ticket purchase is required for this stream', expected=True)
            elif error_code == 'needPw':
                raise ExtractorError('Password protected video, use --video-password <password>', expected=True)
            elif error_code == 'wrongPw':
                raise ExtractorError('Wrong password', expected=True)
            else:
                error_msg = video_meta.get('message')
                raise ExtractorError(join_nonempty(
                    'API returned error code', error_code,
                    error_msg and 'with error message:', error_msg,
                    delim=' '))

        http_headers = {'Origin': 'https://www.pandalive.co.kr'}

        return {
            'id': channel_id,
            'is_live': True,
            'formats': self._extract_m3u8_formats(
                video_meta['PlayList']['hls'][0]['url'], channel_id, 'mp4', headers=http_headers, live=True),
            'http_headers': http_headers,
            **traverse_obj(video_meta, ('media', {
                'title': ('title', {str}),
                'release_timestamp': ('startTime', {parse_iso8601(delim=' ')}),
                'thumbnail': ('ivsThumbnail', {url_or_none}),
                'channel': ('userNick', {str}),
                'concurrent_view_count': ('user', {int_or_none}),
                'like_count': ('likeCnt', {int_or_none}),
            })),
        }