From 513c73a309335fd7197d3cd4b246a9c7d2654a2a Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Sun, 11 Jul 2021 13:04:14 +0200 Subject: [PATCH] [drop] engine torrentz: torrentz2.eu and torrentz2.is are offline [1] https://torrentfreak.com/torrentz2-eu-domain-suspended-by-registry-on-public-prosecutors-order-200628/ Suggested-by: @rasos https://github.com/searx/searx/issues/1875#issuecomment-877755872 Signed-off-by: Markus Heiser --- searx/engines/torrentz.py | 99 --------------------------------------- searx/settings.yml | 8 +--- 2 files changed, 1 insertion(+), 106 deletions(-) delete mode 100644 searx/engines/torrentz.py diff --git a/searx/engines/torrentz.py b/searx/engines/torrentz.py deleted file mode 100644 index 884741d47..000000000 --- a/searx/engines/torrentz.py +++ /dev/null @@ -1,99 +0,0 @@ -# SPDX-License-Identifier: AGPL-3.0-or-later -""" - Torrentz2.is (BitTorrent meta-search engine) -""" - -import re -from urllib.parse import urlencode -from lxml import html -from datetime import datetime -from searx.utils import extract_text, get_torrent_size - -# about -about = { - "website": 'https://torrentz2.is/', - "wikidata_id": 'Q1156687', - "official_api_documentation": 'https://torrentz.is/torrentz.btsearch', - "use_official_api": False, - "require_api_key": False, - "results": 'HTML', -} - -# engine dependent config -categories = ['files'] -paging = True - -# search-url -# https://torrentz2.is/search?f=EXAMPLE&p=6 -base_url = 'https://torrentz2.is/' -search_url = base_url + 'search?{query}' - - -# do search-request -def request(query, params): - page = params['pageno'] - 1 - query = urlencode({'f': query, 'p': page}) - params['url'] = search_url.format(query=query) - return params - - -# get response from search-request -def response(resp): - results = [] - - dom = html.fromstring(resp.text) - - for result in dom.xpath('//div[@class="results"]/dl'): - name_cell = result.xpath('./dt')[0] - title = extract_text(name_cell) - - # skip rows that do not contain a link to a torrent - links = name_cell.xpath('./a') - if len(links) != 1: - continue - - # extract url and remove a slash in the beginning - link = links[0].attrib.get('href').lstrip('/') - - seed = 0 - leech = 0 - try: - seed = int(result.xpath('./dd/span[4]/text()')[0].replace(',', '')) - leech = int(result.xpath('./dd/span[5]/text()')[0].replace(',', '')) - except: - pass - - params = { - 'url': base_url + link, - 'title': title, - 'seed': seed, - 'leech': leech, - 'template': 'torrent.html' - } - - # let's try to calculate the torrent size - try: - filesize_info = result.xpath('./dd/span[3]/text()')[0] - filesize, filesize_multiplier = filesize_info.split() - filesize = get_torrent_size(filesize, filesize_multiplier) - - params['filesize'] = filesize - except: - pass - - # does our link contain a valid SHA1 sum? - if re.compile('[0-9a-fA-F]{40}').match(link): - # add a magnet link to the result - params['magnetlink'] = 'magnet:?xt=urn:btih:' + link - - # extract and convert creation date - try: - date_ts = result.xpath('./dd/span[2]')[0].attrib.get('title') - date = datetime.fromtimestamp(float(date_ts)) - params['publishedDate'] = date - except: - pass - - results.append(params) - - return results diff --git a/searx/settings.yml b/searx/settings.yml index aeeea01ea..8967abac4 100644 --- a/searx/settings.yml +++ b/searx/settings.yml @@ -1134,7 +1134,7 @@ engines: engine: solidtorrents shortcut: solid timeout: 3.0 - disabled: true + disabled: false # For this demo of the sqlite engine download: # https://liste.mediathekview.de/filmliste-v2.db.bz2 @@ -1156,12 +1156,6 @@ engines: # ORDER BY duration DESC # disabled: false - - name: torrentz - engine: torrentz - shortcut: tor - url: https://torrentz2.eu/ - timeout: 3.0 - # Requires Tor - name: torch engine: xpath