Refactor the return result

Co-authored-by: pukkandan <pukkandan.ytdlp@gmail.com>
This commit is contained in:
HobbyistDev 2024-04-11 21:29:54 +08:00 committed by GitHub
parent c895dfea10
commit 6c6ad3298d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 15 additions and 18 deletions

View File

@ -57,12 +57,6 @@ class XiaoHongSuIE(InfoExtractor):
})
})
if len(formats) == 0:
formats.append({
'url': self._html_search_meta(['og:video'], webpage),
'ext': 'mp4'
})
thumbnails = []
for image_info in traverse_obj(note_info, ('imageList', ...)):
for url in traverse_obj(image_info, (('urlDefault', 'urlPre'), {url_or_none})):
@ -74,16 +68,19 @@ class XiaoHongSuIE(InfoExtractor):
})
})
return merge_dicts({
return {
'id': display_id,
'formats': formats,
'thumbnails': thumbnails
}, traverse_obj(note_info, {
'title': 'title',
'description': 'desc',
'tags': ('tagList', ..., 'name', {str}),
'uploader_id': ('user', 'userId'),
}), {
'title': self._html_search_meta(['og:title'], webpage),
'thumbnail': self._html_search_meta(['og:image'], webpage),
})
'formats': formats or [{
'url': self._html_search_meta(['og:video'], webpage, fatal=True),
'ext': 'mp4'
}],
'thumbnails': thumbnails or [{'url':
self._html_search_meta(['og:image'], webpage)}]
'title': self._html_search_meta(['og:title'], webpage, default=None),
**traverse_obj(note_info, {
'title': 'title',
'description': 'desc',
'tags': ('tagList', ..., 'name', {str}),
'uploader_id': ('user', 'userId'),
}),
}