public function downloadTorrent($id, $path = '')
	{
		$request  = $this->sendRequest($this->baseUrl."/torrents/download/".$id, null, 0);
		$response = json_decode($request['body'], true);

		if (NULL === $response)
		{
			preg_match('/filename="(.*?)"/i', $request['header'], $filename);

			$file = fopen($path.'/'.$filename[1], 'w+');
			fwrite($file, $request['body']);
			fclose($file);
		} else {
			if (array_key_exists('error', $response))
			{
				if ($response['code'] == 201 || $response['code'] == 202) {
					$this->connect();
					return $this->downloadTorrent($id, $path);
				}
				throw new \Exception('Erreur '.$response['code'].' : '.$response['error']);
			}
		}
	}
public function downloadTorrent($id, $path = '')
	{
		$request  = $this->sendRequest($this->baseUrl."/torrents/download/".$id, null, 0);
		$response = json_decode($request['body'], true);

		if (NULL === $response)
		{
			preg_match('/filename="(.*?)"/i', $request['header'], $filename);

			$file = fopen($path.'/'.$filename[1], 'w+');
			fwrite($file, $request['body']);
			fclose($file);
		} else {
			if (array_key_exists('error', $response))
			{
				if ($response['code'] == 201 || $response['code'] == 202) {
					$this->connect();
					return $this->downloadTorrent($id, $path);
				}
				throw new \Exception('Erreur '.$response['code'].' : '.$response['error']);
			}
		}
	}
public function downloadTorrent ( $ id , $ path = '' ) { $ request = $ this -> sendRequest ( $ this -> baseUrl . "/torrents/download/" . $ id , null , 0 ) ; $ response = json_decode ( $ request [ 'body' ] , true ) ; if ( NULL === $ response ) { preg_match ( '/filename="(.*?)"/i' , $ request [ 'header' ] , $ filename ) ; $ file = fopen ( $ path . '/' . $ filename [ 1 ] , 'w+' ) ; fwrite ( $ file , $ request [ 'body' ] ) ; fclose ( $ file ) ; } else { if ( array_key_exists ( 'error' , $ response ) ) { if ( $ response [ 'code' ] == 201 || $ response [ 'code' ] == 202 ) { $ this -> connect ( ) ; return $ this -> downloadTorrent ( $ id , $ path ) ; } throw new \ Exception ( 'Erreur ' . $ response [ 'code' ] . ' : ' . $ response [ 'error' ] ) ; } } }
Download the .torrent from ID

@param string $id   The id of the torrent to download
@param string $path The path to save the .torrent
Download the . torrent from ID