/**
  * @param string $query
  * @return SearchResult[]
  */
 public function search($query)
 {
     try {
         $response = $this->httpClient->get('http://kickasstorrents.to/usearch/' . urlencode($query) . '/');
     } catch (\GuzzleHttp\Exception\ClientException $e) {
         return [];
     }
     $crawler = new Crawler((string) $response->getBody());
     $items = $crawler->filter('#mainSearchTable tr');
     $results = [];
     $i = 0;
     foreach ($items as $item) {
         // Ignores advertisement and header
         if ($i < 2) {
             $i++;
             continue;
         }
         $itemCrawler = new Crawler($item);
         $name = $itemCrawler->filter('.cellMainLink')->text();
         if (!stristr($name, $query)) {
             continue;
         }
         $data = json_decode(str_replace("'", '"', $itemCrawler->filter('div[data-sc-params]')->attr('data-sc-params')));
         $result = new SearchResult();
         $result->setName($name);
         $result->setSeeders((int) $itemCrawler->filter('td:nth-child(5)')->text());
         $result->setLeechers((int) $itemCrawler->filter('td:nth-child(6)')->text());
         $result->setMagnetUrl($data->magnet);
         $results[] = $result;
     }
     return $results;
 }
 public function testIsPerformingSearch()
 {
     $mockHandler = new MockHandler([new Response(200, [], $this->getMockRawResult())]);
     $adapter = new ThePirateBayAdapter();
     $adapter->setHttpClient(new Client(['handler' => $mockHandler]));
     $result1 = new SearchResult();
     $result1->setName('elementaryos-beta2-i386.20130506.iso');
     $result1->setSeeders(1);
     $result1->setLeechers(0);
     $result1->setTorrentUrl(null);
     $result1->setMagnetUrl('magnet:?xt=urn:btih:&dn=elementaryos-beta2-i386.20130506.iso&tr=udp%3A%2F%2Fopen.demonii.com%3A1337&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969&tr=udp%3A%2F%2Fexodus.desync.com%3A6969');
     $result2 = new SearchResult();
     $result2->setName('elementaryos-beta2-amd64.20130506.iso');
     $result2->setSeeders(1);
     $result2->setLeechers(0);
     $result2->setTorrentUrl(null);
     $result2->setMagnetUrl('magnet:?xt=urn:btih:&dn=elementaryos-beta2-amd64.20130506.iso&tr=udp%3A%2F%2Fopen.demonii.com%3A1337&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969&tr=udp%3A%2F%2Fexodus.desync.com%3A6969');
     $result3 = new SearchResult();
     $result3->setName('ElementaryOS 64-bit 20130810');
     $result3->setSeeders(1);
     $result3->setLeechers(0);
     $result3->setTorrentUrl(null);
     $result3->setMagnetUrl('magnet:?xt=urn:btih:&dn=ElementaryOS+64-bit+20130810&tr=udp%3A%2F%2Fopen.demonii.com%3A1337&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969&tr=udp%3A%2F%2Fexodus.desync.com%3A6969');
     $expected = [$result1, $result2, $result3];
     $actual = $adapter->search('The Walking Dead S05E08');
     $this->assertEquals($expected, $actual);
 }
Пример #3
0
 /**
  * @param string $query
  * @return SearchResult[]
  */
 public function search($query)
 {
     try {
         $response = $this->httpClient->get('https://eztv.ag/search/' . $this->transformSearchString($query));
     } catch (ClientException $e) {
         return [];
     }
     $crawler = new Crawler((string) $response->getBody());
     $items = $crawler->filter('tr.forum_header_border');
     $results = [];
     foreach ($items as $item) {
         $result = new SearchResult();
         $itemCrawler = new Crawler($item);
         $result->setName(trim($itemCrawler->filter('td')->eq(1)->text()));
         $result->setSeeders($this->options['seeders']);
         $result->setLeechers($this->options['leechers']);
         $node = $itemCrawler->filter('a.download_1');
         if ($node->count() > 0) {
             $result->setTorrentUrl($node->eq(0)->attr('href'));
         }
         $node = $itemCrawler->filter('a.magnet');
         if ($node->count() > 0) {
             $result->setMagnetUrl($node->eq(0)->attr('href'));
         }
         $results[] = $result;
     }
     return $results;
 }
 /**
  * @param string $query
  * @return SearchResult[]
  */
 public function search($query)
 {
     try {
         $response = $this->httpClient->get('https://thepiratebay.se/search/' . urlencode($query) . '/0/7/0');
     } catch (ClientException $e) {
         return [];
     }
     $crawler = new Crawler((string) $response->getBody());
     $items = $crawler->filter('#searchResult tr');
     $results = [];
     $first = true;
     foreach ($items as $item) {
         // Ignore the first row, the header
         if ($first) {
             $first = false;
             continue;
         }
         $result = new SearchResult();
         $itemCrawler = new Crawler($item);
         $result->setName(trim($itemCrawler->filter('.detName')->text()));
         $result->setSeeders((int) $itemCrawler->filter('td')->eq(2)->text());
         $result->setLeechers((int) $itemCrawler->filter('td')->eq(3)->text());
         $result->setMagnetUrl($itemCrawler->filterXpath('//tr/td/a')->attr('href'));
         $results[] = $result;
     }
     return $results;
 }
 public function testIsPerformingSearch()
 {
     $mockHandler = new MockHandler([new Response(200, [], $this->getMockRawResult())]);
     $adapter = new EzTvAdapter(['seeders' => 15, 'leechers' => 20]);
     $adapter->setHttpClient(new Client(['handler' => $mockHandler]));
     $result1 = new SearchResult();
     $result1->setName('Marvels Agents of S H I E L D S03E13 HDTV x264-FLEET');
     $result1->setSeeders(15);
     $result1->setLeechers(20);
     $result1->setTorrentUrl('https://zoink.ch/torrent/Marvels.Agents.of.S.H.I.E.L.D.S03E13.HDTV.x264-FLEET[eztv].mp4.torrent');
     $result1->setMagnetUrl('magnet:?xt=urn:btih:22db54ed3b1e55a2f998c531b8d504984adcce90&dn=Marvels.Agents.of.S.H.I.E.L.D.S03E13.HDTV.x264-FLEET%5Beztv%5D.mp4%5Beztv%5D&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A80&tr=udp%3A%2F%2Fglotorrents.pw%3A6969%2Fannounce&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337%2Fannounce&tr=udp%3A%2F%2Fexodus.desync.com%3A6969');
     $result2 = new SearchResult();
     $result2->setName('Marvels Agents of S H I E L D S03E13 720p HDTV x264-AVS');
     $result2->setSeeders(15);
     $result2->setLeechers(20);
     $result2->setTorrentUrl('https://zoink.ch/torrent/Marvels.Agents.of.S.H.I.E.L.D.S03E13.720p.HDTV.x264-AVS[eztv].mkv.torrent');
     $result2->setMagnetUrl('magnet:?xt=urn:btih:adc79cf1d0c3d855f369ca4d43894927e34b6d7a&dn=Marvels.Agents.of.S.H.I.E.L.D.S03E13.720p.HDTV.x264-AVS%5Beztv%5D.mkv%5Beztv%5D&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A80&tr=udp%3A%2F%2Fglotorrents.pw%3A6969%2Fannounce&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337%2Fannounce&tr=udp%3A%2F%2Fexodus.desync.com%3A6969');
     $result3 = new SearchResult();
     $result3->setName('Marvels Agents of S H I E L D S03E12 HDTV x264-KILLERS');
     $result3->setSeeders(15);
     $result3->setLeechers(20);
     $result3->setTorrentUrl('https://zoink.ch/torrent/Marvels.Agents.of.S.H.I.E.L.D.S03E12.HDTV.x264-KILLERS[eztv].mp4.torrent');
     $result3->setMagnetUrl('magnet:?xt=urn:btih:dac1f9ba51c08d32d113f35f0c17c5fe09381c38&dn=Marvels.Agents.of.S.H.I.E.L.D.S03E12.HDTV.x264-KILLERS%5Beztv%5D.mp4%5Beztv%5D&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A80&tr=udp%3A%2F%2Fglotorrents.pw%3A6969%2Fannounce&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337%2Fannounce&tr=udp%3A%2F%2Fexodus.desync.com%3A6969');
     $expected = [$result1, $result2, $result3];
     $actual = $adapter->search('Marvel\'s Agents of S.H.I.E.L.D.');
     $this->assertEquals($expected, $actual);
 }
 public function testIsPerformingSearch()
 {
     $mockHandler = new MockHandler([new Response(200, [], $this->getMockRawResult())]);
     $adapter = new KickassTorrentsAdapter();
     $adapter->setHttpClient(new Client(['handler' => $mockHandler]));
     $result1 = new SearchResult();
     $result1->setName('Ubuntu Linux Toolbox 1000+ Commands for Ubuntu and Debian Power Users by Christopher Negus');
     $result1->setSeeders(30);
     $result1->setLeechers(2);
     $result1->setMagnetUrl('magnet:?xt=urn:btih:D2AA08AB08325A1D9B62EA9EB7F4585148101A00&dn=ubuntu+linux+toolbox+1000+commands+for+ubuntu+and+debian+power+users+by+christopher+negus&tr=udp%3A%2F%2Ftracker.publicbt.com%2Fannounce&tr=udp%3A%2F%2Fglotorrents.pw%3A6969%2Fannounce&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80%2Fannounce&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337%2Fannounce');
     $result2 = new SearchResult();
     $result2->setName('Debian 7- System Administration Best Practices, 2013 [PDF]~StormRG~');
     $result2->setSeeders(12);
     $result2->setLeechers(1);
     $result2->setMagnetUrl('magnet:?xt=urn:btih:17A41CF831D788317A6F6E776943BD7711E6866D&dn=debian+7+system+administration+best+practices+2013+pdf+stormrg&tr=udp%3A%2F%2Ftracker.publicbt.com%2Fannounce&tr=udp%3A%2F%2Fglotorrents.pw%3A6969%2Fannounce&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80%2Fannounce&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337%2Fannounce');
     $expected = [$result1, $result2];
     $actual = $adapter->search('Debian');
     $this->assertEquals($expected, $actual);
 }