prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Piratebay engine : update the URL
  The current URL is https://thepiratebay.se which doesn't respond.
  This one seems to work https://thepiratebay.mn  (see https://en.wikipedia.org/wiki/The_Pirate_Bay )
  
  Another solution : disable / remove the engine in settings.yml
  
  
  --- 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/piratebay.py`
  Content:
  ```
  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 urlparse import urljoin
  12 from cgi import escape
  13 from urllib import quote
  14 from lxml import html
  15 from operator import itemgetter
  16 from searx.engines.xpath import extract_text
  17 
  18 # engine dependent config
  19 categories = ['videos', 'music', 'files']
  20 paging = True
  21 
  22 # search-url
  23 url = 'https://thepiratebay.se/'
  24 search_url = url + 'search/{search_term}/{pageno}/99/{search_type}'
  25 
  26 # piratebay specific type-definitions
  27 search_types = {'files': '0',
  28                 'music': '100',
  29                 'videos': '200'}
  30 
  31 # specific xpath variables
  32 magnet_xpath = './/a[@title="Download this torrent using magnet"]'
  33 torrent_xpath = './/a[@title="Download this torrent"]'
  34 content_xpath = './/font[@class="detDesc"]'
  35 
  36 
  37 # do search-request
  38 def request(query, params):
  39     search_type = search_types.get(params['category'], '0')
  40 
  41     params['url'] = search_url.format(search_term=quote(query),
  42                                       search_type=search_type,
  43                                       pageno=params['pageno'] - 1)
  44 
  45     # FIX: SSLError: hostname 'kthepiratebay.se'
  46     # doesn't match either of 'ssl2000.cloudflare.com', 'cloudflare.com', '*.cloudflare.com'
  47     params['verify'] = False
  48 
  49     return params
  50 
  51 
  52 # get response from search-request
  53 def response(resp):
  54     results = []
  55 
  56     dom = html.fromstring(resp.text)
  57 
  58     search_res = dom.xpath('//table[@id="searchResult"]//tr')
  59 
  60     # return empty array if nothing is found
  61     if not search_res:
  62         return []
  63 
  64     # parse results
  65     for result in search_res[1:]:
  66         link = result.xpath('.//div[@class="detName"]//a')[0]
  67         href = urljoin(url, link.attrib.get('href'))
  68         title = extract_text(link)
  69         content = escape(extract_text(result.xpath(content_xpath)))
  70         seed, leech = result.xpath('.//td[@align="right"]/text()')[:2]
  71 
  72         # convert seed to int if possible
  73         if seed.isdigit():
  74             seed = int(seed)
  75         else:
  76             seed = 0
  77 
  78         # convert leech to int if possible
  79         if leech.isdigit():
  80             leech = int(leech)
  81         else:
  82             leech = 0
  83 
  84         magnetlink = result.xpath(magnet_xpath)[0]
  85         torrentfile_links = result.xpath(torrent_xpath)
  86         if torrentfile_links:
  87             torrentfile_link = torrentfile_links[0].attrib.get('href')
  88         else:
  89             torrentfile_link = None
  90 
  91         # append result
  92         results.append({'url': href,
  93                         'title': title,
  94                         'content': content,
  95                         'seed': seed,
  96                         'leech': leech,
  97                         'magnetlink': magnetlink.attrib.get('href'),
  98                         'torrentfile': torrentfile_link,
  99                         'template': 'torrent.html'})
  100 
  101     # return results sorted by seeder
  102     return sorted(results, key=itemgetter('seed'), reverse=True)
  103
  ```
  --- 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/piratebay.py b/searx/engines/piratebay.py
  --- a/searx/engines/piratebay.py
  +++ b/searx/engines/piratebay.py
  @@ -20,7 +20,7 @@
   paging = True
   
   # search-url
  -url = 'https://thepiratebay.se/'
  +url = 'https://thepiratebay.am/'
   search_url = url + 'search/{search_term}/{pageno}/99/{search_type}'
   
   # piratebay specific type-definitions
  @@ -42,10 +42,6 @@
                                         search_type=search_type,
                                         pageno=params['pageno'] - 1)
   
  -    # FIX: SSLError: hostname 'kthepiratebay.se'
  -    # doesn't match either of 'ssl2000.cloudflare.com', 'cloudflare.com', '*.cloudflare.com'
  -    params['verify'] = False
  -
       return params
  
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@@ -20,7 +20,7 @@\n paging = True\n \n # search-url\n-url = 'https://thepiratebay.se/'\n+url = 'https://thepiratebay.am/'\n search_url = url + 'search/{search_term}/{pageno}/99/{search_type}'\n \n # piratebay specific type-definitions\n@@ -42,10 +42,6 @@\n                                       search_type=search_type,\n                                       pageno=params['pageno'] - 1)\n \n-    # FIX: SSLError: hostname 'kthepiratebay.se'\n-    # doesn't match either of 'ssl2000.cloudflare.com', 'cloudflare.com', '*.cloudflare.com'\n-    params['verify'] = False\n-\n     return params\n", "issue": "Piratebay engine : update the URL\nThe current URL is https://thepiratebay.se which doesn't respond.\nThis one seems to work https://thepiratebay.mn  (see https://en.wikipedia.org/wiki/The_Pirate_Bay )\n\nAnother solution : disable / remove the engine in settings.yml\n\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 urlparse import urljoin\nfrom cgi import escape\nfrom urllib import quote\nfrom lxml import html\nfrom operator import itemgetter\nfrom searx.engines.xpath import extract_text\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    # FIX: SSLError: hostname 'kthepiratebay.se'\n    # doesn't match either of 'ssl2000.cloudflare.com', 'cloudflare.com', '*.cloudflare.com'\n    params['verify'] = False\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 = escape(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"}], "after_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 urlparse import urljoin\nfrom cgi import escape\nfrom urllib import quote\nfrom lxml import html\nfrom operator import itemgetter\nfrom searx.engines.xpath import extract_text\n\n# engine dependent config\ncategories = ['videos', 'music', 'files']\npaging = True\n\n# search-url\nurl = 'https://thepiratebay.am/'\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 = escape(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"}]}