Skip to content

Commit 8edd1f9

Browse files
committed
replaced brave video search with invidious, fixed the broken json, fixed the broken main tor instance
1 parent c050a09 commit 8edd1f9

File tree

13 files changed

+103
-86
lines changed

13 files changed

+103
-86
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
| Clearnet | TOR | I2P | Country |
1515
|-|-|-|-|
16-
| [search.femboy.hu](https://search.femboy.hu/) | [](http://search.femboy2vec5mc3rdvecifqrwzpiaeoyfh4zodppxq4pc2tdvzhm4moqd.onion/) || 🇭🇺 HU (OFFICIAL INSTANCE) |
16+
| [search.femboy.hu](https://search.femboy.hu/) | [](http://search.cepyxplublbyw2f4axy4pyztfbxmf63lrt2c7uwv6wl4iixz53czload.onion/) || 🇭🇺 HU (OFFICIAL INSTANCE) |
1717
| [lx.vern.cc](https://lx.vern.cc/) | [](http://lx.vernccvbvyi5qhfzyqengccj7lkove6bjot2xhh5kajhwvidqafczrad.onion/) | [](http://vernziqfqvweijfaacmwazohgpdo2bt2ib2jlupt2pwwu27bhgxq.b32.i2p/) | 🇺🇸 US |
1818
| [lx.sesu.cc](https://lx.sesu.cc/) | [](http://lx.swxoebbpeqiiixyhbuh3vbw53pdrmtbiaj2sqveol6kkn5rpapfi4aad.onion/) | [](http://lqbchqljxiwl3bbjt4vqe76luovk5ly6khqhg7mt5qcqfn6e4sbq.b32.i2p/) | 🇨🇱 CL |
1919
| [librex.mikata.ru](https://librex.mikata.ru/) | [](http://f7ssz7l3biu4fugwctfpcx4txg5yq4gqhrt473ledsuc3ivtd3omniid.onion/) || 🇺🇸 US |
@@ -43,7 +43,7 @@ Huge thanks to Richard Stallman for using LibreX and featuring it on his [websit
4343

4444
### About LibreX
4545

46-
LibreX gives you results from Google, Brave, Qwant, Ahmia and popular torrent sites without spying on you.
46+
LibreX gives you results from Google, Qwant, Ahmia and popular torrent sites without spying on you.
4747
<br>
4848
<br>
4949
If you would like to learn more about LibreX check out the [Wiki](https://github.com/hnhx/librex/wiki).

api.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
$results = get_image_results($query_encoded, $page);
3535
break;
3636
case 2:
37-
require "engines/brave/video.php";
37+
require "engines/invidious/video.php";
3838
$results = get_video_results($query_encoded);
3939
break;
4040
case 3:

config.php.example

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
// Google results will be in this language
88
"google_language" => "en",
99

10+
// If you have a local instance you can change this to http://localhost:3000
11+
"invidious_instance_for_video_results" => "https://invidious.namazso.eu",
12+
1013
"disable_bittorent_search" => false,
1114
"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",
1215

@@ -49,7 +52,7 @@
4952
// CURLOPT_PROXYTYPE => CURLPROXY_HTTP,
5053
CURLOPT_RETURNTRANSFER => true,
5154
CURLOPT_ENCODING => "",
52-
CURLOPT_USERAGENT => "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36",
55+
CURLOPT_USERAGENT => "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36",
5356
CURLOPT_IPRESOLVE => CURL_IPRESOLVE_V4,
5457
CURLOPT_CUSTOMREQUEST => "GET",
5558
CURLOPT_PROTOCOLS => CURLPROTO_HTTPS | CURLPROTO_HTTP,

donate.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
<h2>Monero (XMR):</h2>
1616
<p>41dGQr9EwZBfYBY3fibTtJZYfssfRuzJZDSVDeneoVcgckehK3BiLxAV4FvEVJiVqdiW996zvMxhFB8G8ot9nBFqQ84VkuC</p>
1717
<img src="static/images/xmr.png" alt="xmr qr code" width="150" height="150"/>
18-
<h2>Liberapay</h2>
19-
<a href="https://en.liberapay.com/hnhx/donate" target="_blank">liberapay.com/hnhx</a>
2018
</div>
2119

2220
<?php require "misc/footer.php"; ?>

engines/brave/video.php

Lines changed: 0 additions & 65 deletions
This file was deleted.

engines/google/text.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@ function get_text_results($query, $page)
1010
$domain = $config->google_domain;
1111
$language = isset($_COOKIE["google_language"]) ? htmlspecialchars($_COOKIE["google_language"]) : $config->google_language;
1212

13-
$url = "https://www.google.$domain/search?&q=$query_encoded&start=$page&hl=$language&lr=lang_$language";
13+
$url = "https://www.google.$domain/search?&q=$query_encoded&start=$page";
14+
15+
if (3 > strlen($language))
16+
{
17+
$url .= "&hl=$language&lr=lang_$language";
18+
}
1419

1520
if (isset($_COOKIE["safe_search"]))
1621
{

engines/invidious/video.php

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?php
2+
function get_video_results($query)
3+
{
4+
global $config;
5+
6+
$instance_url = $config->invidious_instance_for_video_results;
7+
8+
$url = "$instance_url/api/v1/search?q=$query";
9+
$response = request($url);
10+
$json_response = json_decode($response, true);
11+
12+
$results = array();
13+
14+
foreach ($json_response as $response)
15+
{
16+
if ($response["type"] == "video")
17+
{
18+
$title = $response["title"];
19+
$url = $instance_url . "/watch?v=" . $response["videoId"];
20+
$url = check_for_privacy_frontend($url);
21+
$uploader = $response["author"];
22+
$views = $response["viewCount"];
23+
$date = $response["publishedText"];
24+
$thumbnail = $instance_url . "/vi/" . explode("/vi/" ,$response["videoThumbnails"][4]["url"])[1];
25+
26+
array_push($results,
27+
array (
28+
"title" => htmlspecialchars($title),
29+
"url" => htmlspecialchars($url),
30+
"base_url" => htmlspecialchars(get_base_url($url)),
31+
"uploader" => htmlspecialchars($uploader),
32+
"views" => htmlspecialchars($views),
33+
"date" => htmlspecialchars($date),
34+
"thumbnail" => htmlspecialchars($thumbnail)
35+
)
36+
);
37+
}
38+
}
39+
40+
return $results;
41+
}
42+
43+
function print_video_results($results)
44+
{
45+
echo "<div class=\"text-result-container\">";
46+
47+
foreach($results as $result)
48+
{
49+
$title = $result["title"];
50+
$url = $result["url"];
51+
$base_url = $result["base_url"];
52+
$uploader = $result["uploader"];
53+
$views = $result["views"];
54+
$date = $result["date"];
55+
$thumbnail = $result["thumbnail"];
56+
57+
echo "<div class=\"text-result-wrapper\">";
58+
echo "<a href=\"$url\">";
59+
echo "$base_url";
60+
echo "<h2>$title</h2>";
61+
echo "<img class=\"video-img\" src=\"image_proxy.php?url=$thumbnail\">";
62+
echo "<br>";
63+
echo "<span>$uploader - $date - $views views</span>";
64+
echo "</a>";
65+
echo "</div>";
66+
}
67+
68+
echo "</div>";
69+
}
70+
?>

favicon.ico

-909 Bytes
Binary file not shown.

image_proxy.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,11 @@
44
require "misc/tools.php";
55

66
$url = $_REQUEST["url"];
7+
$requested_root_domain = get_root_domain($url);
78

8-
$split_url = explode("/", $url);
9-
$base_url = $split_url[2];
9+
$allowed_domains = array("qwant.com", "wikimedia.org", get_root_domain($config->invidious_instance_for_video_results));
1010

11-
$base_url_main_split = explode(".", strrev($base_url));
12-
$base_url_main = strrev($base_url_main_split[1]) . "." . strrev($base_url_main_split[0]);
13-
14-
$allowed_domains = array("qwant.com", "wikimedia.org", "brave.com");
15-
16-
if (in_array($base_url_main, $allowed_domains))
11+
if (in_array($requested_root_domain, $allowed_domains))
1712
{
1813
$image = $url;
1914
$image_src = request($image);

instances.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"instances": [
33
{
44
"clearnet": "https://search.femboy.hu/",
5-
"tor": "http://librex.2356uhnbpv5nk3bni5bv6jg2cd6lgj664kwx3lhyelstpttpyv4kk2qd.onion/",
5+
"tor": "http://search.cepyxplublbyw2f4axy4pyztfbxmf63lrt2c7uwv6wl4iixz53czload.onion/",
66
"i2p": null,
77
"country": "HU"
88
},
@@ -35,7 +35,7 @@
3535
"tor": "http://5yblccekvswxl4n43bn5eg4pr7c4xygvu5lhhdb6ulzmislvahmhitad.onion",
3636
"i2p": null,
3737
"country": "PL"
38-
}
38+
},
3939
{
4040
"clearnet": "https://search.davidovski.xyz/",
4141
"tor": null,

0 commit comments

Comments
 (0)