mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-27 14:14:54 +01:00
add video metadata fallback api call, fix linter errors
This commit is contained in:
parent
722ac25c98
commit
0217522df6
|
@ -50,6 +50,28 @@ class BannedVideoBaseIE(InfoExtractor):
|
|||
}
|
||||
}'''
|
||||
|
||||
_GRAPHQL_GETMETADATA_FALLBACK_QUERY = '''
|
||||
query GetVideo($id: String!) {
|
||||
getVideo(id: $id) {
|
||||
...DisplayVideoFields streamUrl directUrl liked disliked audio unlisted live tags {
|
||||
_id name __typename
|
||||
}
|
||||
sale {
|
||||
_id text textSale description url videoUpload {
|
||||
cloudflareVideoUID __typename
|
||||
}
|
||||
__typename
|
||||
}
|
||||
__typename
|
||||
}
|
||||
}
|
||||
fragment DisplayVideoFields on Video {
|
||||
_id title summary playCount likeCount angerCount largeImage embedUrl published videoDuration channel {
|
||||
_id title avatar __typename
|
||||
}
|
||||
createdAt __typename
|
||||
}'''
|
||||
|
||||
_GRAPHQL_GETCOMMENTSREPLIES_QUERY = '''
|
||||
query GetCommentReplies($id: String!) {
|
||||
getCommentReplies(id: $id, limit: 999999, offset: 0) {
|
||||
|
@ -114,6 +136,7 @@ class BannedVideoBaseIE(InfoExtractor):
|
|||
|
||||
_GRAPHQL_QUERIES = {
|
||||
'GetVideoAndComments': _GRAPHQL_GETMETADATA_QUERY,
|
||||
'GetVideo': _GRAPHQL_GETMETADATA_FALLBACK_QUERY,
|
||||
'GetCommentReplies': _GRAPHQL_GETCOMMENTSREPLIES_QUERY,
|
||||
'GetChannel': _GRAPHQL_GETCHANNEL_QUERY,
|
||||
'GetChannelVideos': _GRAPHQL_GETCHANNELVIDEOS_QUERY,
|
||||
|
@ -195,9 +218,11 @@ def _parse_comment(comment_data, parent):
|
|||
def _real_extract(self, url):
|
||||
video_id = self._match_id(url)
|
||||
video_json = self._call_api(video_id, 'GetVideoAndComments', 'Downloading video metadata')
|
||||
if not video_json:
|
||||
video_json = self._call_api(video_id, 'GetVideo', 'Downloading video metadata (fallback)')
|
||||
video_info = video_json['getVideo']
|
||||
is_live = video_info.get('live')
|
||||
comments = [self._parse_comment(comment, 'root') for comment in video_json.get('getVideoComments')]
|
||||
comments = [self._parse_comment(comment, 'root') for comment in video_json.get('getVideoComments', [])]
|
||||
|
||||
formats = [{
|
||||
'format_id': 'direct',
|
||||
|
@ -257,8 +282,8 @@ def _real_extract(self, url):
|
|||
channel_id = channel_info['_id']
|
||||
|
||||
return self.playlist_result(
|
||||
[self.url_result(f'https://banned.video/watch?id={id}', url_transparent=True)
|
||||
for id in self._paginate(channel_id, 'GetChannelVideos')],
|
||||
[self.url_result(f'https://banned.video/watch?id={vid}', url_transparent=True)
|
||||
for vid in self._paginate(channel_id, 'GetChannelVideos')],
|
||||
channel_id, channel_info['title'], channel_info.get('summary'),
|
||||
thumbnail=channel_info.get('coverImage'))
|
||||
|
||||
|
@ -288,6 +313,6 @@ def _real_extract(self, url):
|
|||
playlist_info = self._call_api(playlist_id, 'GetPlaylist', 'Downloading playlist metadata')['getPlaylist']
|
||||
|
||||
return self.playlist_result(
|
||||
[self.url_result(f'https://banned.video/watch?id={id}', url_transparent=True)
|
||||
for id in self._paginate(playlist_id, 'GetPlaylistVideos')], playlist_id,
|
||||
[self.url_result(f'https://banned.video/watch?id={vid}', url_transparent=True)
|
||||
for vid in self._paginate(playlist_id, 'GetPlaylistVideos')], playlist_id,
|
||||
playlist_info['title'], playlist_info.get('summary'))
|
||||
|
|
Loading…
Reference in New Issue
Block a user