[youtube:tab] Support channel search

Fixes: https://github.com/ytdl-org/youtube-dl/issues/29071
pull/310/head
pukkandan 4 years ago
parent da692b7920
commit cd684175ad
No known key found for this signature in database
GPG Key ID: 0F00D95A001F4698

@ -2666,6 +2666,17 @@ class YoutubeTabIE(YoutubeBaseInfoExtractor):
'uploader_id': 'UCKfVa3S1e4PHvxWcwyMMg8w', 'uploader_id': 'UCKfVa3S1e4PHvxWcwyMMg8w',
}, },
'playlist_mincount': 12, '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', 'url': 'https://invidio.us/channel/UCmlqkdCBesrv2Lak1mF_MxA',
'only_matching': True, 'only_matching': True,
@ -3234,8 +3245,9 @@ class YoutubeTabIE(YoutubeBaseInfoExtractor):
@staticmethod @staticmethod
def _extract_selected_tab(tabs): def _extract_selected_tab(tabs):
for tab in tabs: for tab in tabs:
if try_get(tab, lambda x: x['tabRenderer']['selected'], bool): renderer = dict_get(tab, ('tabRenderer', 'expandableTabRenderer')) or {}
return tab['tabRenderer'] if renderer.get('selected') is True:
return renderer
else: else:
raise ExtractorError('Unable to find selected tab') raise ExtractorError('Unable to find selected tab')
@ -3309,6 +3321,7 @@ class YoutubeTabIE(YoutubeBaseInfoExtractor):
try_get(data, lambda x: x['header']['hashtagHeaderRenderer']['hashtag']['simpleText']) try_get(data, lambda x: x['header']['hashtagHeaderRenderer']['hashtag']['simpleText'])
or playlist_id) or playlist_id)
title += format_field(selected_tab, 'title', ' - %s') title += format_field(selected_tab, 'title', ' - %s')
title += format_field(selected_tab, 'expandedText', ' - %s')
metadata = { metadata = {
'playlist_id': playlist_id, 'playlist_id': playlist_id,

Loading…
Cancel
Save