From 955c4cb6ac87d997e090cb809c21bba8cc6e3e0a Mon Sep 17 00:00:00 2001 From: xarantolus Date: Wed, 30 Sep 2020 15:49:51 +0200 Subject: [PATCH] [youtube/search_url]: improve title extraction --- youtube_dl/extractor/youtube.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/youtube_dl/extractor/youtube.py b/youtube_dl/extractor/youtube.py index 1f9cc73717..6207585cf5 100644 --- a/youtube_dl/extractor/youtube.py +++ b/youtube_dl/extractor/youtube.py @@ -3257,12 +3257,12 @@ def extract_videos_from_page_impl(self, page, ids_in_page, titles_in_page): result_items = self._find_videos_in_json(search_response) - for plobj in result_items: - video_id = try_get(plobj, lambda x: x['videoId']) - video_title = try_get(plobj, lambda x: x['title']['runs'][0]['text']) + for renderer in result_items: + video_id = try_get(renderer, lambda x: x['videoId']) + video_title = try_get(renderer, lambda x: x['title']['runs'][0]['text']) or try_get(renderer, lambda x: x['title']['simpleText']) if video_id is None or video_title is None: - # we do not have a videoRenderer or it is empty + # we do not have a videoRenderer or title extraction broke continue video_title = video_title.strip()