Skip to content

Commit

Permalink
[youtube] Support channel search
Browse files Browse the repository at this point in the history
  • Loading branch information
pukkandan authored and dirkf committed Feb 3, 2022
1 parent 41f0043 commit 78ce962
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions youtube_dl/extractor/youtube.py
Original file line number Diff line number Diff line change
Expand Up @@ -2438,6 +2438,17 @@ class YoutubeTabIE(YoutubeBaseInfoExtractor):
}, {
'url': 'https://www.youtube.com/watch?list=PLW4dVinRY435CBE_JD3t-0SRXKfnZHS1P&feature=youtu.be&v=M9cJMXmQ_ZU',
'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
Expand Down Expand Up @@ -2835,8 +2846,9 @@ def _entries(self, tab, item_id, webpage):
@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')

Expand Down Expand Up @@ -2893,6 +2905,8 @@ def _extract_from_tabs(self, item_id, webpage, data, tabs):
title = channel_title or item_id
if tab_title:
title += ' - %s' % tab_title
if selected_tab.get('expandedText'):
title += ' - %s' % selected_tab['expandedText']
description = renderer.get('description')
playlist_id = renderer.get('externalId')
else:
Expand Down

0 comments on commit 78ce962

Please sign in to comment.