ajout heimdall
This commit is contained in:
10
heimdall/config/www/SupportedApps/qBittorrent/app.json
Executable file
10
heimdall/config/www/SupportedApps/qBittorrent/app.json
Executable file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"appid": "3ebd4dd8afe6308e392ccf09e3516eee99a1e8df",
|
||||
"name": "qBittorrent",
|
||||
"website": "https://www.qbittorrent.org/",
|
||||
"license": "GNU General Public License v2.0 only",
|
||||
"description": "The qBittorrent project aims to provide an open-source software alternative to µTorrent.",
|
||||
"enhanced": true,
|
||||
"tile_background": "dark",
|
||||
"icon": "qbittorrent.png"
|
||||
}
|
||||
19
heimdall/config/www/SupportedApps/qBittorrent/config.blade.php
Executable file
19
heimdall/config/www/SupportedApps/qBittorrent/config.blade.php
Executable file
@@ -0,0 +1,19 @@
|
||||
<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]', null, array('placeholder' => __('app.apps.override'), 'id' => 'override_url', 'class' => 'form-control')) !!}
|
||||
</div>
|
||||
<div class="input">
|
||||
<label>{{ __('app.apps.username') }}</label>
|
||||
{!! Form::text('config[username]', (isset($item) ? $item->getconfig()->username : null), array('placeholder' => __('app.apps.username'), 'data-config' => 'username', 'class' => 'form-control config-item')) !!}
|
||||
</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>
|
||||
|
||||
4
heimdall/config/www/SupportedApps/qBittorrent/livestats.blade.php
Executable file
4
heimdall/config/www/SupportedApps/qBittorrent/livestats.blade.php
Executable 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>
|
||||
87
heimdall/config/www/SupportedApps/qBittorrent/qBittorrent.php
Executable file
87
heimdall/config/www/SupportedApps/qBittorrent/qBittorrent.php
Executable file
@@ -0,0 +1,87 @@
|
||||
<?php namespace App\SupportedApps\qBittorrent;
|
||||
|
||||
# qBitTorrent v4.2.0 onwards enforces the use of API v2.
|
||||
# API Documentation:
|
||||
# https://github.com/qbittorrent/qBittorrent/wiki/Web-API-Documentation#authentication
|
||||
|
||||
class qBittorrent extends \App\SupportedApps implements \App\EnhancedApps {
|
||||
|
||||
public $config;
|
||||
|
||||
//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 test()
|
||||
{
|
||||
$test = $this->login();
|
||||
if($test->getStatusCode() === 200) {
|
||||
echo $test->getStatusCode();
|
||||
}
|
||||
#$test = parent::appTest($this->url('version/api'));
|
||||
$test = parent::appTest($this->url('api/v2/app/version'));
|
||||
echo $test->status;
|
||||
}
|
||||
|
||||
public function login()
|
||||
{
|
||||
$username = urlencode($this->config->username);
|
||||
$password = urlencode($this->config->password);
|
||||
$attrs = [
|
||||
'body' => 'username='.$username.'&password='.$password,
|
||||
'cookies' => $this->jar,
|
||||
'headers' => ['content-type' => 'application/x-www-form-urlencoded']
|
||||
];
|
||||
#return parent::execute($this->url('login'), $attrs, false, 'POST');
|
||||
return parent::execute($this->url('api/v2/auth/login'), $attrs, false, 'POST');
|
||||
}
|
||||
|
||||
public function livestats()
|
||||
{
|
||||
$status = 'inactive';
|
||||
$this->login();
|
||||
$attrs = [
|
||||
'cookies' => $this->jar
|
||||
];
|
||||
#$res = parent::execute($this->url('query/torrents'), $attrs);
|
||||
$res = parent::execute($this->url('api/v2/torrents/info'), $attrs);
|
||||
$details = json_decode($res->getBody());
|
||||
|
||||
$data = [];
|
||||
|
||||
|
||||
$torrents = $details;
|
||||
$torrentCount = count($torrents);
|
||||
$rateDownload = $rateUpload = $completedTorrents = 0;
|
||||
foreach ($torrents as $thisTorrent) {
|
||||
$rateDownload += $thisTorrent->dlspeed;
|
||||
$rateUpload += $thisTorrent->upspeed;
|
||||
if ($thisTorrent->progress == 1) {
|
||||
$completedTorrents += 1;
|
||||
}
|
||||
}
|
||||
$leech = $torrentCount - $completedTorrents;
|
||||
if ($leech > 0) {
|
||||
$status = 'active';
|
||||
}
|
||||
|
||||
$data['download_rate'] = format_bytes($rateDownload, false, ' <span>', '/s</span>');
|
||||
$data['upload_rate'] = format_bytes($rateUpload, false, ' <span>', '/s</span>');
|
||||
$data['seed_count'] = $completedTorrents ?? 0;
|
||||
$data['leech_count'] = $leech ?? 0;
|
||||
|
||||
|
||||
|
||||
|
||||
return parent::getLiveStats($status, $data);
|
||||
|
||||
}
|
||||
public function url($endpoint)
|
||||
{
|
||||
$api_url = parent::normaliseurl($this->config->url).$endpoint;
|
||||
return $api_url;
|
||||
}
|
||||
}
|
||||
BIN
heimdall/config/www/SupportedApps/qBittorrent/qbittorrent.png
Executable file
BIN
heimdall/config/www/SupportedApps/qBittorrent/qbittorrent.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 8.1 KiB |
Reference in New Issue
Block a user