prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Yacy results crash
  Getting:
  Engines cannot retrieve results:
  yacy (unexpected crash)
  
  > ERROR:searx.search:engine yacy : exception : 'url'
  > Traceback (most recent call last):
  >   File "/home/leo/searx/searx/search.py", line 118, in search_one_request_safe
  >     search_results = search_one_request(engine, query, request_params, start_time, timeout_limit)
  >   File "/home/leo/searx/searx/search.py", line 110, in search_one_request
  >     return engine.response(response)
  >   File "/home/leo/searx/searx/engines/yacy.py", line 80, in response
  >     results.append({'url': result['url'],
  > KeyError: 'url'
  
  </issue>
  <code>
  [start of searx/engines/yacy.py]
  1 # Yacy (Web, Images, Videos, Music, Files)
  2 #
  3 # @website     http://yacy.net
  4 # @provide-api yes
  5 #              (http://www.yacy-websuche.de/wiki/index.php/Dev:APIyacysearch)
  6 #
  7 # @using-api   yes
  8 # @results     JSON
  9 # @stable      yes
  10 # @parse       (general)    url, title, content, publishedDate
  11 # @parse       (images)     url, title, img_src
  12 #
  13 # @todo        parse video, audio and file results
  14 
  15 from json import loads
  16 from dateutil import parser
  17 from searx.url_utils import urlencode
  18 
  19 from searx.utils import html_to_text
  20 
  21 # engine dependent config
  22 categories = ['general', 'images']  # TODO , 'music', 'videos', 'files'
  23 paging = True
  24 language_support = True
  25 number_of_results = 5
  26 
  27 # search-url
  28 base_url = 'http://localhost:8090'
  29 search_url = '/yacysearch.json?{query}'\
  30              '&startRecord={offset}'\
  31              '&maximumRecords={limit}'\
  32              '&contentdom={search_type}'\
  33              '&resource=global'
  34 
  35 # yacy specific type-definitions
  36 search_types = {'general': 'text',
  37                 'images': 'image',
  38                 'files': 'app',
  39                 'music': 'audio',
  40                 'videos': 'video'}
  41 
  42 
  43 # do search-request
  44 def request(query, params):
  45     offset = (params['pageno'] - 1) * number_of_results
  46     search_type = search_types.get(params.get('category'), '0')
  47 
  48     params['url'] = base_url +\
  49         search_url.format(query=urlencode({'query': query}),
  50                           offset=offset,
  51                           limit=number_of_results,
  52                           search_type=search_type)
  53 
  54     params['url'] += '&lr=lang_' + params['language'].split('-')[0]
  55 
  56     return params
  57 
  58 
  59 # get response from search-request
  60 def response(resp):
  61     results = []
  62 
  63     raw_search_results = loads(resp.text)
  64 
  65     # return empty array if there are no results
  66     if not raw_search_results:
  67         return []
  68 
  69     search_results = raw_search_results.get('channels', [])
  70 
  71     if len(search_results) == 0:
  72         return []
  73 
  74     for result in search_results[0].get('items', []):
  75         # parse image results
  76         if result.get('image'):
  77             # append result
  78             results.append({'url': result['url'],
  79                             'title': result['title'],
  80                             'content': '',
  81                             'img_src': result['image'],
  82                             'template': 'images.html'})
  83 
  84         # parse general results
  85         else:
  86             publishedDate = parser.parse(result['pubDate'])
  87 
  88             # append result
  89             results.append({'url': result['link'],
  90                             'title': result['title'],
  91                             'content': html_to_text(result['description']),
  92                             'publishedDate': publishedDate})
  93 
  94         # TODO parse video, audio and file results
  95 
  96     # return results
  97     return results
  98
  [end of searx/engines/yacy.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/yacy.py b/searx/engines/yacy.py
  --- a/searx/engines/yacy.py
  +++ b/searx/engines/yacy.py
  @@ -74,8 +74,17 @@
       for result in search_results[0].get('items', []):
           # parse image results
           if result.get('image'):
  +
  +            result_url = ''
  +            if 'url' in result:
  +                result_url = result['url']
  +            elif 'link' in result:
  +                result_url = result['link']
  +            else:
  +                continue
  +
               # append result
  -            results.append({'url': result['url'],
  +            results.append({'url': result_url,
                               'title': result['title'],
                               'content': '',
                               'img_src': result['image'],
  
verification_info: {"golden_diff": "diff --git a/searx/engines/yacy.py b/searx/engines/yacy.py\n--- a/searx/engines/yacy.py\n+++ b/searx/engines/yacy.py\n@@ -74,8 +74,17 @@\n     for result in search_results[0].get('items', []):\n         # parse image results\n         if result.get('image'):\n+\n+            result_url = ''\n+            if 'url' in result:\n+                result_url = result['url']\n+            elif 'link' in result:\n+                result_url = result['link']\n+            else:\n+                continue\n+\n             # append result\n-            results.append({'url': result['url'],\n+            results.append({'url': result_url,\n                             'title': result['title'],\n                             'content': '',\n                             'img_src': result['image'],\n", "issue": "Yacy results crash\nGetting:\r\nEngines cannot retrieve results:\r\nyacy (unexpected crash)\r\n\r\n> ERROR:searx.search:engine yacy : exception : 'url'\r\n> Traceback (most recent call last):\r\n>   File \"/home/leo/searx/searx/search.py\", line 118, in search_one_request_safe\r\n>     search_results = search_one_request(engine, query, request_params, start_time, timeout_limit)\r\n>   File \"/home/leo/searx/searx/search.py\", line 110, in search_one_request\r\n>     return engine.response(response)\r\n>   File \"/home/leo/searx/searx/engines/yacy.py\", line 80, in response\r\n>     results.append({'url': result['url'],\r\n> KeyError: 'url'\n", "before_files": [{"content": "# Yacy (Web, Images, Videos, Music, Files)\n#\n# @website     http://yacy.net\n# @provide-api yes\n#              (http://www.yacy-websuche.de/wiki/index.php/Dev:APIyacysearch)\n#\n# @using-api   yes\n# @results     JSON\n# @stable      yes\n# @parse       (general)    url, title, content, publishedDate\n# @parse       (images)     url, title, img_src\n#\n# @todo        parse video, audio and file results\n\nfrom json import loads\nfrom dateutil import parser\nfrom searx.url_utils import urlencode\n\nfrom searx.utils import html_to_text\n\n# engine dependent config\ncategories = ['general', 'images']  # TODO , 'music', 'videos', 'files'\npaging = True\nlanguage_support = True\nnumber_of_results = 5\n\n# search-url\nbase_url = 'http://localhost:8090'\nsearch_url = '/yacysearch.json?{query}'\\\n             '&startRecord={offset}'\\\n             '&maximumRecords={limit}'\\\n             '&contentdom={search_type}'\\\n             '&resource=global'\n\n# yacy specific type-definitions\nsearch_types = {'general': 'text',\n                'images': 'image',\n                'files': 'app',\n                'music': 'audio',\n                'videos': 'video'}\n\n\n# do search-request\ndef request(query, params):\n    offset = (params['pageno'] - 1) * number_of_results\n    search_type = search_types.get(params.get('category'), '0')\n\n    params['url'] = base_url +\\\n        search_url.format(query=urlencode({'query': query}),\n                          offset=offset,\n                          limit=number_of_results,\n                          search_type=search_type)\n\n    params['url'] += '&lr=lang_' + params['language'].split('-')[0]\n\n    return params\n\n\n# get response from search-request\ndef response(resp):\n    results = []\n\n    raw_search_results = loads(resp.text)\n\n    # return empty array if there are no results\n    if not raw_search_results:\n        return []\n\n    search_results = raw_search_results.get('channels', [])\n\n    if len(search_results) == 0:\n        return []\n\n    for result in search_results[0].get('items', []):\n        # parse image results\n        if result.get('image'):\n            # append result\n            results.append({'url': result['url'],\n                            'title': result['title'],\n                            'content': '',\n                            'img_src': result['image'],\n                            'template': 'images.html'})\n\n        # parse general results\n        else:\n            publishedDate = parser.parse(result['pubDate'])\n\n            # append result\n            results.append({'url': result['link'],\n                            'title': result['title'],\n                            'content': html_to_text(result['description']),\n                            'publishedDate': publishedDate})\n\n        # TODO parse video, audio and file results\n\n    # return results\n    return results\n", "path": "searx/engines/yacy.py"}]}