mirror of
https://github.com/yt-dlp/yt-dlp
synced 2025-01-16 03:40:50 +01:00
fix
This commit is contained in:
parent
64f0bf6d4f
commit
d850843f5e
1 changed files with 18 additions and 3 deletions
|
@ -1,6 +1,7 @@
|
||||||
import functools
|
import functools
|
||||||
import json
|
import json
|
||||||
import re
|
import re
|
||||||
|
import time
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
|
@ -9,6 +10,7 @@ from ..utils import (
|
||||||
OnDemandPagedList,
|
OnDemandPagedList,
|
||||||
filter_dict,
|
filter_dict,
|
||||||
int_or_none,
|
int_or_none,
|
||||||
|
jwt_decode_hs256,
|
||||||
parse_qs,
|
parse_qs,
|
||||||
str_or_none,
|
str_or_none,
|
||||||
traverse_obj,
|
traverse_obj,
|
||||||
|
@ -50,9 +52,22 @@ class NiconicoChannelPlusBaseIE(InfoExtractor):
|
||||||
'fc_use_device': 'null',
|
'fc_use_device': 'null',
|
||||||
**headers,
|
**headers,
|
||||||
}
|
}
|
||||||
if jwt_arg := self._configuration_arg('jwt_token', ie_key='niconicochannelplus', casesense=True):
|
if jwt_args := self._configuration_arg('jwt_token', ie_key='niconicochannelplus', casesense=True):
|
||||||
headers['Authorization'] = f'Bearer {jwt_arg}'
|
jwt_token = jwt_args[0]
|
||||||
return self._download_json(f'{settings["api_base_url"]}{path}', video_id, headers=headers, **kwargs)
|
try:
|
||||||
|
if time.time() > jwt_decode_hs256(jwt_token)['exp']:
|
||||||
|
self.report_warning('JWT token is expired. Access to video may be denied.')
|
||||||
|
except Exception:
|
||||||
|
self.report_warning('Possibly invalid JWT token is provided. Access to video may be denied.')
|
||||||
|
headers['Authorization'] = f'Bearer {jwt_token}'
|
||||||
|
data, handle = self._download_json_handle(
|
||||||
|
f'{settings["api_base_url"]}{path}', video_id, headers=headers, expected_status=403, **kwargs)
|
||||||
|
if handle.status == 403:
|
||||||
|
if not self._configuration_arg('jwt_token', ie_key='niconicochannelplus', casesense=True):
|
||||||
|
raise ExtractorError('Login is required. Use --extractor-args "niconicochannelplus:jwt_token=xxx"'
|
||||||
|
'to provide account credentials', expected=True)
|
||||||
|
raise ExtractorError('You may have no access to this video')
|
||||||
|
return data
|
||||||
|
|
||||||
def _get_fanclub_site_id(self, url):
|
def _get_fanclub_site_id(self, url):
|
||||||
settings = self._get_settings(url)
|
settings = self._get_settings(url)
|
||||||
|
|
Loading…
Reference in a new issue