LibreY/engines/bittorrent/torrentgalaxy.php

42 lines
1.9 KiB
PHP
Raw Normal View History

<?php
2023-08-22 05:25:44 -07:00
class TorrentGalaxyRequest extends EngineRequest {
public function get_request_url() {
$query = urlencode($this->query);
return "https://torrentgalaxy.to/torrents.php?search=$query#results";
}
2023-08-22 05:25:44 -07:00
public function get_results() {
2023-08-22 16:38:59 -07:00
$response = curl_multi_getcontent($this->ch);
$xpath = get_xpath($response);
$results = array();
2023-08-22 16:38:59 -07:00
if (!$xpath)
return $results;
2023-08-22 16:38:59 -07:00
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 . $this->opts->bittorrent_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;
2023-08-22 16:38:59 -07:00
array_push($results,
array (
"name" => htmlspecialchars($name),
"seeders" => (int) $seeders,
"leechers" => (int) $leechers,
"magnet" => htmlspecialchars($magnet),
"size" => htmlspecialchars($size),
"source" => "torrentgalaxy.to"
)
);
2023-08-22 05:25:44 -07:00
}
2023-08-22 16:38:59 -07:00
return $results;
2023-08-22 05:25:44 -07:00
}
2023-08-22 16:38:59 -07:00
}
?>