mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-12-25 20:55:52 +01:00
[afreecatv] Support password-protected livestreams (#2738)
Authored by: wlritchi
This commit is contained in:
parent
079a7cfc71
commit
5dee3ad037
@ -416,26 +416,35 @@ class AfreecaTVLiveIE(AfreecaTVIE):
|
|||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
broadcaster_id, broadcast_no = self._match_valid_url(url).group('id', 'bno')
|
broadcaster_id, broadcast_no = self._match_valid_url(url).group('id', 'bno')
|
||||||
|
password = self.get_param('videopassword')
|
||||||
|
|
||||||
info = self._download_json(self._LIVE_API_URL, broadcaster_id, fatal=False,
|
info = self._download_json(self._LIVE_API_URL, broadcaster_id, fatal=False,
|
||||||
data=urlencode_postdata({'bid': broadcaster_id})) or {}
|
data=urlencode_postdata({'bid': broadcaster_id})) or {}
|
||||||
channel_info = info.get('CHANNEL') or {}
|
channel_info = info.get('CHANNEL') or {}
|
||||||
broadcaster_id = channel_info.get('BJID') or broadcaster_id
|
broadcaster_id = channel_info.get('BJID') or broadcaster_id
|
||||||
broadcast_no = channel_info.get('BNO') or broadcast_no
|
broadcast_no = channel_info.get('BNO') or broadcast_no
|
||||||
|
password_protected = channel_info.get('BPWD')
|
||||||
if not broadcast_no:
|
if not broadcast_no:
|
||||||
raise ExtractorError(f'Unable to extract broadcast number ({broadcaster_id} may not be live)', expected=True)
|
raise ExtractorError(f'Unable to extract broadcast number ({broadcaster_id} may not be live)', expected=True)
|
||||||
|
if password_protected == 'Y' and password is None:
|
||||||
|
raise ExtractorError(
|
||||||
|
'This livestream is protected by a password, use the --video-password option',
|
||||||
|
expected=True)
|
||||||
|
|
||||||
formats = []
|
formats = []
|
||||||
quality_key = qualities(self._QUALITIES)
|
quality_key = qualities(self._QUALITIES)
|
||||||
for quality_str in self._QUALITIES:
|
for quality_str in self._QUALITIES:
|
||||||
|
params = {
|
||||||
|
'bno': broadcast_no,
|
||||||
|
'stream_type': 'common',
|
||||||
|
'type': 'aid',
|
||||||
|
'quality': quality_str,
|
||||||
|
}
|
||||||
|
if password is not None:
|
||||||
|
params['pwd'] = password
|
||||||
aid_response = self._download_json(
|
aid_response = self._download_json(
|
||||||
self._LIVE_API_URL, broadcast_no, fatal=False,
|
self._LIVE_API_URL, broadcast_no, fatal=False,
|
||||||
data=urlencode_postdata({
|
data=urlencode_postdata(params),
|
||||||
'bno': broadcast_no,
|
|
||||||
'stream_type': 'common',
|
|
||||||
'type': 'aid',
|
|
||||||
'quality': quality_str,
|
|
||||||
}),
|
|
||||||
note=f'Downloading access token for {quality_str} stream',
|
note=f'Downloading access token for {quality_str} stream',
|
||||||
errnote=f'Unable to download access token for {quality_str} stream')
|
errnote=f'Unable to download access token for {quality_str} stream')
|
||||||
aid = traverse_obj(aid_response, ('CHANNEL', 'AID'))
|
aid = traverse_obj(aid_response, ('CHANNEL', 'AID'))
|
||||||
|
Loading…
Reference in New Issue
Block a user