Add Download BT Peers API
This commit is contained in:
parent
f9d382768f
commit
4b1244aa0c
|
@ -37,7 +37,9 @@ Jusqu'a présent, les fonctionalités suivantes ont été implémentées :
|
|||
- Download Stats
|
||||
- Download Files
|
||||
- Download Configuration
|
||||
- Bittorent Trackers
|
||||
- Bittorent
|
||||
- Trackers
|
||||
- Peers
|
||||
- Configuration
|
||||
- Connection
|
||||
- Connection (Core)
|
||||
|
@ -138,5 +140,6 @@ Les exemples sont disponibles dans le repertoire `exemple`. Ils sont classés pa
|
|||
- `Download` : Listage des téléchargement en cours, liste des fichiers d'un téléchargement et mise a jour de la priorité de téléchargement
|
||||
- `DlConfig` : Affichage des configurations de téléchargement (bt, nntp...)
|
||||
- `dl_rss` : Un script qui parse les flux RSS et qui rajoute en téléchagement les items correspondant a une expression réguliere
|
||||
- `Bittorrent` : Affiche des infos sur des telechargements bittorent
|
||||
|
||||
|
2
TODO.md
2
TODO.md
|
@ -3,7 +3,7 @@
|
|||
- ~~Download Stats~~
|
||||
- ~~Download Files~~
|
||||
- ~~Download Trackers [UNSTABLE]~~
|
||||
- Download Peers [UNSTABLE]
|
||||
- ~~Download Peers [UNSTABLE]~~
|
||||
- Download Blacklist [UNSTABLE]
|
||||
- Download Feeds
|
||||
- ~~Download Configuration~~
|
||||
|
|
|
@ -13,9 +13,14 @@ $DownloadService = new \alphayax\freebox\api\v3\services\download\Download( $App
|
|||
$Downloads = $DownloadService->getAll();
|
||||
print_r( $Downloads);
|
||||
|
||||
|
||||
/// Trackers
|
||||
$TrackerService = new \alphayax\freebox\api\v3\services\download\Tracker( $App);
|
||||
$a = $TrackerService->getAll( $Downloads[1]->getId());
|
||||
$Trackers = $TrackerService->getAll( $Downloads[1]->getId());
|
||||
print_r( $Trackers);
|
||||
|
||||
/// Peers
|
||||
$PeerService = new \alphayax\freebox\api\v3\services\download\Peer( $App);
|
||||
$Peers = $PeerService->getAll( $Downloads[0]->getId());
|
||||
print_r( $Peers);
|
||||
|
||||
print_r( $a);
|
||||
|
|
@ -0,0 +1,150 @@
|
|||
<?php
|
||||
namespace alphayax\freebox\api\v3\models\Download;
|
||||
use alphayax\freebox\api\v3\Model;
|
||||
|
||||
/**
|
||||
* Class Peer
|
||||
* @package alphayax\freebox\api\v3\models\Download
|
||||
*/
|
||||
class Peer extends Model {
|
||||
|
||||
/** @var string (Read-only) : peer IP */
|
||||
protected $host;
|
||||
|
||||
/** @var int (Read-only) : peer port */
|
||||
protected $port;
|
||||
|
||||
/**
|
||||
* @var string (Read-only) : peer state
|
||||
* @see alphayax\freebox\api\v3\symbols\Download\Peer\State
|
||||
*/
|
||||
protected $state;
|
||||
|
||||
/**
|
||||
* @var string (Read-only) : peer origin
|
||||
* @see alphayax\freebox\api\v3\symbols\Download\Peer\Origin
|
||||
*/
|
||||
protected $origin;
|
||||
|
||||
/** @var
|
||||
* string (Read-only)
|
||||
* @see alphayax\freebox\api\v3\symbols\Download\Peer\Protocol
|
||||
*/
|
||||
protected $protocol;
|
||||
|
||||
/** @var string (Read-only) : Bittorrent client name */
|
||||
protected $client;
|
||||
|
||||
/** @var string (Read-only) : Peer country code (iso 3166) If country code is not available it will have the value ”??” */
|
||||
protected $country_code;
|
||||
|
||||
/** @var int (Read-only) : transmitted bytes */
|
||||
protected $tx;
|
||||
|
||||
/** @var int (Read-only) : received bytes */
|
||||
protected $rx;
|
||||
|
||||
/** @var int (Read-only) : current transmit rate in byte/s */
|
||||
protected $tx_rate;
|
||||
|
||||
/** @var int (Read-only) : current receive rate in byte/s */
|
||||
protected $rx_rate;
|
||||
|
||||
/** @var int (Read-only) : peer current download progress */
|
||||
protected $progress;
|
||||
|
||||
/** @var int[] (Read-only) : current requested pieces */
|
||||
protected $requests;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getHost() {
|
||||
return $this->host;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getPort() {
|
||||
return $this->port;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getState() {
|
||||
return $this->state;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getOrigin() {
|
||||
return $this->origin;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getProtocol() {
|
||||
return $this->protocol;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getClient() {
|
||||
return $this->client;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCountryCode() {
|
||||
return $this->country_code;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getTx() {
|
||||
return $this->tx;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getRx() {
|
||||
return $this->rx;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getTxRate() {
|
||||
return $this->tx_rate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getRxRate() {
|
||||
return $this->rx_rate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getProgress() {
|
||||
return $this->progress;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \int[] (Read-only)
|
||||
*/
|
||||
public function getRequests() {
|
||||
return $this->requests;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
namespace alphayax\freebox\api\v3\services\download;
|
||||
use alphayax\freebox\api\v3\Service;
|
||||
use alphayax\freebox\api\v3\models;
|
||||
|
||||
/**
|
||||
* Class Peer
|
||||
* @package alphayax\freebox\api\v3\services\download
|
||||
* @experimental
|
||||
*/
|
||||
class Peer extends Service {
|
||||
|
||||
const API_DOWNLOAD_PEERS = '/api/v3/downloads/%u/peers';
|
||||
|
||||
/**
|
||||
* Get the list of peers for a given Download
|
||||
* Attempting to call this method on a download other than bittorent will fail
|
||||
* @param int $downloadTaskId
|
||||
* @return models\Download\Peer[]
|
||||
*/
|
||||
public function getAll( $downloadTaskId){
|
||||
$service = sprintf( self::API_DOWNLOAD_PEERS, $downloadTaskId);
|
||||
$rest = $this->getAuthService( $service);
|
||||
$rest->GET();
|
||||
|
||||
$DownloadPeer_xs = @$rest->getCurlResponse()['result'] ?: [];
|
||||
$DownloadPeers = [];
|
||||
foreach( $DownloadPeer_xs as $DownloadPeer_x) {
|
||||
$DownloadPeers[] = new models\Download\Peer( $DownloadPeer_x);
|
||||
}
|
||||
return $DownloadPeers;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
namespace alphayax\freebox\api\v3\symbols\Download\Peer;
|
||||
|
||||
/**
|
||||
* Symbol Origin
|
||||
* @package alphayax\freebox\api\v3\symbols\Download\Peer
|
||||
* @see alphayax\freebox\api\v3\models\Download\Peer
|
||||
*/
|
||||
class Origin {
|
||||
|
||||
/** got the peer from the tracker */
|
||||
const TRACKER = 'tracker';
|
||||
|
||||
/** incoming peer */
|
||||
const INCOMING = 'incoming';
|
||||
|
||||
/** got the peer from DHT */
|
||||
const DHT = 'dht';
|
||||
|
||||
/** got the peer from Peer exchange protocol */
|
||||
const PEX = 'pex';
|
||||
|
||||
/** manually added peer */
|
||||
const USER = 'user';
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
namespace alphayax\freebox\api\v3\symbols\Download\Peer;
|
||||
|
||||
/**
|
||||
* Symbol Protocol
|
||||
* @package alphayax\freebox\api\v3\symbols\Download\Peer
|
||||
* @see alphayax\freebox\api\v3\models\Download\Peer
|
||||
*/
|
||||
interface Protocol {
|
||||
|
||||
/** TCP */
|
||||
const TCP = 'tcp';
|
||||
|
||||
/** Obfuscated TCP */
|
||||
const TCP_OBFUSCATED = 'tcp_obfuscated';
|
||||
|
||||
/** UDP */
|
||||
const UDP = 'udp';
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
namespace alphayax\freebox\api\v3\symbols\Download\Peer;
|
||||
|
||||
/**
|
||||
* Interface State
|
||||
* @package alphayax\freebox\api\v3\symbols\Download\Peer
|
||||
* @see alphayax\freebox\api\v3\models\Download\Peer
|
||||
*/
|
||||
interface State {
|
||||
|
||||
/** not connected */
|
||||
const DISCONNECTED = 'disconnected';
|
||||
|
||||
/** trying to connect to the peer */
|
||||
const CONNECTING = 'connecting';
|
||||
|
||||
/** connected to the peer, negotiating capabilities */
|
||||
const HANDSHAKING = 'handshaking';
|
||||
|
||||
/** ready to exchange data */
|
||||
const READY = 'ready';
|
||||
}
|
Loading…
Reference in New Issue