From b227556bb9bc71a1166f3be0732b05a4fa88ae29 Mon Sep 17 00:00:00 2001 From: lamacchinadesiderante Date: Sun, 5 Mar 2023 15:31:15 +0100 Subject: [PATCH] fix torrentgalaxy issue --- config.php | 8 ++--- engines/bittorrent/torrentgalaxy.php | 52 ++++++++++++++++------------ 2 files changed, 33 insertions(+), 27 deletions(-) diff --git a/config.php b/config.php index 750654c..908ed28 100644 --- a/config.php +++ b/config.php @@ -8,7 +8,7 @@ "google_language" => "it", // If you have a local instance you can change this to http://localhost:3000 - "invidious_instance_for_video_results" => "https://invidious.snopyta.org", + "invidious_instance_for_video_results" => "https://invidious.copyriot.xyz", "disable_bittorent_search" => false, "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", @@ -19,14 +19,14 @@ Preset privacy friendly frontends for users, these can be overwritten by users in settings e.g.: "invidious" => "https://yewtu.be", */ - "invidious" => "https://invidious.snopyta.org", // youtube + "invidious" => "https://invidious.copyriot.xyz", // youtube "bibliogram" => "", // instagram "rimgo" => "https://rimgo.pussthecat.org", // imgur "scribe" => "https://scribe.rip", // medium "librarian" => "", // odysee "gothub" => "", // github - "nitter" => "https://nitter.pussthecat.org", // twitter - "libreddit" => "https://libreddit.kavin.rocks", // reddit + "nitter" => "https://nitter.copyriot.xyz", // twitter + "libreddit" => "https://libreddit.copyriot.xyz", // reddit "proxitok" => "https://proxitok.pussthecat.org", // tiktok "wikiless" => "", // wikipedia "quetre" => "https://quetre.pussthecat.org", // quora diff --git a/engines/bittorrent/torrentgalaxy.php b/engines/bittorrent/torrentgalaxy.php index 1289bc2..c1e28e2 100644 --- a/engines/bittorrent/torrentgalaxy.php +++ b/engines/bittorrent/torrentgalaxy.php @@ -4,31 +4,37 @@ function get_torrentgalaxy_results($response) { global $config; - $xpath = get_xpath($response); - $results = array(); - foreach($xpath->query("//div[@class='tgxtablerow txlight']") as $result) - { - $name = $xpath->evaluate(".//div[contains(@class, 'clickable-row')]", $result)[0]->textContent; - $magnet = $xpath->evaluate(".//div[@class='tgxtablecell collapsehide rounded txlight']/a/@href", $result)[1]->textContent; - $magnet_without_tracker = explode("&tr=", $magnet)[0]; - $magnet = $magnet_without_tracker . $config->bittorent_trackers; - $size = $xpath->evaluate(".//div[@class='tgxtablecell collapsehide rounded txlight']/span", $result)[0]->textContent; - $seeders = $xpath->evaluate(".//div[@class='tgxtablecell collapsehide rounded txlight']/span/font", $result)[1]->textContent; - $leechers = $xpath->evaluate(".//div[@class='tgxtablecell collapsehide rounded txlight']/span/font", $result)[2]->textContent; - - array_push($results, - array ( - "name" => htmlspecialchars($name), - "seeders" => (int) $seeders, - "leechers" => (int) $leechers, - "magnet" => htmlspecialchars($magnet), - "size" => htmlspecialchars($size), - "source" => "tgx.rs" - ) - ); + try { + $xpath = get_xpath($response); + $results = array(); + + foreach($xpath->query("//div[@class='tgxtablerow txlight']") as $result) + { + $name = $xpath->evaluate(".//div[contains(@class, 'clickable-row')]", $result)[0]->textContent; + $magnet = $xpath->evaluate(".//div[@class='tgxtablecell collapsehide rounded txlight']/a/@href", $result)[1]->textContent; + $magnet_without_tracker = explode("&tr=", $magnet)[0]; + $magnet = $magnet_without_tracker . $config->bittorent_trackers; + $size = $xpath->evaluate(".//div[@class='tgxtablecell collapsehide rounded txlight']/span", $result)[0]->textContent; + $seeders = $xpath->evaluate(".//div[@class='tgxtablecell collapsehide rounded txlight']/span/font", $result)[1]->textContent; + $leechers = $xpath->evaluate(".//div[@class='tgxtablecell collapsehide rounded txlight']/span/font", $result)[2]->textContent; + + array_push($results, + array ( + "name" => htmlspecialchars($name), + "seeders" => (int) $seeders, + "leechers" => (int) $leechers, + "magnet" => htmlspecialchars($magnet), + "size" => htmlspecialchars($size), + "source" => "tgx.rs" + ) + ); + } + + return $results; + } catch (Error $e) { + return array(); } - return $results; } ?>