.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 78 of file bt4g.py.

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

◆ response()

searx.engines.bt4g.response ( resp)

Definition at line 93 of file bt4g.py.

93def response(resp):
94 results = []
95
96 search_results = etree.XML(resp.content)
97
98 # return empty array if nothing is found
99 if len(search_results) == 0:
100 return []
101
102 for entry in search_results.xpath('./channel/item'):
103 title = entry.find("title").text
104 link = entry.find("guid").text
105 fullDescription = entry.find("description").text.split('<br>')
106 filesize = fullDescription[1]
107 filesizeParsed = re.split(r"([A-Z]+)", filesize)
108 magnetlink = entry.find("link").text
109 pubDate = entry.find("pubDate").text
110 results.append(
111 {
112 'url': link,
113 'title': title,
114 'magnetlink': magnetlink,
115 'seed': 'N/A',
116 'leech': 'N/A',
117 'filesize': get_torrent_size(filesizeParsed[0], filesizeParsed[1]),
118 'publishedDate': datetime.strptime(pubDate, '%a,%d %b %Y %H:%M:%S %z'),
119 'template': 'torrent.html',
120 }
121 )
122
123 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 48 of file bt4g.py.

◆ bt4g_category

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

Definition at line 72 of file bt4g.py.

◆ bt4g_order_by

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

Definition at line 63 of file bt4g.py.

◆ categories

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

Definition at line 56 of file bt4g.py.

◆ paging

bool searx.engines.bt4g.paging = True

Definition at line 57 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 62 of file bt4g.py.

◆ time_range_support

bool searx.engines.bt4g.time_range_support = True

Definition at line 58 of file bt4g.py.

◆ url

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

Definition at line 61 of file bt4g.py.