Repository: searxng/searxng

Issue:
Bug: yggtorrent engine ( Suspended: access denied )
**Version of SearXNG, commit number if you are using on master branch and stipulate if you forked SearXNG**
Repository: https://github.com/tiekoetter/searxng
Branch: master
Version: 1.0.0-1246-10968a7f





Discussion:
It is probably just my instance getting blocked. I will take a look and report back if it isn't a problem of my instance. For the time being you can try another public instance.
A can confirm this issue: in a `make run` instance a `!yggtorrent ..` is blocked.
Qny instance will do the de
Same

Sent from ProtonMail for iOS

On Sat, Dec 4, 2021 at 03:59, Markus Heiser ***@***.***> wrote:

> A can confirm this issue: in a make run instance a !yggtorrent .. is blocked.
>
> —
> You are receiving this because you authored the thread.
> Reply to this email directly, [view it on GitHub](https://github.com/searxng/searxng/issues/580#issuecomment-985994369), or [unsubscribe](https://github.com/notifications/unsubscribe-auth/AIQDZ54G7VHHWS7IICS35ZLUPHJ6TANCNFSM5JKZNWNQ).
> Triage notifications on the go with GitHub Mobile for [iOS](https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675) or [Android](https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub).
I can now also confirm that this happens with a fresh install.
I had a short look: There is a cloudflare wall in front of https://www3.yggtorrent.nz doing some redirects to set cookies .. I don't know how to get around.

When I disable cookies in my browser the page stops at:

![image](https://user-images.githubusercontent.com/554536/144704511-38c3a62e-ce28-4230-8bb9-6d12027b7cbc.png)

The DNS configuration of ygg has changed 3 days ago, all public instances are blocked.
I guess we can remove the engine.

Resolving patch:
diff --git a/searx/engines/yggtorrent.py b/searx/engines/yggtorrent.py
deleted file mode 100644
--- a/searx/engines/yggtorrent.py
+++ /dev/null
@@ -1,127 +0,0 @@
-# SPDX-License-Identifier: AGPL-3.0-or-later
-"""
- Yggtorrent (Videos, Music, Files)
-"""
-
-from lxml import html
-from operator import itemgetter
-from datetime import datetime
-from urllib.parse import quote
-from searx.utils import extract_text, get_torrent_size
-from searx.network import get as http_get
-
-# about
-about = {
-    "website": 'https://www4.yggtorrent.li/',
-    "wikidata_id": None,
-    "official_api_documentation": None,
-    "use_official_api": False,
-    "require_api_key": False,
-    "results": 'HTML',
-}
-
-# engine dependent config
-categories = ['files']
-paging = True
-
-# search-url
-url = 'https://www4.yggtorrent.li/'
-search_url = url + 'engine/search?name={search_term}&do=search&page={pageno}&category={search_type}'
-
-# yggtorrent specific type-definitions
-search_types = {'files': 'all',
-                'music': '2139',
-                'videos': '2145'}
-
-cookies = dict()
-
-
-def init(engine_settings=None):
-    # initial cookies
-    resp = http_get(url, allow_redirects=False)
-    if resp.ok:
-        for r in resp.history:
-            cookies.update(r.cookies)
-        cookies.update(resp.cookies)
-
-
-# do search-request
-def request(query, params):
-    search_type = search_types.get(params['category'], 'all')
-    pageno = (params['pageno'] - 1) * 50
-
-    params['url'] = search_url.format(search_term=quote(query),
-                                      search_type=search_type,
-                                      pageno=pageno)
-
-    params['cookies'] = cookies
-
-    return params
-
-
-# get response from search-request
-def response(resp):
-    results = []
-    dom = html.fromstring(resp.text)
-
-    search_res = dom.xpath('//section[@id="#torrents"]/div/table/tbody/tr')
-
-    # return empty array if nothing is found
-    if not search_res:
-        return []
-
-    # parse results
-    for result in search_res:
-        link = result.xpath('.//a[@id="torrent_name"]')[0]
-        href = link.attrib.get('href')
-        title = extract_text(link)
-        seed = result.xpath('.//td[8]/text()')[0]
-        leech = result.xpath('.//td[9]/text()')[0]
-
-        # convert seed to int if possible
-        if seed.isdigit():
-            seed = int(seed)
-        else:
-            seed = 0
-
-        # convert leech to int if possible
-        if leech.isdigit():
-            leech = int(leech)
-        else:
-            leech = 0
-
-        params = {'url': href,
-                  'title': title,
-                  'seed': seed,
-                  'leech': leech,
-                  'template': 'torrent.html'}
-
-        # let's try to calculate the torrent size
-        try:
-            filesize_info = result.xpath('.//td[6]/text()')[0]
-            filesize = filesize_info[:-2]
-            filesize_multiplier = filesize_info[-2:].lower()
-            multiplier_french_to_english = {
-                'to': 'TiB',
-                'go': 'GiB',
-                'mo': 'MiB',
-                'ko': 'KiB'
-            }
-            filesize = get_torrent_size(filesize, multiplier_french_to_english[filesize_multiplier])
-            params['filesize'] = filesize
-        except:
-            pass
-
-        # extract and convert creation date
-        try:
-            date_ts = result.xpath('.//td[5]/div/text()')[0]
-            date = datetime.fromtimestamp(float(date_ts))
-            params['publishedDate'] = date
-        except:
-            pass
-
-        # append result
-        results.append(params)
-
-    # return results sorted by seeder
-    return sorted(results, key=itemgetter('seed'), reverse=True)


Test patch: