prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Bing Video search engine doesn't work
  Hallo,
  
  yesterday I've set up my own instance of searx. Thereby I discovered A problem with the Bing Video search engine. This is the shown error message:
  
  ```
  Die folgenden Suchmaschinen können die Ergebnisse nicht empfangen:
  bing videos (unexpected crash: list index out of range)
  ```
  
  </issue>
  <code>
  [start of searx/engines/bing_videos.py]
  1 """
  2  Bing (Videos)
  3 
  4  @website     https://www.bing.com/videos
  5  @provide-api yes (http://datamarket.azure.com/dataset/bing/search)
  6 
  7  @using-api   no
  8  @results     HTML
  9  @stable      no
  10  @parse       url, title, content, thumbnail
  11 """
  12 
  13 from json import loads
  14 from lxml import html
  15 from searx.engines.bing_images import _fetch_supported_languages, supported_languages_url, get_region_code
  16 from searx.engines.xpath import extract_text
  17 from searx.url_utils import urlencode
  18 
  19 
  20 categories = ['videos']
  21 paging = True
  22 safesearch = True
  23 time_range_support = True
  24 number_of_results = 10
  25 language_support = True
  26 
  27 search_url = 'https://www.bing.com/videos/asyncv2?{query}&async=content&'\
  28              'first={offset}&count={number_of_results}&CW=1366&CH=25&FORM=R5VR5'
  29 time_range_string = '&qft=+filterui:videoage-lt{interval}'
  30 time_range_dict = {'day': '1440',
  31                    'week': '10080',
  32                    'month': '43200',
  33                    'year': '525600'}
  34 
  35 # safesearch definitions
  36 safesearch_types = {2: 'STRICT',
  37                     1: 'DEMOTE',
  38                     0: 'OFF'}
  39 
  40 
  41 # do search-request
  42 def request(query, params):
  43     offset = (params['pageno'] - 1) * 10 + 1
  44 
  45     # safesearch cookie
  46     params['cookies']['SRCHHPGUSR'] = \
  47         'ADLT=' + safesearch_types.get(params['safesearch'], 'DEMOTE')
  48 
  49     # language cookie
  50     region = get_region_code(params['language'], lang_list=supported_languages)
  51     params['cookies']['_EDGE_S'] = 'mkt=' + region + '&F=1'
  52 
  53     # query and paging
  54     params['url'] = search_url.format(query=urlencode({'q': query}),
  55                                       offset=offset,
  56                                       number_of_results=number_of_results)
  57 
  58     # time range
  59     if params['time_range'] in time_range_dict:
  60         params['url'] += time_range_string.format(interval=time_range_dict[params['time_range']])
  61 
  62     return params
  63 
  64 
  65 # get response from search-request
  66 def response(resp):
  67     results = []
  68 
  69     dom = html.fromstring(resp.text)
  70 
  71     for result in dom.xpath('//div[@class="dg_u"]'):
  72 
  73         # try to extract the url
  74         url_container = result.xpath('.//div[@class="sa_wrapper"]/@data-eventpayload')
  75         if len(url_container) > 0:
  76             url = loads(url_container[0])['purl']
  77         else:
  78             url = result.xpath('./a/@href')[0]
  79 
  80             # discard results that do not return an external url
  81             # very recent results sometimes don't return the video's url
  82             if url.startswith('/videos/search?'):
  83                 continue
  84 
  85         title = extract_text(result.xpath('./a//div[@class="tl"]'))
  86         content = extract_text(result.xpath('.//div[@class="pubInfo"]'))
  87         thumbnail = result.xpath('.//div[@class="vthumb"]/img/@src')[0]
  88 
  89         results.append({'url': url,
  90                         'title': title,
  91                         'content': content,
  92                         'thumbnail': thumbnail,
  93                         'template': 'videos.html'})
  94 
  95         # first page ignores requested number of results
  96         if len(results) >= number_of_results:
  97             break
  98 
  99     return results
  100
  [end of searx/engines/bing_videos.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
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
  @@ -69,22 +69,11 @@
       dom = html.fromstring(resp.text)
   
       for result in dom.xpath('//div[@class="dg_u"]'):
  -
  -        # try to extract the url
  -        url_container = result.xpath('.//div[@class="sa_wrapper"]/@data-eventpayload')
  -        if len(url_container) > 0:
  -            url = loads(url_container[0])['purl']
  -        else:
  -            url = result.xpath('./a/@href')[0]
  -
  -            # discard results that do not return an external url
  -            # very recent results sometimes don't return the video's url
  -            if url.startswith('/videos/search?'):
  -                continue
  -
  -        title = extract_text(result.xpath('./a//div[@class="tl"]'))
  -        content = extract_text(result.xpath('.//div[@class="pubInfo"]'))
  -        thumbnail = result.xpath('.//div[@class="vthumb"]/img/@src')[0]
  +        url = result.xpath('./div[@class="mc_vtvc"]/a/@href')[0]
  +        url = 'https://bing.com' + url
  +        title = extract_text(result.xpath('./div/a/div/div[@class="mc_vtvc_title"]/@title'))
  +        content = extract_text(result.xpath('./div/a/div/div/div/div/text()'))
  +        thumbnail = result.xpath('./div/a/div/div/img/@src')[0]
   
           results.append({'url': url,
                           'title': title,
  @@ -92,7 +81,6 @@
                           'thumbnail': thumbnail,
                           'template': 'videos.html'})
   
  -        # first page ignores requested number of results
           if len(results) >= number_of_results:
               break
  
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@@ -69,22 +69,11 @@\n     dom = html.fromstring(resp.text)\n \n     for result in dom.xpath('//div[@class=\"dg_u\"]'):\n-\n-        # try to extract the url\n-        url_container = result.xpath('.//div[@class=\"sa_wrapper\"]/@data-eventpayload')\n-        if len(url_container) > 0:\n-            url = loads(url_container[0])['purl']\n-        else:\n-            url = result.xpath('./a/@href')[0]\n-\n-            # discard results that do not return an external url\n-            # very recent results sometimes don't return the video's url\n-            if url.startswith('/videos/search?'):\n-                continue\n-\n-        title = extract_text(result.xpath('./a//div[@class=\"tl\"]'))\n-        content = extract_text(result.xpath('.//div[@class=\"pubInfo\"]'))\n-        thumbnail = result.xpath('.//div[@class=\"vthumb\"]/img/@src')[0]\n+        url = result.xpath('./div[@class=\"mc_vtvc\"]/a/@href')[0]\n+        url = 'https://bing.com' + url\n+        title = extract_text(result.xpath('./div/a/div/div[@class=\"mc_vtvc_title\"]/@title'))\n+        content = extract_text(result.xpath('./div/a/div/div/div/div/text()'))\n+        thumbnail = result.xpath('./div/a/div/div/img/@src')[0]\n \n         results.append({'url': url,\n                         'title': title,\n@@ -92,7 +81,6 @@\n                         'thumbnail': thumbnail,\n                         'template': 'videos.html'})\n \n-        # first page ignores requested number of results\n         if len(results) >= number_of_results:\n             break\n", "issue": "Bing Video search engine doesn't work\nHallo,\r\n\r\nyesterday I've set up my own instance of searx. Thereby I discovered A problem with the Bing Video search engine. This is the shown error message:\r\n\r\n```\r\nDie folgenden Suchmaschinen k\u00f6nnen die Ergebnisse nicht empfangen:\r\nbing videos (unexpected crash: list index out of range)\r\n```\n", "before_files": [{"content": "\"\"\"\n Bing (Videos)\n\n @website     https://www.bing.com/videos\n @provide-api yes (http://datamarket.azure.com/dataset/bing/search)\n\n @using-api   no\n @results     HTML\n @stable      no\n @parse       url, title, content, thumbnail\n\"\"\"\n\nfrom json import loads\nfrom lxml import html\nfrom searx.engines.bing_images import _fetch_supported_languages, supported_languages_url, get_region_code\nfrom searx.engines.xpath import extract_text\nfrom searx.url_utils import urlencode\n\n\ncategories = ['videos']\npaging = True\nsafesearch = True\ntime_range_support = True\nnumber_of_results = 10\nlanguage_support = True\n\nsearch_url = 'https://www.bing.com/videos/asyncv2?{query}&async=content&'\\\n             'first={offset}&count={number_of_results}&CW=1366&CH=25&FORM=R5VR5'\ntime_range_string = '&qft=+filterui:videoage-lt{interval}'\ntime_range_dict = {'day': '1440',\n                   'week': '10080',\n                   'month': '43200',\n                   'year': '525600'}\n\n# safesearch definitions\nsafesearch_types = {2: 'STRICT',\n                    1: 'DEMOTE',\n                    0: 'OFF'}\n\n\n# do search-request\ndef request(query, params):\n    offset = (params['pageno'] - 1) * 10 + 1\n\n    # safesearch cookie\n    params['cookies']['SRCHHPGUSR'] = \\\n        'ADLT=' + safesearch_types.get(params['safesearch'], 'DEMOTE')\n\n    # language cookie\n    region = get_region_code(params['language'], lang_list=supported_languages)\n    params['cookies']['_EDGE_S'] = 'mkt=' + region + '&F=1'\n\n    # query and paging\n    params['url'] = search_url.format(query=urlencode({'q': query}),\n                                      offset=offset,\n                                      number_of_results=number_of_results)\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\n        # try to extract the url\n        url_container = result.xpath('.//div[@class=\"sa_wrapper\"]/@data-eventpayload')\n        if len(url_container) > 0:\n            url = loads(url_container[0])['purl']\n        else:\n            url = result.xpath('./a/@href')[0]\n\n            # discard results that do not return an external url\n            # very recent results sometimes don't return the video's url\n            if url.startswith('/videos/search?'):\n                continue\n\n        title = extract_text(result.xpath('./a//div[@class=\"tl\"]'))\n        content = extract_text(result.xpath('.//div[@class=\"pubInfo\"]'))\n        thumbnail = result.xpath('.//div[@class=\"vthumb\"]/img/@src')[0]\n\n        results.append({'url': url,\n                        'title': title,\n                        'content': content,\n                        'thumbnail': thumbnail,\n                        'template': 'videos.html'})\n\n        # first page ignores requested number of results\n        if len(results) >= number_of_results:\n            break\n\n    return results\n", "path": "searx/engines/bing_videos.py"}]}