Skip to content

Commit

Permalink
fix: fetching other pages when first page is cached (merge pull request
Browse files Browse the repository at this point in the history
#105 from davidovski/fix_pages_caching)

Fix fetching other pages when first page is cached
  • Loading branch information
Ahwxorg authored Jan 3, 2024
2 parents 4aa25f7 + 70fd43f commit c77e0c1
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 9 deletions.
4 changes: 2 additions & 2 deletions config.php.example
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
// You can use any Invidious instance here
"invidious_instance_for_video_results" => "https://invidious.snopyta.org",

"disable_bittorent_search" => false,
"bittorent_trackers" => "&tr=http://nyaa.tracker.wf:7777/announce&tr=udp://open.stealth.si:80/announce&tr=udp://tracker.opentrackr.org:1337/announce&tr=udp://exodus.desync.com:6969/announce&tr=udp://tracker.torrent.eu.org:451/announce",
"disable_bittorrent_search" => false,
"bittorrent_trackers" => "&tr=http://nyaa.tracker.wf:7777/announce&tr=udp://open.stealth.si:80/announce&tr=udp://tracker.opentrackr.org:1337/announce&tr=udp://exodus.desync.com:6969/announce&tr=udp://tracker.torrent.eu.org:451/announce",

"disable_hidden_service_search" => false,

Expand Down
4 changes: 2 additions & 2 deletions docker/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"language" => "${CONFIG_LANGUAGE}",
"number_of_results" => ${CONFIG_NUMBER_OF_RESULTS},
"invidious_instance_for_video_results" => "${CONFIG_INVIDIOUS_INSTANCE}",
"disable_bittorent_search" => ${CONFIG_DISABLE_BITTORRENT_SEARCH},
"bittorent_trackers" => "${CONFIG_BITTORRENT_TRACKERS}",
"disable_bittorrent_search" => ${CONFIG_DISABLE_BITTORRENT_SEARCH},
"bittorrent_trackers" => "${CONFIG_BITTORRENT_TRACKERS}",
"disable_hidden_service_search" => ${CONFIG_HIDDEN_SERVICE_SEARCH},
"instance_fallback" => ${CONFIG_INSTANCE_FALLBACK},
"request_cooldown" => ${CONFIG_RATE_LIMIT_COOLDOWN},
Expand Down
4 changes: 2 additions & 2 deletions engines/bittorrent/thepiratebay.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function parse_results($response) {
if ($name == "No results returned")
break;

array_push($results,
array_push($results,
array (
"size" => htmlspecialchars($size),
"name" => htmlspecialchars($name),
Expand All @@ -39,7 +39,7 @@ public function parse_results($response) {
}

return $results;

}
}
?>
2 changes: 1 addition & 1 deletion engines/qwant/image.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
class QwantImageSearch extends EngineRequest {
public function get_request_url() {
$offset = $page * 5; // load 50 images per page
$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";
}
Expand Down
2 changes: 1 addition & 1 deletion engines/text/text.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public function __construct($opts, $mh) {
shuffle($this->engines);

$this->query = $opts->query;
$this->cache_key = "text:" . $this->query;
$this->cache_key = "text:" . $this->query . "p" . $opts->page . "l" . $opts->language;

$this->page = $opts->page;
$this->opts = $opts;
Expand Down
9 changes: 8 additions & 1 deletion misc/search_engine.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ public static function print_results($results, $opts) {}
function load_opts() {
$opts = require "config.php";

# account for the old, misspelled options
if (isset($opts->disable_bittorent_search))
$opts->disable_bittorrent_search = $opts->disable_bittorent_search;

if (isset($opts->bittorent_trackers))
$opts->bittorrent_trackers = $opts->bittorent_trackers;

$opts->request_cooldown ??= 25;
$opts->cache_time ??= 25;

Expand Down Expand Up @@ -124,7 +131,7 @@ function init_search($opts, $mh) {
return new VideoSearch($opts, $mh);

case 3:
if ($opts->disable_bittorent_search) {
if ($opts->disable_bittorrent_search) {
echo "<p class=\"text-result-container\">" . TEXTS["feature_disabled"] . "</p>";
break;
}
Expand Down

0 comments on commit c77e0c1

Please sign in to comment.