Example #1
0
 public function testShouldSearchTorrents()
 {
     $result = array('query' => "Ubuntu", 'offset' => 0, 'limit' => 10, 'total' => "2", 'torrents' => array(array('id' => "4536589", 'name' => "Linux Ubuntu 11.10 [Processeurs x86-32bits] [Format .iso bootable] [Français]", 'category' => "234", 'rewritename' => "linux-ubuntu-11-10-processeurs-x86-32bits-format-iso-bootable-francais", 'seeders' => "19", 'leechers' => "0", 'comments' => "40", 'isVerified' => "1", 'added' => "2011-12-05 18:33:22", 'size' => "686817280", 'times_completed' => "8477", 'owner' => "6338305", 'categoryname' => "Linux", 'categoryimage' => "app-linux", 'username' => "Elendil57", 'privacy' => "strong"), array('id' => "4967435", 'name' => "Ubuntu-13.10 Desktop-Processeurs 64bits ", 'category' => "234", 'rewritename' => "ubuntu-13-10-desktop-processeurs-64bits", 'seeders' => "11", 'leechers' => "0", 'comments' => "26", 'isVerified' => "1", 'added' => "2013-10-21 17:29:02", 'size' => "925896640", 'times_completed' => "1682", 'owner' => "96342169", 'categoryname' => "Linux", 'categoryimage' => "app-linux", 'username' => "jordanx59x", 'privacy' => "normal")));
     $response = $this->getMock('GuzzleHttp\\Message\\ResponseInterface');
     $response->expects($this->once())->method('json')->willReturn($result);
     $this->client->expects($this->once())->method('post')->with($this->config->getBaseUrl() . '/torrents/search/Ubuntu?limit=2', array('headers' => array('Authorization' => 'token')))->willReturn($response);
     $torrents = $this->repository->search('Ubuntu');
     $this->assertCount(2, $torrents);
 }
Example #2
0
<?php

require __DIR__ . '/../vendor/autoload.php';
use Rosello\T411\Authentication\Authentication;
use Rosello\T411\Config\AuthConfig;
use Rosello\T411\Downloader\TorrentDownloader;
use Rosello\T411\Repository\TorrentRepository;
//Create auth config object
$authConfig = new AuthConfig('username', 'password');
//Ask token
$authentication = new Authentication();
$tokenConfig = $authentication->auth($authConfig);
//Search torrents
$limit = 10;
$repository = new TorrentRepository($tokenConfig, $limit);
$torrents = $repository->search('Ubuntu');
//Download first torrent
$downloader = new TorrentDownloader($tokenConfig);
$file = $downloader->download($torrents[0]);