.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
searx.engines.bt4g Namespace Reference

Functions

 request (query, params)
 
 response (resp)
 

Variables

dict about
 
list categories = ['files']
 
bool paging = True
 
bool time_range_support = True
 
str url = 'https://bt4gprx.com'
 
str search_url = url + '/search?q={search_term}&orderby={order_by}&category={category}&p={pageno}&page=rss'
 
str bt4g_order_by = 'relevance'
 
str bt4g_category = 'all'
 

Detailed Description

BT4G_ (bt4g.com) is not a tracker and doesn't store any content and only
collects torrent metadata (such as file names and file sizes) and a magnet link
(torrent identifier).

This engine does not parse the HTML page because there is an API in XML (RSS).
The RSS feed provides fewer data like amount of seeders/leechers and the files
in the torrent file.  It's a tradeoff for a "stable" engine as the XML from RSS
content will change way less than the HTML page.

.. _BT4G: https://bt4g.com/

Configuration
=============

The engine has the following additional settings:

- :py:obj:`bt4g_order_by`
- :py:obj:`bt4g_category`

With this options a SearXNG maintainer is able to configure **additional**
engines for specific torrent searches.  For example a engine to search only for
Movies and sort the result list by the count of seeders.

.. code:: yaml

  - name: bt4g.movie
    engine: bt4g
    shortcut: bt4gv
    categories: video
    bt4g_order_by: seeders
    bt4g_category: 'movie'

Implementations
===============

Function Documentation

◆ request()

searx.engines.bt4g.request ( query,
params )

Definition at line 75 of file bt4g.py.

75def request(query, params):
76
77 order_by = bt4g_order_by
78 if params['time_range']:
79 order_by = 'time'
80
81 params['url'] = search_url.format(
82 search_term=quote(query),
83 order_by=order_by,
84 category=bt4g_category,
85 pageno=params['pageno'],
86 )
87 return params
88
89

◆ response()

searx.engines.bt4g.response ( resp)

Definition at line 90 of file bt4g.py.

90def response(resp):
91 results = []
92
93 search_results = etree.XML(resp.content)
94
95 # return empty array if nothing is found
96 if len(search_results) == 0:
97 return []
98
99 for entry in search_results.xpath('./channel/item'):
100 title = entry.find("title").text
101 link = entry.find("guid").text
102 fullDescription = entry.find("description").text.split('<br>')
103 magnetlink = entry.find("link").text
104 pubDate = entry.find("pubDate").text
105 results.append(
106 {
107 'url': link,
108 'title': title,
109 'magnetlink': magnetlink,
110 'seed': 'N/A',
111 'leech': 'N/A',
112 'filesize': fullDescription[1],
113 'publishedDate': datetime.strptime(pubDate, '%a,%d %b %Y %H:%M:%S %z'),
114 'template': 'torrent.html',
115 }
116 )
117
118 return results

Variable Documentation

◆ about

dict searx.engines.bt4g.about
Initial value:
1= {
2 "website": 'https://bt4gprx.com',
3 "use_official_api": False,
4 "require_api_key": False,
5 "results": 'XML',
6}

Definition at line 45 of file bt4g.py.

◆ bt4g_category

str searx.engines.bt4g.bt4g_category = 'all'

Definition at line 69 of file bt4g.py.

◆ bt4g_order_by

str searx.engines.bt4g.bt4g_order_by = 'relevance'

Definition at line 60 of file bt4g.py.

◆ categories

list searx.engines.bt4g.categories = ['files']

Definition at line 53 of file bt4g.py.

◆ paging

bool searx.engines.bt4g.paging = True

Definition at line 54 of file bt4g.py.

◆ search_url

str searx.engines.bt4g.search_url = url + '/search?q={search_term}&orderby={order_by}&category={category}&p={pageno}&page=rss'

Definition at line 59 of file bt4g.py.

◆ time_range_support

bool searx.engines.bt4g.time_range_support = True

Definition at line 55 of file bt4g.py.

◆ url

str searx.engines.bt4g.url = 'https://bt4gprx.com'

Definition at line 58 of file bt4g.py.