1
0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2025-07-10 07:18:33 +00:00

[ie/pandatv] Add extractor

This commit is contained in:
ptlydpr 2025-06-05 02:25:33 +09:00
parent eebc2d6ae1
commit 1600e083ea
2 changed files with 28 additions and 20 deletions

View File

@ -1490,7 +1490,7 @@
PalcoMP3IE, PalcoMP3IE,
PalcoMP3VideoIE, PalcoMP3VideoIE,
) )
from .pandatv import PandatvLiveIE from .pandatv import PandaTVIE
from .panopto import ( from .panopto import (
PanoptoIE, PanoptoIE,
PanoptoListIE, PanoptoListIE,

View File

@ -10,8 +10,8 @@
) )
class PandatvLiveIE(InfoExtractor): class PandaTVIE(InfoExtractor):
_VALID_URL = r'(?P<base_url>https?://(?:www\.|m\.)?pandalive\.co\.kr)/play/(?P<id>[\da-z]+)' _VALID_URL = r'https?://(?:www\.|m\.)?pandalive\.co\.kr/play/(?P<id>[\da-z]+)'
_TESTS = [{ _TESTS = [{
'url': 'https://www.pandalive.co.kr/play/bebenim', 'url': 'https://www.pandalive.co.kr/play/bebenim',
'info_dict': { 'info_dict': {
@ -29,33 +29,41 @@ class PandatvLiveIE(InfoExtractor):
}] }]
def _real_extract(self, url): def _real_extract(self, url):
base_url, channel_id = self._match_valid_url(url).groups() channel_id = self._match_id(url)
http_headers = {'Origin': base_url} http_headers = {'Origin': 'https://www.pandalive.co.kr'}
# Prepare POST data
post_data = {'action': 'watch', 'userId': channel_id, 'password': '', 'shareLinkType': ''}
post_data_bytes = urlencode_postdata(post_data)
# Fetch video metadata
video_meta = self._download_json( video_meta = self._download_json(
'https://api.pandalive.co.kr/v1/live/play', channel_id, 'Downloading video meta data', 'https://api.pandalive.co.kr/v1/live/play', channel_id,
errnote=' Unable to download video meta data', data=post_data_bytes, expected_status=(200, 400)) 'Downloading video meta data', 'Unable to download video meta data',
data=urlencode_postdata({
'action': 'watch',
'userId': channel_id,
'password': self.get_param('videopassword'),
'shareLinkType': '',
}), expected_status=400)
# Check video metadata
if not video_meta.get('result'): if not video_meta.get('result'):
if traverse_obj(video_meta, ('errorData', 'code')) == 'castEnd': error_code = traverse_obj(video_meta, ('errorData', 'code', {str}))
if error_code == 'castEnd':
raise UserNotLive(video_id=channel_id) raise UserNotLive(video_id=channel_id)
elif traverse_obj(video_meta, ('errorData', 'code')) == 'needAdult': elif error_code == 'needAdult':
raise ExtractorError( self.raise_login_required('Adult verification is required for this stream')
'Adult verification is required. Check `--cookies` or `--cookies-from-browser` ' elif error_code == 'needLogin':
'method in https://github.com/yt-dlp/yt-dlp#filesystem-options', expected=True) 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 == 'wrongPw':
raise ExtractorError('Wrong or no stream password. Use --video-password option.', expected=True)
else:
raise ExtractorError(f'API returned an error code: {error_code}')
return { return {
'id': channel_id, 'id': channel_id,
'is_live': True, 'is_live': True,
'formats': self._extract_m3u8_formats( 'formats': self._extract_m3u8_formats(
traverse_obj(video_meta, ('PlayList', 'hls', 0, 'url')), channel_id, headers=http_headers, video_meta['PlayList']['hls'][0]['url'], channel_id, 'mp4', headers=http_headers, live=True),
ext='mp4', fatal=False, live=True),
'http_headers': http_headers, 'http_headers': http_headers,
**traverse_obj(video_meta.get('media'), { **traverse_obj(video_meta.get('media'), {
'title': ('title', {str}), 'title': ('title', {str}),