diff options
Diffstat (limited to 'searx/engines/youtube_noapi.py')
-rw-r--r-- | searx/engines/youtube_noapi.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/searx/engines/youtube_noapi.py b/searx/engines/youtube_noapi.py index b015dff8d..c2136c3ca 100644 --- a/searx/engines/youtube_noapi.py +++ b/searx/engines/youtube_noapi.py @@ -7,6 +7,8 @@ from functools import reduce from json import loads, dumps from urllib.parse import quote_plus +from searx.utils import extr + # about about = { "website": 'https://www.youtube.com/', @@ -109,8 +111,8 @@ def parse_next_page_response(response_text): def parse_first_page_response(response_text): results = [] - results_data = response_text[response_text.find('ytInitialData') :] - results_data = results_data[results_data.find('{') : results_data.find(';</script>')] + results_data = extr(response_text, 'ytInitialData = ', ';</script>') + results_json = loads(results_data) if results_data else {} sections = ( results_json.get('contents', {}) |