[ie/youtube] Attempt to extract title for Shorts from accessibilityText as fallback (#11991)

Closes #11991

Co-authored-by: bashonly <88596187+bashonly@users.noreply.github.com>
This commit is contained in:
kibaa 2025-01-04 20:46:50 +01:00
parent 0b6b7742c2
commit 4b951b09b2

View file

@ -5210,10 +5210,12 @@ def _rich_entries(self, rich_grid_renderer):
yield self.url_result(
f'https://www.youtube.com/shorts/{video_id}',
ie=YoutubeIE, video_id=video_id,
**traverse_obj(renderer, ('overlayMetadata', {
'title': ('primaryText', 'content', {str}),
'view_count': ('secondaryText', 'content', {parse_count}),
})),
**traverse_obj(renderer, {
'title': ((
('overlayMetadata', 'primaryText', 'content', {str}),
('accessibilityText', {lambda x: re.fullmatch(r'(.+), (?:[\d,.]+(?:[KM]| million)?|No) views? - play Short', x)}, 1)), any),
'view_count': ('overlayMetadata', 'secondaryText', 'content', {parse_count}),
}),
thumbnails=self._extract_thumbnails(renderer, 'thumbnail', final_key='sources'))
return