LibreY

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

merge.php (2364B)

      1 <?php
      2     class TorrentSearch extends EngineRequest {
      3         public function __construct($opts, $mh) {
      4             parent::__construct($opts, $mh);
      5 
      6             require "engines/bittorrent/thepiratebay.php";
      7             require "engines/bittorrent/rutor.php";
      8             require "engines/bittorrent/yts.php";
      9             require "engines/bittorrent/torrentgalaxy.php";
     10             require "engines/bittorrent/1337x.php";
     11             require "engines/bittorrent/sukebei.php";
     12 
     13             $this->requests = array(
     14                 new PirateBayRequest($opts, $mh),
     15                 new _1337xRequest($opts, $mh),
     16                 new NyaaRequest($opts, $mh),
     17                 new RutorRequest($opts, $mh),
     18                 new SukebeiRequest($opts, $mh),
     19                 new TorrentGalaxyRequest($opts, $mh),
     20                 new YTSRequest($opts, $mh),
     21             );
     22         }
     23 
     24         public function parse_results($response) {
     25             $results = array();
     26             foreach ($this->requests as $request) {
     27                 if ($request->successful())
     28                     $results = array_merge($results, $request->get_results());
     29             }
     30 
     31             $seeders = array_column($results, "seeders");
     32             array_multisort($seeders, SORT_DESC, $results);
     33 
     34             return $results; 
     35         }
     36 
     37         public static function print_results($results, $opts) {
     38             echo "<div class=\"text-result-container\">";
     39 
     40             if (empty($results)) {
     41                 echo "<p>" . TEXTS["failure_empty"] . "</p>";
     42                 return;
     43             }
     44 
     45             foreach($results as $result) {
     46                 $source = $result["source"];
     47                 $name = $result["name"];
     48                 $magnet = $result["magnet"];
     49                 $seeders = $result["seeders"];
     50                 $leechers = $result["leechers"];
     51                 $size = $result["size"];
     52 
     53                 echo "<div class=\"text-result-wrapper\">";
     54                 echo "<a href=\"$magnet\">";
     55                 echo "$source";
     56                 echo "<h2>$name</h2>";
     57                 echo "</a>";
     58                 echo "<span>SE: <span class=\"seeders\">$seeders</span> - ";
     59                 echo "LE: <span class=\"leechers\">$leechers</span> - ";
     60                 echo "$size</span>";
     61                 echo "</div>";
     62             }
     63 
     64             echo "</div>";
     65         }
     66     }
     67 
     68 ?>