0
0
Fork 0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2024-11-22 02:15:12 +00:00

[youtube:tab] Support channel search

Fixes: https://github.com/ytdl-org/youtube-dl/issues/29071
This commit is contained in:
pukkandan 2021-05-18 19:30:21 +05:30
parent da692b7920
commit cd684175ad
No known key found for this signature in database
GPG key ID: 0F00D95A001F4698

View file

@ -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 @@ def extract_entries(parent_renderer): # this needs to called again for continua
@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 @@ def _extract_from_tabs(self, item_id, webpage, data, tabs):
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,