diff --git a/engines/text/google.php b/engines/text/google.php
@@ -70,6 +70,12 @@
);
}
+ if (empty($results) && !str_contains($response, "Our systems have detected unusual traffic from your computer network.")) {
+ $results["error"] = array(
+ "message" => "There are no results. Please try different keywords!"
+ );
+ }
+
return $results;
}
}
diff --git a/engines/text/text.php b/engines/text/text.php
@@ -36,23 +36,31 @@
$results = $this->engine_request->get_results();
- if ($this->special_request) {
- $special_result = $this->special_request->get_results();
+ if (empty(count($results))) {
+ set_cooldown($this->engine, ($opts->request_cooldown ?? "1") * 60, $this->opts->cooldowns);
+ } else {
+ if ($this->special_request) {
+ $special_result = $this->special_request->get_results();
- if ($special_result)
- $results = array_merge(array($special_result), $results);
+ if ($special_result)
+ $results = array_merge(array($special_result), $results);
+ }
}
- if (count($results) <= 1)
- set_cooldown($this->engine, ($opts->request_cooldown ?? "1") * 60, $this->opts->cooldowns);
-
return $results;
}
public static function print_results($results) {
- if (empty($results))
+ if (empty($results)) {
+ echo "<div class=\"text-result-container\"><p>An error occured fetching results</p></div>";
return;
+ }
+
+ if (array_key_exists("error", $results)) {
+ echo "<div class=\"text-result-container\"><p>" . $results["error"]["message"] . "</p></div>";
+ return;
+ }
$special = $results[0];
diff --git a/misc/search_engine.php b/misc/search_engine.php
@@ -152,8 +152,9 @@
} while ($running);
$results = $search_category->get_results();
+ error_log(print_r($results, true));
- if (count($results) <= 1) {
+ if (empty($results)) {
require "engines/librex/fallback.php";
$results = get_librex_results($opts);
}
| | |