From 76ac023ff02f06e8c003d104f02a03deeddebdcd Mon Sep 17 00:00:00 2001 From: kibaa Date: Sun, 26 Jan 2025 02:23:29 +0100 Subject: [PATCH] [ie/youtube:tab] Improve shorts title extraction (#11991) (#11997) Closes #11991 Authored by: d3d9, bashonly Co-authored-by: bashonly <88596187+bashonly@users.noreply.github.com> --- yt_dlp/extractor/youtube.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/yt_dlp/extractor/youtube.py b/yt_dlp/extractor/youtube.py index d84e8df335..f1c055f3b8 100644 --- a/yt_dlp/extractor/youtube.py +++ b/yt_dlp/extractor/youtube.py @@ -5370,10 +5370,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