Skip to content
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

Open
nxjosephofficial opened this issue Mar 11, 2024 · 18 comments
Open

Can I disable qwant for images? #132

nxjosephofficial opened this issue Mar 11, 2024 · 18 comments
Labels
help wanted Extra attention is needed

Comments

@nxjosephofficial
Copy link

nxjosephofficial commented Mar 11, 2024

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

Warning: Undefined array key 0 in /usr/local/www/LibreY/engines/qwant/image.php on line 23

Warning: Trying to access array offset on null in /usr/local/www/LibreY/engines/qwant/image.php on line 23

Deprecated: htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated in /usr/local/www/LibreY/engines/qwant/image.php on line 23

Warning: Undefined array key 0 in /usr/local/www/LibreY/engines/qwant/image.php on line 24

Warning: Trying to access array offset on null in /usr/local/www/LibreY/engines/qwant/image.php on line 24

Deprecated: htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated in /usr/local/www/LibreY/engines/qwant/image.php on line 24

Warning: Undefined array key 0 in /usr/local/www/LibreY/engines/qwant/image.php on line 25

Warning: Trying to access array offset on null in /usr/local/www/LibreY/engines/qwant/image.php on line 25

Deprecated: htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated in /usr/local/www/LibreY/engines/qwant/image.php on line 25

Warning: Undefined array key 1 in /usr/local/www/LibreY/engines/qwant/image.php on line 23

Warning: Trying to access array offset on null in /usr/local/www/LibreY/engines/qwant/image.php on line 23

Deprecated: htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated in /usr/local/www/LibreY/engines/qwant/image.php on line 23

Warning: Undefined array key 1 in /usr/local/www/LibreY/engines/qwant/image.php on line 24

Warning: Trying to access array offset on null in /usr/local/www/LibreY/engines/qwant/image.php on line 24

Deprecated: htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated in /usr/local/www/LibreY/engines/qwant/image.php on line 24

Warning: Undefined array key 1 in /usr/local/www/LibreY/engines/qwant/image.php on line 25

Warning: Trying to access array offset on null in /usr/local/www/LibreY/engines/qwant/image.php on line 25

Deprecated: htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated in /usr/local/www/LibreY/engines/qwant/image.php on line 25

Warning: Undefined array key 2 in /usr/local/www/LibreY/engines/qwant/image.php on line 23

Warning: Trying to access array offset on null in /usr/local/www/LibreY/engines/qwant/image.php on line 23

Deprecated: htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated in /usr/local/www/LibreY/engines/qwant/image.php on line 23

Warning: Undefined array key 2 in /usr/local/www/LibreY/engines/qwant/image.php on line 24

Warning: Trying to access array offset on null in /usr/local/www/LibreY/engines/qwant/image.php on line 24

Deprecated: htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated in /usr/local/www/LibreY/engines/qwant/image.php on line 24

Warning: Undefined array key 2 in /usr/local/www/LibreY/engines/qwant/image.php on line 25

Warning: Trying to access array offset on null in /usr/local/www/LibreY/engines/qwant/image.php on line 25

Deprecated: htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated in /usr/local/www/LibreY/engines/qwant/image.php on line 25

Warning: Undefined array key 3 in /usr/local/www/LibreY/engines/qwant/image.php on line 23

Warning: Trying to access array offset on null in /usr/local/www/LibreY/engines/qwant/image.php on line 23

Deprecated: htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated in /usr/local/www/LibreY/engines/qwant/image.php on line 23

Warning: Undefined array key 3 in /usr/local/www/LibreY/engines/qwant/image.php on line 24

Warning: Trying to access array offset on null in /usr/local/www/LibreY/engines/qwant/image.php on line 24

Deprecated: htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated in /usr/local/www/LibreY/engines/qwant/image.php on line 24

Warning: Undefined array key 3 in /usr/local/www/LibreY/engines/qwant/image.php on line 25

Warning: Trying to access array offset on null in /usr/local/www/LibreY/engines/qwant/image.php on line 25

Deprecated: htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated in /usr/local/www/LibreY/engines/qwant/image.php on line 25

Warning: Undefined array key 4 in /usr/local/www/LibreY/engines/qwant/image.php on line 23

Warning: Trying to access array offset on null in /usr/local/www/LibreY/engines/qwant/image.php on line 23

Deprecated: htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated in /usr/local/www/LibreY/engines/qwant/image.php on line 23

Warning: Undefined array key 4 in /usr/local/www/LibreY/engines/qwant/image.php on line 24

Warning: Trying to access array offset on null in /usr/local/www/LibreY/engines/qwant/image.php on line 24

Deprecated: htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated in /usr/local/www/LibreY/engines/qwant/image.php on line 24

Warning: Undefined array key 4 in /usr/local/www/LibreY/engines/qwant/image.php on line 25

Warning: Trying to access array offset on null in /usr/local/www/LibreY/engines/qwant/image.php on line 25

Deprecated: htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated in /usr/local/www/LibreY/engines/qwant/image.php on line 25

Warning: Undefined array key 5 in /usr/local/www/LibreY/engines/qwant/image.php on line 23

Warning: Trying to access array offset on null in /usr/local/www/LibreY/engines/qwant/image.php on line 23

Deprecated: htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated in /usr/local/www/LibreY/engines/qwant/image.php on line 23

Warning: Undefined array key 5 in /usr/local/www/LibreY/engines/qwant/image.php on line 24

Warning: Trying to access array offset on null in /usr/local/www/LibreY/engines/qwant/image.php on line 24

Deprecated: htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated in /usr/local/www/LibreY/engines/qwant/image.php on line 24

Warning: Undefined array key 5 in /usr/local/www/LibreY/engines/qwant/image.php on line 25

Warning: Trying to access array offset on null in /usr/local/www/LibreY/engines/qwant/image.php on line 25

Deprecated: htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated in /usr/local/www/LibreY/engines/qwant/image.php on line 25

Warning: Undefined array key 6 in /usr/local/www/LibreY/engines/qwant/image.php on line 23

Warning: Trying to access array offset on null in /usr/local/www/LibreY/engines/qwant/image.php on line 23

Deprecated: htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated in /usr/local/www/LibreY/engines/qwant/image.php on line 23

Warning: Undefined array key 6 in /usr/local/www/LibreY/engines/qwant/image.php on line 24

Warning: Trying to access array offset on null in /usr/local/www/LibreY/engines/qwant/image.php on line 24

Deprecated: htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated in /usr/local/www/LibreY/engines/qwant/image.php on line 24

Warning: Undefined array key 6 in /usr/local/www/LibreY/engines/qwant/image.php on line 25

Warning: Trying to access array offset on null in /usr/local/www/LibreY/engines/qwant/image.php on line 25

Deprecated: htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated in /usr/local/www/LibreY/engines/qwant/image.php on line 25

Warning: Undefined array key 7 in /usr/local/www/LibreY/engines/qwant/image.php on line 23

Warning: Trying to access array offset on null in /usr/local/www/LibreY/engines/qwant/image.php on line 23

Deprecated: htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated in /usr/local/www/LibreY/engines/qwant/image.php on line 23

Warning: Undefined array key 7 in /usr/local/www/LibreY/engines/qwant/image.php on line 24

Warning: Trying to access array offset on null in /usr/local/www/LibreY/engines/qwant/image.php on line 24

Deprecated: htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated in /usr/local/www/LibreY/engines/qwant/image.php on line 24

Warning: Undefined array key 7 in /usr/local/www/LibreY/engines/qwant/image.php on line 25

Warning: Trying to access array offset on null in /usr/local/www/LibreY/engines/qwant/image.php on line 25

Deprecated: htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated in /usr/local/www/LibreY/engines/qwant/image.php on line 25

Warning: Undefined array key 8 in /usr/local/www/LibreY/engines/qwant/image.php on line 23

Warning: Trying to access array offset on null in /usr/local/www/LibreY/engines/qwant/image.php on line 23

Deprecated: htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated in /usr/local/www/LibreY/engines/qwant/image.php on line 23

Warning: Undefined array key 8 in /usr/local/www/LibreY/engines/qwant/image.php on line 24

Warning: Trying to access array offset on null in /usr/local/www/LibreY/engines/qwant/image.php on line 24

Deprecated: htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated in /usr/local/www/LibreY/engines/qwant/image.php on line 24

Warning: Undefined array key 8 in /usr/local/www/LibreY/engines/qwant/image.php on line 25

Warning: Trying to access array offset on null in /usr/local/www/LibreY/engines/qwant/image.php on line 25

Deprecated: htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated in /usr/local/www/LibreY/engines/qwant/image.php on line 25

Warning: Undefined array key 9 in /usr/local/www/LibreY/engines/qwant/image.php on line 23

Warning: Trying to access array offset on null in /usr/local/www/LibreY/engines/qwant/image.php on line 23

Deprecated: htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated in /usr/local/www/LibreY/engines/qwant/image.php on line 23

Warning: Undefined array key 9 in /usr/local/www/LibreY/engines/qwant/image.php on line 24

Warning: Trying to access array offset on null in /usr/local/www/LibreY/engines/qwant/image.php on line 24

Deprecated: htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated in /usr/local/www/LibreY/engines/qwant/image.php on line 24

Warning: Undefined array key 9 in /usr/local/www/LibreY/engines/qwant/image.php on line 25

Warning: Trying to access array offset on null in /usr/local/www/LibreY/engines/qwant/image.php on line 25

Deprecated: htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated in /usr/local/www/LibreY/engines/qwant/image.php on line 25


2024-03-11-163212_1366x768_scrot

@ghost
Copy link

ghost commented Mar 11, 2024

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.

@davidovski
Copy link

@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.

@ghost
Copy link

ghost commented Mar 11, 2024

I feel like im always here spitting out hypotheticals but havent got time to implement anything

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.

@codedipper
Copy link

codedipper commented Mar 12, 2024

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 git apply on the file.
In addition, LibreY also makes connections to sites such as Wikipedia which can put you at risk.

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";

@ghost
Copy link

ghost commented Mar 12, 2024

I may also suggest using a proxy or Tor for extra safety, because LibreY also makes connections to sites such as Wikipedia which can put you at risk.

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!

@codedipper
Copy link

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 config.php.
I can happily make a guide to setup a Tor proxy though!

@ghost
Copy link

ghost commented Mar 12, 2024

This is already possible through the CURLOPT(s) in the config.php.
I can happily make a guide to setup a Tor proxy though!

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

@davidovski
Copy link

Only downside with proxying libreY through tor is that most search engines will be locked behind captchas, leaving it unable to get search results.

@codedipper
Copy link

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.

@Ahwxorg
Copy link
Owner

Ahwxorg commented Mar 16, 2024

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.

@codedipper
Copy link

codedipper commented Mar 16, 2024

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.

@Ahwxorg
Copy link
Owner

Ahwxorg commented Mar 16, 2024

unless required

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.

@codedipper
Copy link

I created a quick guide for anyone that needs to use Tor to proxy LibreY for Docker compose.
https://github.com/codedipper/LibreY-Tor/wiki/Setup-LibreY-Tor-proxy-with-prebuilt-images-in-Docker-compose

@Ahwxorg
Copy link
Owner

Ahwxorg commented Apr 14, 2024

I created a quick guide for anyone that needs to use Tor to proxy LibreY for Docker compose. https://github.com/codedipper/LibreY-Tor/wiki/Setup-LibreY-Tor-proxy-with-prebuilt-images-in-Docker-compose

Can I put this in "official" docs?

@codedipper
Copy link

I created a quick guide for anyone that needs to use Tor to proxy LibreY for Docker compose. https://github.com/codedipper/LibreY-Tor/wiki/Setup-LibreY-Tor-proxy-with-prebuilt-images-in-Docker-compose

Can I put this in "official" docs?

Sure!

@Ahwxorg
Copy link
Owner

Ahwxorg commented Apr 14, 2024

Added!

@extremelyonline
Copy link

Another image engine would definitely be welcomed!

@Ahwxorg Ahwxorg added the help wanted Extra attention is needed label Oct 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

5 participants