mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2026-05-03 14:06:07 +00:00
rework error handling for supporter content
This commit is contained in:
parent
f02819391b
commit
3858f91075
@ -652,18 +652,6 @@ class BiliBiliIE(BilibiliBaseIE):
|
|||||||
else:
|
else:
|
||||||
video_data = initial_state['videoData']
|
video_data = initial_state['videoData']
|
||||||
|
|
||||||
if video_data.get('is_upower_exclusive') and not video_data.get('is_upower_play'):
|
|
||||||
high_level = traverse_obj(initial_state, ('elecFullInfo', 'show_info', 'high_level', {dict})) or {}
|
|
||||||
msg = (
|
|
||||||
f'{join_nonempty("title", "sub_title", from_dict=high_level, delim=",")}. '
|
|
||||||
f'{self._login_hint()}')
|
|
||||||
if video_data.get('is_upower_preview'):
|
|
||||||
self.report_warning(
|
|
||||||
f'This is a supporter-only video, only the preview will be extracted: {msg}',
|
|
||||||
video_id=video_id)
|
|
||||||
else:
|
|
||||||
raise ExtractorError(f'This is a supporter-only video: {msg}', expected=True)
|
|
||||||
|
|
||||||
video_id, title = video_data['bvid'], video_data.get('title')
|
video_id, title = video_data['bvid'], video_data.get('title')
|
||||||
|
|
||||||
# Bilibili anthologies are similar to playlists but all videos share the same video ID as the anthology itself.
|
# Bilibili anthologies are similar to playlists but all videos share the same video ID as the anthology itself.
|
||||||
@ -734,6 +722,18 @@ class BiliBiliIE(BilibiliBaseIE):
|
|||||||
else:
|
else:
|
||||||
formats = self.extract_formats(play_info)
|
formats = self.extract_formats(play_info)
|
||||||
|
|
||||||
|
if video_data.get('is_upower_exclusive'):
|
||||||
|
high_level = traverse_obj(initial_state, ('elecFullInfo', 'show_info', 'high_level', {dict})) or {}
|
||||||
|
msg = (
|
||||||
|
f'{join_nonempty("title", "sub_title", from_dict=high_level, delim=",")}. '
|
||||||
|
f'{self._login_hint()}')
|
||||||
|
if not formats:
|
||||||
|
raise ExtractorError(f'This is a supporter-only video: {msg}', expected=True)
|
||||||
|
if '试看' in traverse_obj(play_info, ('accept_description', ..., {str})):
|
||||||
|
self.report_warning(
|
||||||
|
f'This is a supporter-only video, only the preview will be extracted: {msg}',
|
||||||
|
video_id=video_id)
|
||||||
|
|
||||||
if not traverse_obj(play_info, ('dash')):
|
if not traverse_obj(play_info, ('dash')):
|
||||||
# we only have legacy formats and need additional work
|
# we only have legacy formats and need additional work
|
||||||
has_qn = lambda x: x in traverse_obj(formats, (..., 'quality'))
|
has_qn = lambda x: x in traverse_obj(formats, (..., 'quality'))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user