torrentgalaxy.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. class TorrentGalaxyRequest extends EngineRequest {
  3. public function get_request_url() {
  4. $query = urlencode($this->query);
  5. return "https://torrentgalaxy.to/torrents.php?search=$query#results";
  6. }
  7. public function parse_results($response) {
  8. $xpath = get_xpath($response);
  9. $results = array();
  10. if (!$xpath)
  11. return $results;
  12. foreach($xpath->query("//div[@class='tgxtablerow txlight']") as $result)
  13. {
  14. $name = $xpath->evaluate(".//div[contains(@class, 'clickable-row')]", $result)[0]->textContent;
  15. $magnet = $xpath->evaluate(".//div[@class='tgxtablecell collapsehide rounded txlight']/a/@href", $result)[1]->textContent;
  16. $magnet_without_tracker = explode("&tr=", $magnet)[0];
  17. $magnet = $magnet_without_tracker . $this->opts->bittorrent_trackers;
  18. $size = $xpath->evaluate(".//div[@class='tgxtablecell collapsehide rounded txlight']/span", $result)[0]->textContent;
  19. $seeders = $xpath->evaluate(".//div[@class='tgxtablecell collapsehide rounded txlight']/span/font", $result)[1]->textContent;
  20. $leechers = $xpath->evaluate(".//div[@class='tgxtablecell collapsehide rounded txlight']/span/font", $result)[2]->textContent;
  21. array_push($results,
  22. array (
  23. "name" => htmlspecialchars($name),
  24. "seeders" => (int) $seeders,
  25. "leechers" => (int) $leechers,
  26. "magnet" => htmlspecialchars($magnet),
  27. "size" => htmlspecialchars($size),
  28. "source" => "torrentgalaxy.to"
  29. )
  30. );
  31. }
  32. return $results;
  33. }
  34. }
  35. ?>