From cd684175adbe663bbdf6a6c72d8b99b617b6ff2e Mon Sep 17 00:00:00 2001 From: pukkandan Date: Tue, 18 May 2021 19:30:21 +0530 Subject: [PATCH] [youtube:tab] Support channel search Fixes: https://github.com/ytdl-org/youtube-dl/issues/29071 --- yt_dlp/extractor/youtube.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/yt_dlp/extractor/youtube.py b/yt_dlp/extractor/youtube.py index a2c497ab7..d7cba7589 100644 --- a/yt_dlp/extractor/youtube.py +++ b/yt_dlp/extractor/youtube.py @@ -2666,6 +2666,17 @@ class YoutubeTabIE(YoutubeBaseInfoExtractor): 'uploader_id': 'UCKfVa3S1e4PHvxWcwyMMg8w', }, 'playlist_mincount': 12, + }, { + 'note': 'Search tab', + 'url': 'https://www.youtube.com/c/3blue1brown/search?query=linear%20algebra', + 'playlist_mincount': 40, + 'info_dict': { + 'id': 'UCYO_jab_esuFRV4b17AJtAw', + 'title': '3Blue1Brown - Search - linear algebra', + 'description': 'md5:e1384e8a133307dd10edee76e875d62f', + 'uploader': '3Blue1Brown', + 'uploader_id': 'UCYO_jab_esuFRV4b17AJtAw', + }, }, { 'url': 'https://invidio.us/channel/UCmlqkdCBesrv2Lak1mF_MxA', 'only_matching': True, @@ -3234,8 +3245,9 @@ class YoutubeTabIE(YoutubeBaseInfoExtractor): @staticmethod def _extract_selected_tab(tabs): for tab in tabs: - if try_get(tab, lambda x: x['tabRenderer']['selected'], bool): - return tab['tabRenderer'] + renderer = dict_get(tab, ('tabRenderer', 'expandableTabRenderer')) or {} + if renderer.get('selected') is True: + return renderer else: raise ExtractorError('Unable to find selected tab') @@ -3309,6 +3321,7 @@ class YoutubeTabIE(YoutubeBaseInfoExtractor): try_get(data, lambda x: x['header']['hashtagHeaderRenderer']['hashtag']['simpleText']) or playlist_id) title += format_field(selected_tab, 'title', ' - %s') + title += format_field(selected_tab, 'expandedText', ' - %s') metadata = { 'playlist_id': playlist_id,