diff --git a/README.md b/README.md index eedec54..b582dae 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,7 @@ Jusqu'a présent, les fonctionalités suivantes ont été implémentées : - Download (core) - Download Stats - Download Files + - Download Configuration - Configuration - Connection - Connection (Core) @@ -133,7 +134,8 @@ Les exemples sont disponibles dans le repertoire `exemple`. Ils sont classés pa - `System` : Affichage de la configuration système de la freebox - `UPnP` : Affichage des configuration UPnP - `download` - - `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 + - `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 \ No newline at end of file diff --git a/TODO.md b/TODO.md index eddb3c3..19e17f1 100644 --- a/TODO.md +++ b/TODO.md @@ -6,7 +6,7 @@ - Download Peers [UNSTABLE] - Download Blacklist [UNSTABLE] - Download Feeds - - Download Configuration + - ~~Download Configuration~~ - ~~File System Api~~ - ~~File System~~ - ~~File Sharing Link~~ diff --git a/exemple/download/DlConfig.php b/exemple/download/DlConfig.php new file mode 100644 index 0000000..4a64c53 --- /dev/null +++ b/exemple/download/DlConfig.php @@ -0,0 +1,17 @@ +authorize(); +$App->openSession(); + +/// Download configuration +$DownloadConfigService = new \alphayax\freebox\api\v3\services\download\Configuration( $App); +$DlConfig = $DownloadConfigService->getConfiguration(); +print_r( $DlConfig); + +$DlConfig = $DownloadConfigService->updateThrottlingMode( 'normal'); +print_r( $DlConfig); diff --git a/freebox/api/v3/models/Download/Config/DlThrottlingConfig.php b/freebox/api/v3/models/Download/Config/DlThrottlingConfig.php index 84af677..dc989d3 100644 --- a/freebox/api/v3/models/Download/Config/DlThrottlingConfig.php +++ b/freebox/api/v3/models/Download/Config/DlThrottlingConfig.php @@ -14,12 +14,12 @@ class DlThrottlingConfig extends Model { /** @var DlRate : download rate for normal slow slot (in B/s) */ protected $slow; - /** @var string + /** @var string[168] * The schedule array represent the list of week hours timeslot, starting on monday a midnight. * Therefore the complete week is represented in a array of 168 elements (24 * 7) * @see alphayax\freebox\api\v3\symbols\Download\Config\DlThrottlingConfig\Schedule */ - protected $schedule; + protected $schedule = []; /** * @var string @@ -27,6 +27,16 @@ class DlThrottlingConfig extends Model { */ protected $mode; + /** + * DlThrottlingConfig constructor. + * @param array $properties_x + */ + public function __construct( array $properties_x){ + parent::__construct( $properties_x); + $this->initProperty( '$normal' , DlRate::class); + $this->initProperty( 'slow' , DlRate::class); + } + /** * @return DlRate */ diff --git a/freebox/api/v3/services/download/Configuration.php b/freebox/api/v3/services/download/Configuration.php new file mode 100644 index 0000000..5d880fb --- /dev/null +++ b/freebox/api/v3/services/download/Configuration.php @@ -0,0 +1,55 @@ +getAuthService( self::API_DOWNLOAD_CONFIG); + $rest->GET(); + + return new models\Download\Config\DownloadConfig( $rest->getCurlResponse()['result']); + } + + /** + * Update the Download configuration + * @param models\Download\Config\DownloadConfig $downloadConfig + * @return models\Download\Config\DownloadConfig + */ + public function setConfiguration( models\Download\Config\DownloadConfig $downloadConfig){ + $rest = $this->getAuthService( self::API_DOWNLOAD_CONFIG); + $rest->PUT( $downloadConfig->toArray()); + + return new models\Download\Config\DownloadConfig( $rest->getCurlResponse()['result']); + } + + /** + * You can force the throttling mode using this method. + * You can use any of the throttling modes defined in DlThrottlingConfig. + * Setting to schedule will automatically set correct throttling mode. + * Other values will force the throttling mode until you set it back to schedule. + * @param string $throttlingMode + * @return array [is_scheduled, throttling] + */ + public function updateThrottlingMode( $throttlingMode = 'normal'){ + $rest = $this->getAuthService( self::API_DOWNLOAD_THROTTLING); + $rest->PUT([ + 'throttling' => $throttlingMode, + ]); + + return $rest->getCurlResponse()['result']; + } + +}