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

Functions

 request (query, params)
 
 response (resp)
 

Variables

dict about
 
list categories = ["files"]
 
str url = "https://thepiratebay.org/"
 
str search_url = "https://apibay.org/q.php?q={search_term}&cat={search_type}"
 
list trackers
 
dict search_types = {"files": "0", "music": "100", "videos": "200"}
 

Detailed Description

 Piratebay (Videos, Music, Files)

Function Documentation

◆ request()

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

Definition at line 47 of file piratebay.py.

47def request(query, params):
48 search_type = search_types.get(params["category"], "0")
49
50 params["url"] = search_url.format(search_term=quote(query), search_type=search_type)
51
52 return params
53
54
55# get response from search-request

◆ response()

searx.engines.piratebay.response ( resp)

Definition at line 56 of file piratebay.py.

56def response(resp):
57 results = []
58
59 search_res = loads(resp.text)
60
61 # return empty array if nothing is found
62 if search_res[0]["name"] == "No results returned":
63 return []
64
65 # parse results
66 for result in search_res:
67 link = url + "description.php?id=" + result["id"]
68 magnetlink = (
69 "magnet:?xt=urn:btih:" + result["info_hash"] + "&dn=" + result["name"] + "&tr=" + "&tr=".join(trackers)
70 )
71
72 params = {
73 "url": link,
74 "title": result["name"],
75 "seed": result["seeders"],
76 "leech": result["leechers"],
77 "magnetlink": magnetlink,
78 "template": "torrent.html",
79 }
80
81 # extract and convert creation date
82 try:
83 params['publishedDate'] = datetime.fromtimestamp(float(result["added"]))
84 except: # pylint: disable=bare-except
85 pass
86
87 # let's try to calculate the torrent size
88 params['filesize'] = humanize_bytes(int(result["size"]))
89
90 # append result
91 results.append(params)
92
93 # return results sorted by seeder
94 return sorted(results, key=itemgetter("seed"), reverse=True)

Variable Documentation

◆ about

dict searx.engines.piratebay.about
Initial value:
1= {
2 "website": 'https://thepiratebay.org',
3 "wikidata_id": 'Q22663',
4 "official_api_documentation": 'https://apibay.org/',
5 "use_official_api": True,
6 "require_api_key": False,
7 "results": 'JSON',
8}

Definition at line 14 of file piratebay.py.

◆ categories

list searx.engines.piratebay.categories = ["files"]

Definition at line 24 of file piratebay.py.

◆ search_types

dict searx.engines.piratebay.search_types = {"files": "0", "music": "100", "videos": "200"}

Definition at line 43 of file piratebay.py.

◆ search_url

str searx.engines.piratebay.search_url = "https://apibay.org/q.php?q={search_term}&cat={search_type}"

Definition at line 28 of file piratebay.py.

◆ trackers

list searx.engines.piratebay.trackers
Initial value:
1= [
2 "udp://tracker.coppersurfer.tk:6969/announce",
3 "udp://9.rarbg.to:2920/announce",
4 "udp://tracker.opentrackr.org:1337",
5 "udp://tracker.internetwarriors.net:1337/announce",
6 "udp://tracker.leechers-paradise.org:6969/announce",
7 "udp://tracker.coppersurfer.tk:6969/announce",
8 "udp://tracker.pirateparty.gr:6969/announce",
9 "udp://tracker.cyberia.is:6969/announce",
10]

Definition at line 31 of file piratebay.py.

◆ url

str searx.engines.piratebay.url = "https://thepiratebay.org/"

Definition at line 27 of file piratebay.py.