parent
ba2405474a
commit
6af7249c19
|
@ -8,9 +8,5 @@
|
|||
/vendor/*
|
||||
|
||||
# Project files
|
||||
/exemple/AirMedia/app_token
|
||||
exemple/Call/app_token
|
||||
/exemple/config/app_token
|
||||
/exemple/download/app_token
|
||||
/exemple/FileSystem/app_token
|
||||
/app_token
|
||||
/exemple/**/app_token
|
||||
|
|
|
@ -9,11 +9,11 @@ $App->authorize();
|
|||
$App->openSession();
|
||||
|
||||
$FileUploadService = new \alphayax\freebox\api\v3\services\FileSystem\FileUpload( $App);
|
||||
/*
|
||||
$authID = $FileUploadService->createAuthorization('/Disque dur/Photos/', 'P3140017.jpg');
|
||||
$success = $FileUploadService->uploadFile( $authID, '/home/alphayax/Bureau/P3140017.jpg');
|
||||
|
||||
$authID = $FileUploadService->createAuthorization('/Disque dur/Vidéos/', 'Game.of.Thrones.S06E05.SUBFRENCH.1080i.HDTV.H264-LiBERTY.mkv');
|
||||
$success = $FileUploadService->uploadFile( $authID, '/home/alphayax/Game.of.Thrones.S06E05.SUBFRENCH.1080i.HDTV.H264-LiBERTY.mkv');
|
||||
print_r( $success); // 1939839620
|
||||
*/
|
||||
|
||||
|
||||
$AllUploads = $FileUploadService->getAll();
|
||||
print_r( $AllUploads);
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
|
||||
/// Require Composer AutoLoader
|
||||
require_once '../../vendor/autoload.php';
|
||||
|
||||
/// Define our application
|
||||
$App = new \alphayax\freebox\utils\Application( 'com.alphayax.freebox.download', 'PHP API Example (Download)', '1.0.0');
|
||||
$App->authorize();
|
||||
$App->openSession();
|
||||
|
||||
/// Download
|
||||
$DownloadService = new \alphayax\freebox\api\v3\services\download\Download( $App);
|
||||
$Downloads = $DownloadService->getAll();
|
||||
print_r( $Downloads);
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"rss": "https:\/\/www.nyaa.se\/?page=rss&user=175467",
|
||||
"pattern": "\/One_Piece.*HD.*mp4\/",
|
||||
"last_date": 1463304765
|
||||
"last_date": 1463909172
|
||||
}
|
|
@ -2,7 +2,7 @@
|
|||
use alphayax\utils\cli\IO;
|
||||
|
||||
/// Require Composer AutoLoader
|
||||
require_once '../../vendor/autoload.php';
|
||||
require_once '../../../vendor/autoload.php';
|
||||
|
||||
/// Define our application
|
||||
$App = new \alphayax\freebox\utils\Application( 'com.alphayax.freebox.example', 'Freebox PHP API Example', '0.0.2');
|
|
@ -0,0 +1,249 @@
|
|||
<?php
|
||||
namespace alphayax\freebox\api\v3\models\Download;
|
||||
use alphayax\freebox\api\v3\Model;
|
||||
|
||||
/**
|
||||
* Class Task
|
||||
* @package alphayax\freebox\api\v3\models\Download
|
||||
*/
|
||||
class Task extends Model {
|
||||
|
||||
/** @var int (Read-only) : id */
|
||||
protected $id;
|
||||
|
||||
/**
|
||||
* @var string (Read-only)
|
||||
* @see alphayax\freebox\api\v3\symbols\Download\Task\Type
|
||||
*/
|
||||
protected $type;
|
||||
|
||||
/** @var string (Read-only) */
|
||||
protected $name;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* @see alphayax\freebox\api\v3\symbols\Download\Task\Status
|
||||
*/
|
||||
protected $status;
|
||||
|
||||
/** @var int (Read-only) : download size (in Bytes) */
|
||||
protected $size;
|
||||
|
||||
/** @var int : position in download queue (0 if not queued) */
|
||||
protected $queue_pos;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* @see alphayax\freebox\api\v3\symbols\Download\Task\IoPriority
|
||||
*/
|
||||
protected $io_priority;
|
||||
|
||||
/** @var int (Read-only) : transmitted bytes (including protocol overhead) */
|
||||
protected $tx_bytes;
|
||||
|
||||
/** @var int (Read-only) : received bytes (including protocol overhead) */
|
||||
protected $rx_bytes;
|
||||
|
||||
/** @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) : transmit percentage (without protocol overhead)
|
||||
* To improve precision the value as been scaled by 100 so that a tx_pct of 123 means 1.23%
|
||||
*/
|
||||
protected $tx_pct;
|
||||
|
||||
/**
|
||||
* @var int (Read-only) : received percentage (without protocol overhead)
|
||||
* To improve precision the value as been scaled by 100 so that a tx_pct of 123 means 1.23%
|
||||
*/
|
||||
protected $rx_pct;
|
||||
|
||||
/** @var string (Read-only) : An error code */
|
||||
protected $error;
|
||||
|
||||
/** @var int timestamp (Read-only) : timestamp of the download creation time */
|
||||
protected $created_ts;
|
||||
|
||||
/** @var int (Read-only) : estimated remaining download time (in seconds) */
|
||||
protected $eta;
|
||||
|
||||
/** @var string (Read-only) : directory where the file(s) will be saved (base64 encoded) */
|
||||
protected $download_dir;
|
||||
|
||||
/**
|
||||
* @var int (Read-only) Only relevant for bittorrent tasks.
|
||||
* Once the transmit ration has been reached the task will stop seeding.
|
||||
* The ratio is scaled by 100 to improve resolution.
|
||||
* A stop_ratio of 150 means that the task will stop seeding once tx_bytes = 1.5 * rx_bytes.
|
||||
*/
|
||||
protected $stop_ratio;
|
||||
|
||||
/** @var string : (only relevant for nzb) password for extracting downloaded archives */
|
||||
protected $archive_password;
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getId() {
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getType() {
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName() {
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getStatus() {
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $status
|
||||
*/
|
||||
public function setStatus($status) {
|
||||
$this->status = $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getSize() {
|
||||
return $this->size;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getQueuePos() {
|
||||
return $this->queue_pos;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $queue_pos
|
||||
*/
|
||||
public function setQueuePos($queue_pos) {
|
||||
$this->queue_pos = $queue_pos;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getIoPriority() {
|
||||
return $this->io_priority;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $io_priority
|
||||
*/
|
||||
public function setIoPriority($io_priority) {
|
||||
$this->io_priority = $io_priority;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getTxBytes() {
|
||||
return $this->tx_bytes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getRxBytes() {
|
||||
return $this->rx_bytes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getTxRate() {
|
||||
return $this->tx_rate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getRxRate() {
|
||||
return $this->rx_rate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getTxPct() {
|
||||
return $this->tx_pct;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getRxPct() {
|
||||
return $this->rx_pct;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getError() {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getCreatedTs() {
|
||||
return $this->created_ts;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getEta() {
|
||||
return $this->eta;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDownloadDir() {
|
||||
return $this->download_dir;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getStopRatio() {
|
||||
return $this->stop_ratio;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getArchivePassword() {
|
||||
return $this->archive_password;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $archive_password
|
||||
*/
|
||||
public function setArchivePassword($archive_password) {
|
||||
$this->archive_password = $archive_password;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
<?php
|
||||
namespace alphayax\freebox\api\v3\services\download;
|
||||
use alphayax\freebox\api\v3\models;
|
||||
use alphayax\freebox\api\v3\Service;
|
||||
|
||||
|
||||
|
@ -15,24 +16,32 @@ class Download extends Service {
|
|||
const API_DOWNLOAD_ADD = '/api/v3/downloads/add/';
|
||||
|
||||
/**
|
||||
* Get the current system info
|
||||
* Returns the collection of all Download tasks
|
||||
* @throws \Exception
|
||||
* @return models\Download\Task[]
|
||||
*/
|
||||
public function getAll(){
|
||||
$rest = $this->getAuthService( self::API_DOWNLOAD);
|
||||
$rest->GET();
|
||||
return $rest->getCurlResponse()['result'];
|
||||
|
||||
$DownloadTask_xs = @$rest->getCurlResponse()['result'] ?: [];
|
||||
$DownloadTasks = [];
|
||||
foreach( $DownloadTask_xs as $DownloadTask_x) {
|
||||
$DownloadTasks[] = new models\Download\Task( $DownloadTask_x);
|
||||
}
|
||||
return $DownloadTasks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current system info
|
||||
* Returns the Download task with the given id
|
||||
* @param int $download_id
|
||||
* @return
|
||||
* @return models\Download\Task
|
||||
*/
|
||||
public function getFromId( $download_id){
|
||||
$rest = $this->getAuthService( self::API_DOWNLOAD . $download_id);
|
||||
$rest->GET();
|
||||
return $rest->getCurlResponse()['result'];
|
||||
|
||||
return new models\Download\Task( $rest->getCurlResponse()['result']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -44,6 +53,7 @@ class Download extends Service {
|
|||
$logService = sprintf( self::API_DOWNLOAD_LOG, $download_id);
|
||||
$rest = $this->getAuthService( $logService);
|
||||
$rest->GET();
|
||||
|
||||
return $rest->getCurlResponse()['result'];
|
||||
}
|
||||
|
||||
|
@ -56,7 +66,8 @@ class Download extends Service {
|
|||
public function deleteFromId( $download_id){
|
||||
$rest = $this->getAuthService( self::API_DOWNLOAD . $download_id);
|
||||
$rest->DELETE();
|
||||
return $rest->getCurlResponse()['result'];
|
||||
|
||||
return $rest->getCurlResponse()['success'];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -68,21 +79,22 @@ class Download extends Service {
|
|||
$eraseService = sprintf( self::API_DOWNLOAD_ERASE, $download_id);
|
||||
$rest = $this->getAuthService( $eraseService);
|
||||
$rest->DELETE();
|
||||
return $rest->getCurlResponse()['result'];
|
||||
|
||||
return $rest->getCurlResponse()['success'];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete a download task (erase data)
|
||||
* @param int $download_id
|
||||
* @param array $data
|
||||
* @return
|
||||
* Update a download task
|
||||
* @param models\Download\Task $downloadTask
|
||||
* @return models\Download\Task
|
||||
*/
|
||||
public function updateFromId( $download_id, $data){
|
||||
$eraseService = sprintf( self::API_DOWNLOAD_ERASE, $download_id);
|
||||
public function update( models\Download\Task $downloadTask){
|
||||
$eraseService = sprintf( self::API_DOWNLOAD_ERASE, $downloadTask->getId());
|
||||
$rest = $this->getAuthService( $eraseService);
|
||||
$rest->PUT( $data);
|
||||
return $rest->getCurlResponse()['result'];
|
||||
$rest->PUT( $downloadTask->toArray());
|
||||
|
||||
return new models\Download\Task( $rest->getCurlResponse()['result']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
namespace alphayax\freebox\api\v3\symbols\Download\Task;
|
||||
|
||||
/**
|
||||
* Symbol IoPriority
|
||||
* @package alphayax\freebox\api\v3\symbols\Download\Task
|
||||
* @see alphayax\freebox\api\v3\models\Download\Task
|
||||
*/
|
||||
interface IoPriority {
|
||||
const LOW = 'low';
|
||||
const NORMAL = 'normal';
|
||||
const HIGH = 'high';
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
namespace alphayax\freebox\api\v3\symbols\Download\Task;
|
||||
|
||||
/**
|
||||
* Symbol Status
|
||||
* @package alphayax\freebox\api\v3\symbols\Download\Task
|
||||
* @see alphayax\freebox\api\v3\models\Download\Task
|
||||
*/
|
||||
interface Status {
|
||||
|
||||
/** task is stopped, can be resumed by setting the status to downloading */
|
||||
const STOPPED = 'stopped';
|
||||
|
||||
/** task will start when a new download slot is available the queue position is stored in queue_pos attribute */
|
||||
const QUEUED = 'queued';
|
||||
|
||||
/** task is preparing to start download */
|
||||
const STARTING = 'starting';
|
||||
|
||||
/** task is in progress */
|
||||
const DOWNLOADING = 'downloading';
|
||||
|
||||
/** task is gracefully stopping */
|
||||
const STOPPING = 'stopping';
|
||||
|
||||
/** there was a problem with the download, you can get an error code in the error field */
|
||||
const ERROR = 'error';
|
||||
|
||||
/** the download is over. For bt you can resume seeding setting the status to seeding if the ratio is not reached yet */
|
||||
const DONE = 'done';
|
||||
|
||||
/** (only valid for nzb) download is over, the downloaded files are being checked using par2 */
|
||||
const CHECKING = 'checking';
|
||||
|
||||
/** (only valid for nzb) download is over, the downloaded files are being repaired using par2 */
|
||||
const REPAIRING = 'repairing';
|
||||
|
||||
/** only valid for nzb) download is over, the downloaded files are being extracted */
|
||||
const EXTRACTING = 'extracting';
|
||||
|
||||
/** (only valid for bt) download is over, the content is Change to being shared to other users. The task will automatically stop once the seed ratio has been reached */
|
||||
const SEEDING = 'seeding';
|
||||
|
||||
/** You can set a task status to ‘retry’ to restart the download task. */
|
||||
const RETRY = 'retry';
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
namespace alphayax\freebox\api\v3\symbols\Download\Task;
|
||||
|
||||
/**
|
||||
* Symbol Type
|
||||
* @package alphayax\freebox\api\v3\symbols\Download\Task
|
||||
* @see alphayax\freebox\api\v3\models\Download\Task
|
||||
*/
|
||||
interface Type {
|
||||
|
||||
/** bittorrent download */
|
||||
const BITTORENT = 'bt';
|
||||
|
||||
/** newsgroup download */
|
||||
const NEWSGROUP = 'nzb';
|
||||
|
||||
/** HTTP download */
|
||||
const HTTP = 'http';
|
||||
|
||||
/** FTP download */
|
||||
const FTP = 'ftp';
|
||||
}
|
Loading…
Reference in New Issue