mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-27 15:16:52 +01:00
parent
eedb38ce40
commit
40966e8da2
@ -36,6 +36,8 @@
|
||||
class NiconicoIE(InfoExtractor):
|
||||
IE_NAME = 'niconico'
|
||||
IE_DESC = 'ニコニコ動画'
|
||||
_GEO_COUNTRIES = ['JP']
|
||||
_GEO_BYPASS = False
|
||||
|
||||
_TESTS = [{
|
||||
'url': 'http://www.nicovideo.jp/watch/sm22312215',
|
||||
@ -478,15 +480,27 @@ def _real_extract(self, url):
|
||||
raise
|
||||
raise ExtractorError(clean_html(error_msg), expected=True)
|
||||
|
||||
club_joined = traverse_obj(api_data, ('channel', 'viewer', 'follow', 'isFollowed', {bool}))
|
||||
if club_joined is None:
|
||||
fail_msg = self._html_search_regex(
|
||||
availability = self._availability(**(traverse_obj(api_data, ('payment', 'video', {
|
||||
'needs_premium': ('isPremium', {bool}),
|
||||
'needs_subscription': ('isAdmission', {bool}),
|
||||
})) or {'needs_auth': True}))
|
||||
formats = [*self._yield_dmc_formats(api_data, video_id),
|
||||
*self._yield_dms_formats(api_data, video_id)]
|
||||
if not formats:
|
||||
fail_msg = clean_html(self._html_search_regex(
|
||||
r'<p[^>]+\bclass="fail-message"[^>]*>(?P<msg>.+?)</p>',
|
||||
webpage, 'fail message', default=None, group='msg')
|
||||
webpage, 'fail message', default=None, group='msg'))
|
||||
if fail_msg:
|
||||
self.raise_login_required(clean_html(fail_msg), metadata_available=True)
|
||||
elif not club_joined:
|
||||
self.to_screen(f'Niconico said: {fail_msg}')
|
||||
if fail_msg and 'された地域と同じ地域からのみ視聴できます。' in fail_msg:
|
||||
availability = None
|
||||
self.raise_geo_restricted(countries=self._GEO_COUNTRIES, metadata_available=True)
|
||||
elif availability == 'premium_only':
|
||||
self.raise_login_required('This video requires premium', metadata_available=True)
|
||||
elif availability == 'subscriber_only':
|
||||
self.raise_login_required('This video is for members only', metadata_available=True)
|
||||
elif availability == 'needs_auth':
|
||||
self.raise_login_required(metadata_available=False)
|
||||
|
||||
# Start extracting information
|
||||
tags = None
|
||||
@ -512,8 +526,8 @@ def get_video_info(*items, get_first=True, **kwargs):
|
||||
'id': video_id,
|
||||
'_api_data': api_data,
|
||||
'title': get_video_info(('originalTitle', 'title')) or self._og_search_title(webpage, default=None),
|
||||
'formats': [*self._yield_dmc_formats(api_data, video_id),
|
||||
*self._yield_dms_formats(api_data, video_id)],
|
||||
'formats': formats,
|
||||
'availability': availability,
|
||||
'thumbnails': [{
|
||||
'id': key,
|
||||
'url': url,
|
||||
|
Loading…
Reference in New Issue
Block a user