LibreY

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

1337x.php (1693B)

      1 <?php
      2     class _1337xRequest extends EngineRequest {
      3         public function get_request_url() {
      4             $query = urlencode($this->query);
      5             return "https://1337x.to/search/$query/1/";
      6         }
      7 
      8         public function parse_results($response) {
      9             $xpath = get_xpath($response);
     10             $results = array();
     11 
     12             if (!$xpath)
     13                 return $results;
     14 
     15             foreach($xpath->query("//table/tbody/tr") as $result) {
     16                 $name = $xpath->evaluate(".//td[@class='coll-1 name']/a", $result)[1]->textContent;
     17                 $magnet = "./engines/bittorrent/get_magnet_1337x.php?url=https://1337x.to" . $xpath->evaluate(".//td[@class='coll-1 name']/a/@href", $result)[1]->textContent;
     18                 $size_unformatted = explode(" ", $xpath->evaluate(".//td[contains(@class, 'coll-4 size')]", $result)[0]->textContent);
     19                 $size = $size_unformatted[0] . " " . preg_replace("/[0-9]+/", "", $size_unformatted[1]);
     20                 $seeders = $xpath->evaluate(".//td[@class='coll-2 seeds']", $result)[0]->textContent;
     21                 $leechers = $xpath->evaluate(".//td[@class='coll-3 leeches']", $result)[0]->textContent;
     22 
     23                 array_push($results,
     24                     array (
     25                         "name" => htmlspecialchars($name),
     26                         "seeders" => (int) $seeders,
     27                         "leechers" => (int) $leechers,
     28                         "magnet" => htmlspecialchars($magnet),
     29                         "size" => htmlspecialchars($size),
     30                         "source" => "1337x.to"
     31                     )
     32                 );
     33             }
     34 
     35             return $results;
     36         }
     37     }
     38 ?>