From 0abdf068d1f620b7efe2d89cd68779e638ba7e29 Mon Sep 17 00:00:00 2001
From: hnhx
Date: Fri, 25 Feb 2022 10:42:32 +0100
Subject: [PATCH] reorganized the whole code base , added disable torrent
search to config
---
README.md | 8 +-
api.php | 36 +++++-
config.php | 5 +-
donate.php | 13 +++
donate.xhtml | 29 -----
.../thepiratebay.php} | 34 ++++--
engines/google.php | 45 --------
{results => engines}/google/image.php | 24 +++-
{results => engines}/google/text.php | 33 +++++-
{results => engines}/google/video.php | 29 ++++-
engines/special.php | 23 ----
{results => engines}/special/currency.php | 8 +-
{results => engines}/special/definition.php | 6 +-
{results => engines}/special/wikipedia.php | 12 +-
index.php | 17 +++
index.xhtml | 33 ------
misc/tools.php | 97 +++-------------
search.php | 109 ++++++++++--------
static/footer.html | 8 ++
static/header.html | 11 ++
static/{ => images}/image_result.png | Bin
static/{ => images}/librex.png | Bin
static/{ => images}/text_result.png | Bin
static/{ => images}/torrent_result.png | Bin
static/{ => images}/video_result.png | Bin
static/{ => images}/xmr.png | Bin
26 files changed, 286 insertions(+), 294 deletions(-)
create mode 100644 donate.php
delete mode 100644 donate.xhtml
rename engines/{bittorrent.php => bittorrent/thepiratebay.php} (50%)
delete mode 100644 engines/google.php
rename {results => engines}/google/image.php (59%)
rename {results => engines}/google/text.php (59%)
rename {results => engines}/google/video.php (56%)
delete mode 100644 engines/special.php
rename {results => engines}/special/currency.php (84%)
rename {results => engines}/special/definition.php (79%)
rename {results => engines}/special/wikipedia.php (71%)
create mode 100644 index.php
delete mode 100644 index.xhtml
create mode 100644 static/footer.html
create mode 100644 static/header.html
rename static/{ => images}/image_result.png (100%)
rename static/{ => images}/librex.png (100%)
rename static/{ => images}/text_result.png (100%)
rename static/{ => images}/torrent_result.png (100%)
rename static/{ => images}/video_result.png (100%)
rename static/{ => images}/xmr.png (100%)
diff --git a/README.md b/README.md
index c7dcb67..34cef15 100644
--- a/README.md
+++ b/README.md
@@ -38,7 +38,7 @@ All you need is a webserver (e.g.: nginx) and PHP, and you are good to go.
# API
Example API request: `.../api.php?q=gentoo&p=2&type=0`
-Where `q` is the keyword, `p` is the result page (the first page is `0`) and `type` is the search type (`0`=text, `1`=image, `2`=video)
+Where `q` is the keyword, `p` is the result page (the first page is `0`) and `type` is the search type (`0`=text, `1`=image, `2`=video, `3`=torrent)
JSON result:
+ In case of text search:
@@ -52,6 +52,12 @@ JSON result:
+ `title`: Title of the result video
+ `url`: Full URL of the video
+ `base_url`: The base URL of the result (e.g.: http://youtube.com/watch -> http://youtube.com/)
++ In case of torrent search:
+ + `hash`: Hash of the torrent
+ + `name`: Name of the torrent
+ + `seeders`: The amount of seeders
+ + `leechers`: The amount of leechers
+ + `magnet`: The magnet link
The API also supports both GET and POST requests
diff --git a/api.php b/api.php
index c6378a2..908b4b9 100644
--- a/api.php
+++ b/api.php
@@ -1,6 +1,5 @@
"disabled");
+ else
+ {
+ require "engines/bittorrent/thepiratebay.php";
+ $results = get_thepiratebay_results($query_encoded);
+ }
+ break;
+ default:
+ require "engines/google/text.php";
+ $results = get_text_results($query_encoded, $page);
+ break;
+ }
header('Content-Type: application/json');
echo json_encode($results, JSON_PRETTY_PRINT);
diff --git a/config.php b/config.php
index 89bad39..2023258 100755
--- a/config.php
+++ b/config.php
@@ -8,9 +8,8 @@
// Results will be in this language
$config_google_language = "en";
- // Maxmium size of the cache
- $config_cache_size = 1024 * 1024 * 1024;
-
+ // Disable BitTorrent search
+ $config_disable_bittorent_search = false;
/*
youtube.com results will be replaced with the given invidious instance
diff --git a/donate.php b/donate.php
new file mode 100644
index 0000000..33c1642
--- /dev/null
+++ b/donate.php
@@ -0,0 +1,13 @@
+
+
+
+
+
";
}
?>
-
-
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/static/footer.html b/static/footer.html
new file mode 100644
index 0000000..5751d60
--- /dev/null
+++ b/static/footer.html
@@ -0,0 +1,8 @@
+
+