prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Bug: bing videos engine
  **Version of SearXNG, commit number if you are using on master branch and stipulate if you forked SearXNG**
  Repository: https://github.com/searxng/searxng
  Branch: master
  Version: 2022.08.14-649d1a14
  <!-- Check if these values are correct -->
  
  **How did you install SearXNG?**
  searxng-docker
  
  **What happened?**
  bing video search crashed
  
  **How To Reproduce**
  search for anything
  
  **Expected behavior**
  <!-- A clear and concise description of what you expected to happen. -->
  
  **Screenshots & Logs**
  <!-- If applicable, add screenshots, logs to help explain your problem. -->
  
  **Additional context**
  <!-- Add any other context about the problem here. -->
  
  **Technical report**
  
  Error
    * Error: IndexError
    * Percentage: 100
    * Parameters: `()`
    * File name: `searx/engines/bing_videos.py:84`
    * Function: `response`
    * Code: `metadata = loads(result.xpath('.//div[@class="vrhdata"]/@vrhm')[0])`
  
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `searx/engines/bing_videos.py`
  Content:
  ```
  1 # SPDX-License-Identifier: AGPL-3.0-or-later
  2 # lint: pylint
  3 """Bing (Videos)
  4 
  5 """
  6 
  7 from json import loads
  8 from urllib.parse import urlencode
  9 
  10 from lxml import html
  11 
  12 from searx.utils import match_language
  13 from searx.engines.bing import language_aliases
  14 
  15 from searx.engines.bing import (  # pylint: disable=unused-import
  16     _fetch_supported_languages,
  17     supported_languages_url,
  18 )
  19 
  20 about = {
  21     "website": 'https://www.bing.com/videos',
  22     "wikidata_id": 'Q4914152',
  23     "official_api_documentation": 'https://www.microsoft.com/en-us/bing/apis/bing-video-search-api',
  24     "use_official_api": False,
  25     "require_api_key": False,
  26     "results": 'HTML',
  27 }
  28 
  29 categories = ['videos', 'web']
  30 paging = True
  31 safesearch = True
  32 time_range_support = True
  33 send_accept_language_header = True
  34 number_of_results = 28
  35 
  36 base_url = 'https://www.bing.com/'
  37 search_string = (
  38     # fmt: off
  39     'videos/search'
  40     '?{query}'
  41     '&count={count}'
  42     '&first={first}'
  43     '&scope=video'
  44     '&FORM=QBLH'
  45     # fmt: on
  46 )
  47 time_range_string = '&qft=+filterui:videoage-lt{interval}'
  48 time_range_dict = {'day': '1440', 'week': '10080', 'month': '43200', 'year': '525600'}
  49 
  50 # safesearch definitions
  51 safesearch_types = {2: 'STRICT', 1: 'DEMOTE', 0: 'OFF'}
  52 
  53 
  54 # do search-request
  55 def request(query, params):
  56     offset = ((params['pageno'] - 1) * number_of_results) + 1
  57 
  58     search_path = search_string.format(query=urlencode({'q': query}), count=number_of_results, first=offset)
  59 
  60     # safesearch cookie
  61     params['cookies']['SRCHHPGUSR'] = 'ADLT=' + safesearch_types.get(params['safesearch'], 'DEMOTE')
  62 
  63     # language cookie
  64     language = match_language(params['language'], supported_languages, language_aliases).lower()
  65     params['cookies']['_EDGE_S'] = 'mkt=' + language + '&F=1'
  66 
  67     # query and paging
  68     params['url'] = base_url + search_path
  69 
  70     # time range
  71     if params['time_range'] in time_range_dict:
  72         params['url'] += time_range_string.format(interval=time_range_dict[params['time_range']])
  73 
  74     return params
  75 
  76 
  77 # get response from search-request
  78 def response(resp):
  79     results = []
  80 
  81     dom = html.fromstring(resp.text)
  82 
  83     for result in dom.xpath('//div[@class="dg_u"]'):
  84         metadata = loads(result.xpath('.//div[@class="vrhdata"]/@vrhm')[0])
  85         info = ' - '.join(result.xpath('.//div[@class="mc_vtvc_meta_block"]//span/text()')).strip()
  86         content = '{0} - {1}'.format(metadata['du'], info)
  87         thumbnail = '{0}th?id={1}'.format(base_url, metadata['thid'])
  88         results.append(
  89             {
  90                 'url': metadata['murl'],
  91                 'thumbnail': thumbnail,
  92                 'title': metadata.get('vt', ''),
  93                 'content': content,
  94                 'template': 'videos.html',
  95             }
  96         )
  97 
  98     return results
  99
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/searx/engines/bing_videos.py b/searx/engines/bing_videos.py
  --- a/searx/engines/bing_videos.py
  +++ b/searx/engines/bing_videos.py
  @@ -80,7 +80,7 @@
   
       dom = html.fromstring(resp.text)
   
  -    for result in dom.xpath('//div[@class="dg_u"]'):
  +    for result in dom.xpath('//div[@class="dg_u"]/div[contains(@class, "mc_vtvc")]'):
           metadata = loads(result.xpath('.//div[@class="vrhdata"]/@vrhm')[0])
           info = ' - '.join(result.xpath('.//div[@class="mc_vtvc_meta_block"]//span/text()')).strip()
           content = '{0} - {1}'.format(metadata['du'], info)
  
verification_info: {"golden_diff": "diff --git a/searx/engines/bing_videos.py b/searx/engines/bing_videos.py\n--- a/searx/engines/bing_videos.py\n+++ b/searx/engines/bing_videos.py\n@@ -80,7 +80,7 @@\n \n     dom = html.fromstring(resp.text)\n \n-    for result in dom.xpath('//div[@class=\"dg_u\"]'):\n+    for result in dom.xpath('//div[@class=\"dg_u\"]/div[contains(@class, \"mc_vtvc\")]'):\n         metadata = loads(result.xpath('.//div[@class=\"vrhdata\"]/@vrhm')[0])\n         info = ' - '.join(result.xpath('.//div[@class=\"mc_vtvc_meta_block\"]//span/text()')).strip()\n         content = '{0} - {1}'.format(metadata['du'], info)\n", "issue": "Bug: bing videos engine\n**Version of SearXNG, commit number if you are using on master branch and stipulate if you forked SearXNG**\r\nRepository: https://github.com/searxng/searxng\r\nBranch: master\r\nVersion: 2022.08.14-649d1a14\r\n<!-- Check if these values are correct -->\r\n\r\n**How did you install SearXNG?**\r\nsearxng-docker\r\n\r\n**What happened?**\r\nbing video search crashed\r\n\r\n**How To Reproduce**\r\nsearch for anything\r\n\r\n**Expected behavior**\r\n<!-- A clear and concise description of what you expected to happen. -->\r\n\r\n**Screenshots & Logs**\r\n<!-- If applicable, add screenshots, logs to help explain your problem. -->\r\n\r\n**Additional context**\r\n<!-- Add any other context about the problem here. -->\r\n\r\n**Technical report**\r\n\r\nError\r\n  * Error: IndexError\r\n  * Percentage: 100\r\n  * Parameters: `()`\r\n  * File name: `searx/engines/bing_videos.py:84`\r\n  * Function: `response`\r\n  * Code: `metadata = loads(result.xpath('.//div[@class=\"vrhdata\"]/@vrhm')[0])`\r\n\r\n\n", "before_files": [{"content": "# SPDX-License-Identifier: AGPL-3.0-or-later\n# lint: pylint\n\"\"\"Bing (Videos)\n\n\"\"\"\n\nfrom json import loads\nfrom urllib.parse import urlencode\n\nfrom lxml import html\n\nfrom searx.utils import match_language\nfrom searx.engines.bing import language_aliases\n\nfrom searx.engines.bing import (  # pylint: disable=unused-import\n    _fetch_supported_languages,\n    supported_languages_url,\n)\n\nabout = {\n    \"website\": 'https://www.bing.com/videos',\n    \"wikidata_id\": 'Q4914152',\n    \"official_api_documentation\": 'https://www.microsoft.com/en-us/bing/apis/bing-video-search-api',\n    \"use_official_api\": False,\n    \"require_api_key\": False,\n    \"results\": 'HTML',\n}\n\ncategories = ['videos', 'web']\npaging = True\nsafesearch = True\ntime_range_support = True\nsend_accept_language_header = True\nnumber_of_results = 28\n\nbase_url = 'https://www.bing.com/'\nsearch_string = (\n    # fmt: off\n    'videos/search'\n    '?{query}'\n    '&count={count}'\n    '&first={first}'\n    '&scope=video'\n    '&FORM=QBLH'\n    # fmt: on\n)\ntime_range_string = '&qft=+filterui:videoage-lt{interval}'\ntime_range_dict = {'day': '1440', 'week': '10080', 'month': '43200', 'year': '525600'}\n\n# safesearch definitions\nsafesearch_types = {2: 'STRICT', 1: 'DEMOTE', 0: 'OFF'}\n\n\n# do search-request\ndef request(query, params):\n    offset = ((params['pageno'] - 1) * number_of_results) + 1\n\n    search_path = search_string.format(query=urlencode({'q': query}), count=number_of_results, first=offset)\n\n    # safesearch cookie\n    params['cookies']['SRCHHPGUSR'] = 'ADLT=' + safesearch_types.get(params['safesearch'], 'DEMOTE')\n\n    # language cookie\n    language = match_language(params['language'], supported_languages, language_aliases).lower()\n    params['cookies']['_EDGE_S'] = 'mkt=' + language + '&F=1'\n\n    # query and paging\n    params['url'] = base_url + search_path\n\n    # time range\n    if params['time_range'] in time_range_dict:\n        params['url'] += time_range_string.format(interval=time_range_dict[params['time_range']])\n\n    return params\n\n\n# get response from search-request\ndef response(resp):\n    results = []\n\n    dom = html.fromstring(resp.text)\n\n    for result in dom.xpath('//div[@class=\"dg_u\"]'):\n        metadata = loads(result.xpath('.//div[@class=\"vrhdata\"]/@vrhm')[0])\n        info = ' - '.join(result.xpath('.//div[@class=\"mc_vtvc_meta_block\"]//span/text()')).strip()\n        content = '{0} - {1}'.format(metadata['du'], info)\n        thumbnail = '{0}th?id={1}'.format(base_url, metadata['thid'])\n        results.append(\n            {\n                'url': metadata['murl'],\n                'thumbnail': thumbnail,\n                'title': metadata.get('vt', ''),\n                'content': content,\n                'template': 'videos.html',\n            }\n        )\n\n    return results\n", "path": "searx/engines/bing_videos.py"}], "after_files": [{"content": "# SPDX-License-Identifier: AGPL-3.0-or-later\n# lint: pylint\n\"\"\"Bing (Videos)\n\n\"\"\"\n\nfrom json import loads\nfrom urllib.parse import urlencode\n\nfrom lxml import html\n\nfrom searx.utils import match_language\nfrom searx.engines.bing import language_aliases\n\nfrom searx.engines.bing import (  # pylint: disable=unused-import\n    _fetch_supported_languages,\n    supported_languages_url,\n)\n\nabout = {\n    \"website\": 'https://www.bing.com/videos',\n    \"wikidata_id\": 'Q4914152',\n    \"official_api_documentation\": 'https://www.microsoft.com/en-us/bing/apis/bing-video-search-api',\n    \"use_official_api\": False,\n    \"require_api_key\": False,\n    \"results\": 'HTML',\n}\n\ncategories = ['videos', 'web']\npaging = True\nsafesearch = True\ntime_range_support = True\nsend_accept_language_header = True\nnumber_of_results = 28\n\nbase_url = 'https://www.bing.com/'\nsearch_string = (\n    # fmt: off\n    'videos/search'\n    '?{query}'\n    '&count={count}'\n    '&first={first}'\n    '&scope=video'\n    '&FORM=QBLH'\n    # fmt: on\n)\ntime_range_string = '&qft=+filterui:videoage-lt{interval}'\ntime_range_dict = {'day': '1440', 'week': '10080', 'month': '43200', 'year': '525600'}\n\n# safesearch definitions\nsafesearch_types = {2: 'STRICT', 1: 'DEMOTE', 0: 'OFF'}\n\n\n# do search-request\ndef request(query, params):\n    offset = ((params['pageno'] - 1) * number_of_results) + 1\n\n    search_path = search_string.format(query=urlencode({'q': query}), count=number_of_results, first=offset)\n\n    # safesearch cookie\n    params['cookies']['SRCHHPGUSR'] = 'ADLT=' + safesearch_types.get(params['safesearch'], 'DEMOTE')\n\n    # language cookie\n    language = match_language(params['language'], supported_languages, language_aliases).lower()\n    params['cookies']['_EDGE_S'] = 'mkt=' + language + '&F=1'\n\n    # query and paging\n    params['url'] = base_url + search_path\n\n    # time range\n    if params['time_range'] in time_range_dict:\n        params['url'] += time_range_string.format(interval=time_range_dict[params['time_range']])\n\n    return params\n\n\n# get response from search-request\ndef response(resp):\n    results = []\n\n    dom = html.fromstring(resp.text)\n\n    for result in dom.xpath('//div[@class=\"dg_u\"]/div[contains(@class, \"mc_vtvc\")]'):\n        metadata = loads(result.xpath('.//div[@class=\"vrhdata\"]/@vrhm')[0])\n        info = ' - '.join(result.xpath('.//div[@class=\"mc_vtvc_meta_block\"]//span/text()')).strip()\n        content = '{0} - {1}'.format(metadata['du'], info)\n        thumbnail = '{0}th?id={1}'.format(base_url, metadata['thid'])\n        results.append(\n            {\n                'url': metadata['murl'],\n                'thumbnail': thumbnail,\n                'title': metadata.get('vt', ''),\n                'content': content,\n                'template': 'videos.html',\n            }\n        )\n\n    return results\n", "path": "searx/engines/bing_videos.py"}]}