added bibliogram and nitter front ends , fixed the api for text results
This commit is contained in:
parent
cfe31bed5b
commit
20e049c78c
6 changed files with 35 additions and 14 deletions
|
@ -30,7 +30,7 @@ Your request will be **rejected** if your instance:
|
|||
+ Tracking snippets from URLs are removed
|
||||
+ Image results are converted to base64 to prevent clients from connecting to Google servers
|
||||
+ Supports both POST and GET requests
|
||||
+ YouTube results are converted into a privacy friendly Invidious instance
|
||||
+ Popular social media sites (YouTube, Instagram, Twitter) are replaced with privacy friendly front-ends
|
||||
+ Easy to use JSON API for developers
|
||||
+ No 3rd party libs are used
|
||||
+ Easy to setup
|
||||
|
|
2
api.php
2
api.php
|
@ -17,7 +17,7 @@
|
|||
{
|
||||
case 0:
|
||||
require "engines/google/text.php";
|
||||
$results = get_text_results($query_encoded, $page);
|
||||
$results = get_text_results($query_encoded, $page, true);
|
||||
break;
|
||||
case 1:
|
||||
require "engines/google/image.php";
|
||||
|
|
16
config.php
16
config.php
|
@ -10,16 +10,20 @@
|
|||
|
||||
// Disable BitTorrent search
|
||||
$config_disable_bittorent_search = false;
|
||||
|
||||
$config_bittorent_trackers = "&tr=http%3A%2F%2Fnyaa.tracker.wf%3A7777%2Fannounce&tr=udp%3A%2F%2Fopen.stealth.si%3A80%2Fannounce&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337%2Fannounce&tr=udp%3A%2F%2Fexodus.desync.com%3A6969%2Fannounce&tr=udp%3A%2F%2Ftracker.torrent.eu.org%3A451%2Fannounce";
|
||||
|
||||
/*
|
||||
youtube.com results will be replaced with the given invidious instance
|
||||
Get online invidious instances from here: https://docs.invidious.io/Invidious-Instances.md
|
||||
These are privacy friendly front-ends for popular sites
|
||||
|
||||
Set as null if you don't want to replace YouTube results
|
||||
Online invidious instances: https://docs.invidious.io/Invidious-Instances.md
|
||||
Online bibliogram instances: https://git.sr.ht/~cadence/bibliogram-docs/tree/master/docs/Instances.md
|
||||
Online nitter instances: https://github.com/zedeus/nitter/wiki/Instances
|
||||
|
||||
Set as null or 0 if you don't want to replace results
|
||||
*/
|
||||
$config_replace_yt_with_invidious = "yewtu.be";
|
||||
$config_replace_youtube_with_invidious = "https://yewtu.be";
|
||||
$config_replace_instagram_with_bibliogram = "https://bibliogram.pussthecat.org";
|
||||
$config_replace_twitter_with_nitter = "https://nitter.namazso.eu";
|
||||
|
||||
/*
|
||||
To send requests trough a proxy uncomment CURLOPT_PROXY and CURLOPT_PROXYTYPE:
|
||||
|
@ -46,7 +50,7 @@
|
|||
CURLOPT_FOLLOWLOCATION => false,
|
||||
CURLOPT_ENCODING => "",
|
||||
CURLOPT_USERAGENT => $config_user_agent,
|
||||
CURLOPT_SSL_VERIFYHOST => 0,
|
||||
CURLOPT_SSL_VERIFYHOST => false,
|
||||
CURLOPT_VERBOSE => 1
|
||||
);
|
||||
?>
|
|
@ -18,7 +18,7 @@
|
|||
return 0;
|
||||
}
|
||||
|
||||
function get_text_results($query, $page=0)
|
||||
function get_text_results($query, $page=0, $api=false)
|
||||
{
|
||||
require "config.php";
|
||||
require "misc/tools.php";
|
||||
|
@ -37,7 +37,7 @@
|
|||
$special_search = $page == 0 ? check_for_special_search($query) : 0;
|
||||
$special_ch = null;
|
||||
$url = null;
|
||||
if ($special_search != 0)
|
||||
if ($special_search != 0 && $api == false)
|
||||
{
|
||||
switch ($special_search)
|
||||
{
|
||||
|
@ -97,8 +97,7 @@
|
|||
continue;
|
||||
|
||||
$url = $url->textContent;
|
||||
if ($config_replace_yt_with_invidious != null && strpos($url, "youtube.com"))
|
||||
$url = "https://" . $config_replace_yt_with_invidious . explode("youtube.com", $url)[1];
|
||||
$url = check_for_privacy_friendly_alternative($url);
|
||||
|
||||
$title = $xpath->evaluate(".//h3", $result)[0];
|
||||
$description = $xpath->evaluate(".//div[contains(@class, 'VwiC3b')]", $result)[0];
|
||||
|
|
|
@ -22,8 +22,7 @@
|
|||
continue;
|
||||
|
||||
$url = $url->textContent;
|
||||
if ($config_replace_yt_with_invidious != null && strpos($url, "youtube.com"))
|
||||
$url = "https://" . $config_replace_yt_with_invidious . explode("youtube.com", $url)[1];
|
||||
$url = check_for_privacy_friendly_alternative($url);
|
||||
|
||||
$title = $xpath->evaluate(".//h3", $result)[0];
|
||||
|
||||
|
|
|
@ -6,6 +6,25 @@
|
|||
return $base_url;
|
||||
}
|
||||
|
||||
function check_for_privacy_friendly_alternative($url)
|
||||
{
|
||||
require "config.php";
|
||||
|
||||
if ($config_replace_youtube_with_invidious != null && strpos($url, "youtube.com"))
|
||||
$url = $config_replace_youtube_with_invidious . explode("youtube.com", $url)[1];
|
||||
else if ($config_replace_instagram_with_bibliogram != null && strpos($url, "instagram.com"))
|
||||
{
|
||||
if (!strpos($url, "/p/"))
|
||||
$config_replace_instagram_with_bibliogram .= "/u";
|
||||
|
||||
$url = $config_replace_instagram_with_bibliogram . explode("instagram.com", $url)[1];
|
||||
}
|
||||
else if ($config_replace_twitter_with_nitter != null && strpos($url, "twitter.com"))
|
||||
$url = $config_replace_twitter_with_nitter . explode("twitter.com", $url)[1];
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
function get_xpath($response)
|
||||
{
|
||||
$htmlDom = new DOMDocument;
|
||||
|
|
Loading…
Reference in a new issue