[youtube] Support channel search

Code from cd684175ad
This commit is contained in:
pukkandan 2022-01-30 01:24:09 +05:30 committed by dirkf
parent 41f0043983
commit 78ce962f4f

View File

@ -2438,6 +2438,17 @@ class YoutubeTabIE(YoutubeBaseInfoExtractor):
}, { }, {
'url': 'https://www.youtube.com/watch?list=PLW4dVinRY435CBE_JD3t-0SRXKfnZHS1P&feature=youtu.be&v=M9cJMXmQ_ZU', 'url': 'https://www.youtube.com/watch?list=PLW4dVinRY435CBE_JD3t-0SRXKfnZHS1P&feature=youtu.be&v=M9cJMXmQ_ZU',
'only_matching': True, 'only_matching': True,
}, {
'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',
}
}] }]
@classmethod @classmethod
@ -2835,8 +2846,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')
@ -2893,6 +2905,8 @@ class YoutubeTabIE(YoutubeBaseInfoExtractor):
title = channel_title or item_id title = channel_title or item_id
if tab_title: if tab_title:
title += ' - %s' % tab_title title += ' - %s' % tab_title
if selected_tab.get('expandedText'):
title += ' - %s' % selected_tab['expandedText']
description = renderer.get('description') description = renderer.get('description')
playlist_id = renderer.get('externalId') playlist_id = renderer.get('externalId')
else: else: