# SPDX-License-Identifier: AGPL-3.0-or-later """Google (Video) For detailed description of the *REST-full* API see: `Query Parameter Definitions`_. Not all parameters can be applied. .. _admonition:: Content-Security-Policy (CSP) This engine needs to allow images from the `data URLs`_ (prefixed with the ``data:` scheme).:: Header set Content-Security-Policy "img-src 'self' data: ;" .. _Query Parameter Definitions: https://developers.google.com/custom-search/docs/xml_results#WebSearch_Query_Parameter_Definitions .. _data URLs: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs """ # pylint: disable=invalid-name, missing-function-docstring import re from urllib.parse import urlencode from random import random from lxml import html from searx import logger from searx.utils import ( eval_xpath, eval_xpath_list, eval_xpath_getindex, extract_text, ) from searx.engines.google import ( get_lang_info, time_range_dict, filter_mapping, results_xpath, g_section_with_header, title_xpath, href_xpath, content_xpath, suggestion_xpath, spelling_suggestion_xpath, detect_google_sorry, ) # pylint: disable=unused-import from searx.engines.google import ( supported_languages_url , _fetch_supported_languages ) # pylint: enable=unused-import # about about = { "website": 'https://www.google.com', "wikidata_id": 'Q219885', "official_api_documentation": 'https://developers.google.com/custom-search', "use_official_api": False, "require_api_key": False, "results": 'HTML', } logger = logger.getChild('google video') # engine dependent config categories = ['videos'] paging = False language_support = True use_locale_domain = True time_range_support = True safesearch = True RE_CACHE = {} def _re(regexpr): """returns compiled regular expression""" RE_CACHE[regexpr] = RE_CACHE.get(regexpr, re.compile(regexpr)) return RE_CACHE[regexpr] def scrap_out_thumbs(dom): """Scrap out thumbnail data from