mirror of
https://github.com/linuxserver/Heimdall-Apps.git
synced 2026-02-20 04:16:08 +08:00
* feat: add MySpeed app integration with live stats and config - Implement MySpeed app with live statistics display for download/upload speeds - Add configuration page with URL override option - Include app icon and metadata in app.json * style: format constructor with consistent spacing * refactor: remove empty line in MySpeed constructor --------- Co-authored-by: Lucas Araujo <lucas.ribeiro.de.araujo@rabobank.nl>
44 lines
957 B
PHP
44 lines
957 B
PHP
<?php
|
|
|
|
namespace App\SupportedApps\MySpeed;
|
|
|
|
class MySpeed extends \App\SupportedApps implements \App\EnhancedApps
|
|
{
|
|
public $config;
|
|
|
|
public function __construct() {
|
|
}
|
|
|
|
public function test()
|
|
{
|
|
$test = parent::appTest($this->url('api/info/version'));
|
|
echo $test->status;
|
|
}
|
|
|
|
public function livestats()
|
|
{
|
|
$status = 'inactive';
|
|
$res = parent::execute($this->url('api/speedtests/statistics'));
|
|
$details = json_decode($res->getBody());
|
|
|
|
$data = [];
|
|
|
|
if ($details) {
|
|
$status = 'active';
|
|
$data = [
|
|
'avg_down' => floor($details->download->avg),
|
|
'avg_up' => floor($details->upload->avg)
|
|
|
|
];
|
|
}
|
|
|
|
return parent::getLiveStats($status, $data);
|
|
}
|
|
|
|
public function url($endpoint)
|
|
{
|
|
$api_url = parent::normaliseurl($this->config->url) . $endpoint;
|
|
return $api_url;
|
|
}
|
|
}
|