LibreY- privacy respecting meta search engine |
git clone git://git.acid.vegas/LibreY.git |
Log | Files | Refs | Archive | README | LICENSE |
nyaa.php (1966B)
1 <?php 2 class NyaaRequest extends EngineRequest { 3 public $SOURCE = "nyaa.si"; 4 5 public function get_request_url() { 6 return "https://$this->SOURCE/?q=" . urlencode($this->query); 7 } 8 9 public function parse_results($response) { 10 $xpath = get_xpath($response); 11 $results = array(); 12 13 if (!$xpath) 14 return $results; 15 16 foreach($xpath->query("//tbody/tr") as $result) 17 { 18 $name_node = $xpath->evaluate(".//td[@colspan='2']//a[not(contains(@class, 'comments'))]/@title", $result); 19 if ($name_node->length > 0) { 20 $name = $name_node[0]->textContent; 21 } else { 22 $name = ""; 23 } 24 $centered = $xpath->evaluate(".//td[@class='text-center']", $result); 25 $magnet_node = $xpath->evaluate(".//a[2]/@href", $centered[0]); 26 if ($magnet_node->length > 0) { 27 $magnet = $magnet_node[0]->textContent; 28 $magnet_without_tracker = explode("&tr=", $magnet)[0]; 29 $magnet = $magnet_without_tracker . $this->opts->bittorent_trackers; 30 } else { 31 $magnet = ""; 32 } 33 $size = $centered[1]->textContent; 34 $seeders = $centered[3]->textContent; 35 $leechers = $centered[4]->textContent; 36 37 array_push($results, 38 array ( 39 "name" => htmlspecialchars($name), 40 "seeders" => (int) $seeders, 41 "leechers" => (int) $leechers, 42 "magnet" => htmlspecialchars($magnet), 43 "size" => htmlspecialchars($size), 44 "source" => $this->SOURCE 45 ) 46 ); 47 } 48 49 return $results; 50 } 51 } 52 ?>