Example #1
0
 /**
  * @param string $rawResponse
  *
  * @return Torrent[]
  */
 protected function transformResponse($rawResponse)
 {
     $crawler = new Crawler(gzdecode($rawResponse));
     return $crawler->filter('tr[id^="torrent_"]')->each(function ($node) {
         $magnet = $node->filter('.ka-magnet')->parents()->attr('href');
         preg_match('/btih:([0-9A-Za-z]+)&/', $magnet, $matches);
         $hash = $matches[1];
         $size = $node->filter('td.nobr')->text();
         preg_match('/([0-9\\.]+) ([A-Za-z]+)/', $size, $matches);
         $size = $matches[1];
         $unit = $matches[2];
         $converter = new Nomnom($size);
         $torrent = new Torrent();
         $torrent->setName($node->filter('a.cellMainLink')->text());
         $torrent->setHash($hash);
         $torrent->setMagnet($magnet);
         if ($unit == 'KB') {
             $unit = 'kB';
         }
         $torrent->setSize($converter->from($unit)->to('B'));
         $torrent->setSeeds($node->filter('td.green')->text());
         $torrent->setPeers($node->filter('td.red')->text());
         return $torrent;
     });
 }
Example #2
0
 /**
  * @param string $rawResponse
  *
  * @return Torrent[]
  *
  * @throws UnexpectedResponseException
  */
 protected function transformResponse($rawResponse)
 {
     $crawler = new Crawler($rawResponse);
     return $crawler->filter('#searchResult tr:not(.header)')->each(function ($node) {
         $magnet = $node->filter('a[href^="magnet"]')->attr('href');
         preg_match('/btih:([0-9A-Za-z]+)&/', $magnet, $matches);
         $hash = $matches[1];
         $detDesc = $node->filter('.detDesc')->text();
         preg_match('/Size ([0-9\\.]+)/', $detDesc, $matches);
         $size = $matches[1];
         preg_match('/([A-Za-z]+),/', $detDesc, $matches);
         $unit = str_replace('i', '', $matches[1]);
         $converter = new Nomnom($size);
         $torrent = new Torrent();
         $torrent->setName($node->filter('a.detLink')->text());
         $torrent->setHash($hash);
         $torrent->setMagnet($magnet);
         if ($unit == 'KB') {
             $unit = 'kB';
         }
         $torrent->setSize($converter->from($unit)->to('B'));
         $torrent->setSeeds($node->filter('td[align="right"]')->first()->text());
         $torrent->setPeers($node->filter('td[align="right"]')->last()->text());
         return $torrent;
     });
 }
Example #3
0
 /**
  * @param string $rawResponse
  *
  * @return Torrent[]
  */
 protected function transformResponse($rawResponse)
 {
     if (!($stdClass = json_decode($rawResponse))) {
         throw new UnexpectedResponseException('Could not parse response');
     }
     return array_map(function ($result) {
         $torrent = new Torrent();
         $torrent->setName($result->MovieTitle);
         $torrent->setHash($result->TorrentHash);
         $torrent->setSize($result->SizeByte);
         $torrent->setSeeds($result->TorrentSeeds);
         $torrent->setPeers($result->TorrentPeers);
         return $torrent;
     }, $stdClass->MovieList);
 }
Example #4
0
 /**
  * @param string $html
  *
  * @return Torrent[]
  */
 protected function transformResponse($html)
 {
     $crawler = new Crawler($html);
     return $crawler->filter('tr.forum_header_border')->each(function ($node) {
         $magnet = $node->filter('a.magnet')->first()->attr('href');
         preg_match('/btih:([0-9A-Za-z]+)&/', $magnet, $matches);
         $hash = $matches[1];
         $size = $node->filter('a.epinfo')->attr('title');
         preg_match('/\\(([0-9\\.]+) ([A-Za-z]+)\\)/', $size, $matches);
         $size = $matches[1];
         $unit = $matches[2];
         $converter = new Nomnom($size);
         $torrent = new Torrent();
         $torrent->setName($node->filter('td.forum_thread_post')->eq(1)->text());
         $torrent->setHash($hash);
         $torrent->setSize($converter->from($unit)->to('B'));
         return $torrent;
     });
 }