prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Engines cannot retrieve results: piratebay (request exception): PirateBay changed URL
  When some text is entered, and I click on General and Files several times, it shows this error:
  ```
  Error! Engines cannot retrieve results.
  piratebay (request exception)
  Please, try again later or find another searx instance.
  ```
  
  Version 0.14.0 on FreeBSD.
  Default config.
  
  </issue>
  <code>
  [start of searx/engines/piratebay.py]
  1 #  Piratebay (Videos, Music, Files)
  2 #
  3 # @website     https://thepiratebay.se
  4 # @provide-api no (nothing found)
  5 #
  6 # @using-api   no
  7 # @results     HTML (using search portal)
  8 # @stable      yes (HTML can change)
  9 # @parse       url, title, content, seed, leech, magnetlink
  10 
  11 from lxml import html
  12 from operator import itemgetter
  13 from searx.engines.xpath import extract_text
  14 from searx.url_utils import quote, urljoin
  15 
  16 # engine dependent config
  17 categories = ['videos', 'music', 'files']
  18 paging = True
  19 
  20 # search-url
  21 url = 'https://thepiratebay.se/'
  22 search_url = url + 'search/{search_term}/{pageno}/99/{search_type}'
  23 
  24 # piratebay specific type-definitions
  25 search_types = {'files': '0',
  26                 'music': '100',
  27                 'videos': '200'}
  28 
  29 # specific xpath variables
  30 magnet_xpath = './/a[@title="Download this torrent using magnet"]'
  31 torrent_xpath = './/a[@title="Download this torrent"]'
  32 content_xpath = './/font[@class="detDesc"]'
  33 
  34 
  35 # do search-request
  36 def request(query, params):
  37     search_type = search_types.get(params['category'], '0')
  38 
  39     params['url'] = search_url.format(search_term=quote(query),
  40                                       search_type=search_type,
  41                                       pageno=params['pageno'] - 1)
  42 
  43     return params
  44 
  45 
  46 # get response from search-request
  47 def response(resp):
  48     results = []
  49 
  50     dom = html.fromstring(resp.text)
  51 
  52     search_res = dom.xpath('//table[@id="searchResult"]//tr')
  53 
  54     # return empty array if nothing is found
  55     if not search_res:
  56         return []
  57 
  58     # parse results
  59     for result in search_res[1:]:
  60         link = result.xpath('.//div[@class="detName"]//a')[0]
  61         href = urljoin(url, link.attrib.get('href'))
  62         title = extract_text(link)
  63         content = extract_text(result.xpath(content_xpath))
  64         seed, leech = result.xpath('.//td[@align="right"]/text()')[:2]
  65 
  66         # convert seed to int if possible
  67         if seed.isdigit():
  68             seed = int(seed)
  69         else:
  70             seed = 0
  71 
  72         # convert leech to int if possible
  73         if leech.isdigit():
  74             leech = int(leech)
  75         else:
  76             leech = 0
  77 
  78         magnetlink = result.xpath(magnet_xpath)[0]
  79         torrentfile_links = result.xpath(torrent_xpath)
  80         if torrentfile_links:
  81             torrentfile_link = torrentfile_links[0].attrib.get('href')
  82         else:
  83             torrentfile_link = None
  84 
  85         # append result
  86         results.append({'url': href,
  87                         'title': title,
  88                         'content': content,
  89                         'seed': seed,
  90                         'leech': leech,
  91                         'magnetlink': magnetlink.attrib.get('href'),
  92                         'torrentfile': torrentfile_link,
  93                         'template': 'torrent.html'})
  94 
  95     # return results sorted by seeder
  96     return sorted(results, key=itemgetter('seed'), reverse=True)
  97
  [end of searx/engines/piratebay.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/piratebay.py b/searx/engines/piratebay.py
  --- a/searx/engines/piratebay.py
  +++ b/searx/engines/piratebay.py
  @@ -18,7 +18,7 @@
   paging = True
   
   # search-url
  -url = 'https://thepiratebay.se/'
  +url = 'https://thepiratebay.org/'
   search_url = url + 'search/{search_term}/{pageno}/99/{search_type}'
   
   # piratebay specific type-definitions
  
verification_info: {"golden_diff": "diff --git a/searx/engines/piratebay.py b/searx/engines/piratebay.py\n--- a/searx/engines/piratebay.py\n+++ b/searx/engines/piratebay.py\n@@ -18,7 +18,7 @@\n paging = True\n \n # search-url\n-url = 'https://thepiratebay.se/'\n+url = 'https://thepiratebay.org/'\n search_url = url + 'search/{search_term}/{pageno}/99/{search_type}'\n \n # piratebay specific type-definitions\n", "issue": "Engines cannot retrieve results: piratebay (request exception): PirateBay changed URL\nWhen some text is entered, and I click on General and Files several times, it shows this error:\r\n```\r\nError! Engines cannot retrieve results.\r\npiratebay (request exception)\r\nPlease, try again later or find another searx instance.\r\n```\r\n\r\nVersion 0.14.0 on FreeBSD.\r\nDefault config.\n", "before_files": [{"content": "#  Piratebay (Videos, Music, Files)\n#\n# @website     https://thepiratebay.se\n# @provide-api no (nothing found)\n#\n# @using-api   no\n# @results     HTML (using search portal)\n# @stable      yes (HTML can change)\n# @parse       url, title, content, seed, leech, magnetlink\n\nfrom lxml import html\nfrom operator import itemgetter\nfrom searx.engines.xpath import extract_text\nfrom searx.url_utils import quote, urljoin\n\n# engine dependent config\ncategories = ['videos', 'music', 'files']\npaging = True\n\n# search-url\nurl = 'https://thepiratebay.se/'\nsearch_url = url + 'search/{search_term}/{pageno}/99/{search_type}'\n\n# piratebay specific type-definitions\nsearch_types = {'files': '0',\n                'music': '100',\n                'videos': '200'}\n\n# specific xpath variables\nmagnet_xpath = './/a[@title=\"Download this torrent using magnet\"]'\ntorrent_xpath = './/a[@title=\"Download this torrent\"]'\ncontent_xpath = './/font[@class=\"detDesc\"]'\n\n\n# do search-request\ndef request(query, params):\n    search_type = search_types.get(params['category'], '0')\n\n    params['url'] = search_url.format(search_term=quote(query),\n                                      search_type=search_type,\n                                      pageno=params['pageno'] - 1)\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    search_res = dom.xpath('//table[@id=\"searchResult\"]//tr')\n\n    # return empty array if nothing is found\n    if not search_res:\n        return []\n\n    # parse results\n    for result in search_res[1:]:\n        link = result.xpath('.//div[@class=\"detName\"]//a')[0]\n        href = urljoin(url, link.attrib.get('href'))\n        title = extract_text(link)\n        content = extract_text(result.xpath(content_xpath))\n        seed, leech = result.xpath('.//td[@align=\"right\"]/text()')[:2]\n\n        # convert seed to int if possible\n        if seed.isdigit():\n            seed = int(seed)\n        else:\n            seed = 0\n\n        # convert leech to int if possible\n        if leech.isdigit():\n            leech = int(leech)\n        else:\n            leech = 0\n\n        magnetlink = result.xpath(magnet_xpath)[0]\n        torrentfile_links = result.xpath(torrent_xpath)\n        if torrentfile_links:\n            torrentfile_link = torrentfile_links[0].attrib.get('href')\n        else:\n            torrentfile_link = None\n\n        # append result\n        results.append({'url': href,\n                        'title': title,\n                        'content': content,\n                        'seed': seed,\n                        'leech': leech,\n                        'magnetlink': magnetlink.attrib.get('href'),\n                        'torrentfile': torrentfile_link,\n                        'template': 'torrent.html'})\n\n    # return results sorted by seeder\n    return sorted(results, key=itemgetter('seed'), reverse=True)\n", "path": "searx/engines/piratebay.py"}]}