-
-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can I disable qwant for images? #132
Comments
Wow! That's a lot of errors. There's definitely something to go ahead and change to , allow errors to be logged in a proper fashion to show that an error occured without having 3 warnings per image failed. When I'm home, I'll try and fix that aspect of the issue and then focus on your request, if someone else doesn't beat me to it. |
@dehlirious go for it. I feel like im always here spitting out hypotheticals but havent got time to implement anything these days but I think it would be good to try and move away from qwant for images and trying to scrape google/bing/etc for images. I've found that qwant doesnt really give very good results for certain queries. |
Should open a discussion for the "hypothesis/ to implement/to-do" ideas, since often they come up in random places like issues, having a consolidated location would be neat. |
For now I just made a quick patch to disable all connections to Qwant until we think of a permanent solution, which you can apply by pasting it into a text file and using diff --git a/api.php b/api.php
index 342186f..4e90adb 100644
--- a/api.php
+++ b/api.php
@@ -15,7 +15,7 @@
<br/>
<p>\"q\" is the keyword</p>
<p>\"p\" is the result page (the first page is 0)</p>
- <p>\"t\" is the search type (0=text, 1=image, 2=video, 3=torrent, 4=tor)</p>
+ <p>\"t\" is the search type (0=text, 2=video, 3=torrent, 4=tor)</p>
<br/>
<p>The results are going to be in JSON format.</p>
<p>The API supports both POST and GET requests.</p>";
diff --git a/engines/qwant/image.php b/engines/qwant/image.php
deleted file mode 100644
index 78c85b7..0000000
--- a/engines/qwant/image.php
+++ /dev/null
@@ -1,55 +0,0 @@
-<?php
- class QwantImageSearch extends EngineRequest {
- public function get_request_url() {
- $offset = $this->page * 5; // load 50 images per page
- $query = urlencode($this->query);
- return "https://api.qwant.com/v3/search/images?q=$query&t=images&count=50&locale=en_us&offset=$offset&device=desktop&tgp=3&safesearch=1";
- }
-
- public function parse_results($response) {
- $json = json_decode($response, true);
- $results = array();
-
- if ($json["status"] != "success")
- return $results; // no results
-
- $imgs = $json["data"]["result"]["items"];
- $imgCount = $json["data"]["result"]["total"];
-
- for ($i = 0; $i < $imgCount; $i++)
- {
- array_push($results,
- array (
- "thumbnail" => htmlspecialchars($imgs[$i]["thumbnail"]),
- "alt" => htmlspecialchars($imgs[$i]["title"]),
- "url" => htmlspecialchars($imgs[$i]["url"])
- )
- );
- }
-
- return $results;
- }
-
- public static function print_results($results, $opts) {
- echo "<div class=\"image-result-container\">";
-
- foreach($results as $result)
- {
- if (!$result
- || !array_key_exists("url", $result)
- || !array_key_exists("alt", $result))
- continue;
- $thumbnail = urlencode($result["thumbnail"]);
- $alt = $result["alt"];
- $url = $result["url"];
- $url = check_for_privacy_frontend($url, $opts);
-
- echo "<a title=\"$alt\" href=\"$url\" target=\"_blank\">";
- echo "<img src=\"image_proxy.php?url=$thumbnail\">";
- echo "</a>";
- }
-
- echo "</div>";
- }
- }
-?>
diff --git a/image_proxy.php b/image_proxy.php
index 87b45da..4aab4c0 100644
--- a/image_proxy.php
+++ b/image_proxy.php
@@ -6,7 +6,7 @@
$url = $_REQUEST["url"];
$requested_root_domain = get_root_domain($url);
- $allowed_domains = array("i.ytimg.com", "s2.qwant.com", "s1.qwant.com", "upload.wikimedia.org");
+ $allowed_domains = array("i.ytimg.com", "upload.wikimedia.org");
if (in_array($requested_root_domain, $allowed_domains))
{
diff --git a/misc/search_engine.php b/misc/search_engine.php
index 27d6fda..d9f7223 100644
--- a/misc/search_engine.php
+++ b/misc/search_engine.php
@@ -123,8 +123,8 @@
switch ($opts->type)
{
case 1:
- require_once "engines/qwant/image.php";
- return new QwantImageSearch($opts, $mh);
+ echo "<p class=\"text-result-container\">Image search is unavailable</p>";
+ break;
case 2:
require_once "engines/invidious/video.php";
|
The concept of integrating into LibreY / settings a way to for all connections to go through a proxy, adding to the setup a guide on how to setup a tor proxy, is a good idea! |
This is already possible through the CURLOPT(s) in the |
Sick! I didn't look, was basing it off memory and didn't remember that being a thing. And that would be wise I'd say, for most people. Tor regularly + tor using docker |
Only downside with proxying libreY through tor is that most search engines will be locked behind captchas, leaving it unable to get search results. |
This is actually not true for the most part! Spoofing the user agent seems to be enough to prevent captchas, but you could still be right since a lot of new engines were added since Google and DuckDuckGo. |
Huh, weird... I never had that work for me. I've always found issues whilst on Tor... Anyhow, it's probably best to not use Tor unless required (for LibreY-hosting purposes) due to overload of the network. |
Using Tor to bypass censorship, such as in this case, is kind of what it's meant to be used for. |
I meant that I shouldn't use Tor on LibreY since I am completely fine in my country. If you're not, I myself would not host LibreY, but if you do, them yes, please do use Tor. |
I created a quick guide for anyone that needs to use Tor to proxy LibreY for Docker compose. |
Can I put this in "official" docs? |
Sure! |
Added! |
Another image engine would definitely be welcomed! |
Hi. qwant does not work in my country and i cant view images on my self hosted librey instance. Can i disable qwant for images and use something else?
https://search.nxjoseph.com
The text was updated successfully, but these errors were encountered: