ajout heimdall

This commit is contained in:
2025-01-01 11:24:01 +01:00
parent f8be42e486
commit c52f60fca9
1477 changed files with 15692 additions and 0 deletions

View File

@@ -0,0 +1,82 @@
<?php namespace App\SupportedApps\Deluge;
use GuzzleHttp\Exception\GuzzleException;
use GuzzleHttp\Client;
use Illuminate\Support\Arr;
class Deluge extends \App\SupportedApps implements \App\EnhancedApps {
//protected $login_first = true; // Uncomment if api requests need to be authed first
protected $method = 'POST'; // Uncomment if requests to the API should be set by POST
function __construct() {
$this->jar = new \GuzzleHttp\Cookie\CookieJar; // Uncomment if cookies need to be set
}
public function login()
{
$password = $this->config->password;
$attrs = [
'body' => '{"method": "auth.login", "params": ["'.$password.'"], "id": 1}',
'cookies' => $this->jar,
'headers' => ['content-type' => 'application/json', 'Accept' => 'application/json']
];
return parent::appTest($this->url('json'), $attrs);
}
public function test()
{
$test = $this->login();
if($test->code === 200) {
$data = json_decode($test->response);
if(!isset($data->result) || is_null($data->result) || $data->result == false) {
$test->status = 'Failed: Invalid Credentials';
}
}
echo $test->status;
}
public function livestats()
{
$test = $this->login();
$status = 'inactive';
$attrs = [
'body' => '{"method": "web.update_ui", "params": [["none"], {}], "id": 1}',
'cookies' => $this->jar,
'headers' => ['content-type' => 'application/json', 'Accept' => 'application/json']
];
$res = parent::execute($this->url('json'), $attrs);
$details = json_decode($res->getBody());
$data = [];
if($details) {
$states = $details->result->filters->state;
$download_rate = $details->result->stats->download_rate ?? 0;
$upload_rate = $details->result->stats->upload_rate ?? 0;
$data['download_rate'] = format_bytes($download_rate, false, ' <span>', '/s</span>');
$data['upload_rate'] = format_bytes($upload_rate, false, ' <span>', '/s</span>');
$data['seed_count'] = self::getState($states, 'Seeding');
$data['leech_count'] = self::getState($states, 'Downloading');
$status = (self::getState($states, 'Active') > 0) ? 'active' : 'inactive';
}
return parent::getLiveStats($status, $data);
}
public function url($endpoint)
{
$api_url = parent::normaliseurl($this->config->url).$endpoint;
return $api_url;
}
protected static function getState(array $states, string $wantedState, int $default = 0): int {
$state = Arr::first($states, function (array $state) use ($wantedState) {
return $state[0] == $wantedState;
});
return Arr::get($state, 1, $default);
}
}

View File

@@ -0,0 +1,49 @@
{
"appid": "bc28bfa49a73fd2384cbecd6572ea72d0166aa28",
"name": "Deluge",
"website": "https://deluge-torrent.org/",
"license": "GNU General Public License v3.0 only",
"description": "Deluge is a BitTorrent client written in Python. Deluge is cross-platform, using a front and back end architecture where libtorrent, a software library written in C++ which provides the application's networking logic, is connected to one of various front ends through the project's own Python bindings",
"enhanced": true,
"config": {
"auth_payload": {
"method": "auth.login",
"id": 1,
"params": [":password:"]
},
"type": "apikey",
"stats": [{
"name": "Queue",
"url": ":url:api?output=json&apikey=:apikey:&mode=queue",
"key": "queue.sizeleft",
"filter": "size",
"updateOnChange": "Yes",
"suffix": ""
}, {
"name": "Speed",
"url": ":url:api?output=json&apikey=:apikey:&mode=queue",
"key": "queue.speed",
"filter": "speed",
"updateOnChange": "Yes",
"suffix": ""
}],
"stat1": {
"name": "Queue",
"url": ":url:api?output=json&apikey=:apikey:&mode=queue",
"key": "queue.sizeleft",
"filter": "size",
"updateOnChange": "Yes",
"suffix": ""
},
"stat2": {
"name": "Speed",
"url": ":url:api?output=json&apikey=:apikey:&mode=queue",
"key": "queue.speed",
"filter": "speed",
"updateOnChange": "Yes",
"suffix": ""
}
},
"tile_background": "dark",
"icon": "deluge.png"
}

View File

@@ -0,0 +1,14 @@
<h2>{{ __('app.apps.config') }} ({{ __('app.optional') }}) @include('items.enable')</h2>
<div class="items">
<div class="input">
<label>{{ strtoupper(__('app.url')) }}</label>
{!! Form::text('config[override_url]', (isset($item) ? $item->getconfig()->override_url : null), array('placeholder' => __('app.apps.override'), 'id' => 'override_url', 'class' => 'form-control')) !!}
</div>
<div class="input">
<label>{{ __('app.apps.password') }}</label>
{!! Form::input('password', 'config[password]', (isset($item) ? $item->getconfig()->password : null), array('placeholder' => __('app.apps.password'), 'data-config' => 'password', 'class' => 'form-control config-item')) !!}
</div>
<div class="input">
<button style="margin-top: 32px;" class="btn test" id="test_config">Test</button>
</div>
</div>

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

@@ -0,0 +1,4 @@
<ul class="livestats">
<li><span class="title">Leech: {{ $leech_count }}</span><strong>{!! $download_rate !!}</strong></li>
<li><span class="title">Seed: {{ $seed_count }}</span><strong>{!! $upload_rate !!}</strong></li>
</ul>