LibreY

- privacy respecting meta search engine
git clone git://git.acid.vegas/LibreY.git
Log | Files | Refs | Archive | README | LICENSE

rutor.php (1670B)

      1 <?php
      2     class RutorRequest extends EngineRequest {
      3         public function get_request_url() {
      4             return "http://rutor.info/search/" . urlencode($this->query);
      5         }
      6 
      7         public function parse_results($response) {
      8             $xpath = get_xpath($response);
      9             $results = array();
     10 
     11             if (!$xpath)
     12                 return $results;
     13 
     14             foreach($xpath->query("//table/tr[@class='gai' or @class='tum']") as $result)
     15             {
     16                 $name = $xpath->evaluate(".//td/a", $result)[2]->textContent;
     17                 $magnet =  $xpath->evaluate(".//td/a/@href", $result)[1]->textContent;
     18                 $magnet_without_tracker = explode("&tr=", $magnet)[0];
     19                 $magnet = $magnet_without_tracker . $this->opts->bittorrent_trackers;
     20                 $td = $xpath->evaluate(".//td", $result);
     21                 $size = $td[count($td) == 5 ? 3 : 2]->textContent;
     22                 $seeders = $xpath->evaluate(".//span", $result)[0]->textContent;
     23                 $leechers = $xpath->evaluate(".//span", $result)[1]->textContent;
     24 
     25                 array_push($results,
     26                     array (
     27                         "name" => htmlspecialchars($name),
     28                         "seeders" => (int) filter_var($seeders, FILTER_SANITIZE_NUMBER_INT),
     29                         "leechers" => (int) filter_var($leechers, FILTER_SANITIZE_NUMBER_INT),
     30                         "magnet" => htmlspecialchars($magnet),
     31                         "size" => htmlspecialchars($size),
     32                         "source" => "rutor.info"
     33                     )
     34                 );
     35             }
     36 
     37             return $results;
     38         }
     39     }
     40 ?>