ajout heimdall
This commit is contained in:
59
heimdall/config/www/SupportedApps/Kodi/Kodi.php
Executable file
59
heimdall/config/www/SupportedApps/Kodi/Kodi.php
Executable file
@@ -0,0 +1,59 @@
|
||||
<?php namespace App\SupportedApps\Kodi;
|
||||
|
||||
class Kodi extends \App\SupportedApps implements \App\EnhancedApps {
|
||||
public $config;
|
||||
|
||||
function __construct() {}
|
||||
|
||||
public function url($endpoint)
|
||||
{
|
||||
$api_url = parent::normaliseurl($this->config->url) . 'jsonrpc?request={"id":1,"jsonrpc":"2.0","method":"' . $endpoint . '"}';
|
||||
return $api_url;
|
||||
}
|
||||
|
||||
private function getAttrs() {
|
||||
return [
|
||||
'headers' => [
|
||||
'Authorization' => 'Basic ' . base64_encode($this->config->username . ':' . $this->config->password),
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
public function test()
|
||||
{
|
||||
$test = parent::appTest($this->url('JSONRPC.Introspect'), $this->getAttrs());
|
||||
echo $test->status;
|
||||
}
|
||||
|
||||
public function livestats()
|
||||
{
|
||||
$status = 'inactive';
|
||||
$data = ['visiblestats' => []];
|
||||
foreach($this->config->availablestats as $method) {
|
||||
$res = parent::execute($this->url($method), $this->getAttrs());
|
||||
$result = json_decode($res->getBody());
|
||||
if ( isset($result->result) && isset($result->result->limits) ) {
|
||||
$stat = new \stdClass();
|
||||
$stat->title = self::getAvailableStats()[$method];
|
||||
$stat->value = $result->result->limits->total;
|
||||
$data['visiblestats'][] = $stat;
|
||||
}
|
||||
}
|
||||
return parent::getLiveStats($status, $data);
|
||||
}
|
||||
|
||||
public static function getAvailableStats()
|
||||
{
|
||||
return [
|
||||
'VideoLibrary.GetMovies' => 'Movies',
|
||||
'VideoLibrary.GetMovieSets' => 'Movie Sets',
|
||||
'VideoLibrary.GetTVShows' => 'TV Shows',
|
||||
'VideoLibrary.GetEpisodes' => 'Episodes',
|
||||
'PVR.GetRecordings' => 'PVR Rec',
|
||||
'AudioLibrary.GetArtists' => 'Artists',
|
||||
'AudioLibrary.GetAlbums' => 'Albums',
|
||||
'AudioLibrary.GetSongs' => 'Songs',
|
||||
'VideoLibrary.GetMusicVideos' => 'Music Vids',
|
||||
];
|
||||
}
|
||||
}
|
||||
10
heimdall/config/www/SupportedApps/Kodi/app.json
Executable file
10
heimdall/config/www/SupportedApps/Kodi/app.json
Executable file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"appid": "8ac539a79155a0032834264ac3f6dbd38f1c812d",
|
||||
"name": "Kodi",
|
||||
"website": "https://kodi.tv/",
|
||||
"license": "GNU General Public License v1.0 or later",
|
||||
"description": "Kodi (formerly known as XBMC) is an award-winning free and open source (GPL) software media player and entertainment hub that can be installed on Linux, OSX, Windows, iOS and Android, featuring a 10-foot user interface for use with televisions and remote controls.",
|
||||
"enhanced": true,
|
||||
"tile_background": "dark",
|
||||
"icon": "kodi.png"
|
||||
}
|
||||
22
heimdall/config/www/SupportedApps/Kodi/config.blade.php
Executable file
22
heimdall/config/www/SupportedApps/Kodi/config.blade.php
Executable file
@@ -0,0 +1,22 @@
|
||||
<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]', null, array('placeholder' => __('app.apps.username'), 'data-config' => 'username', 'class' => 'form-control config-item')) !!}
|
||||
</div>
|
||||
<div class="input">
|
||||
<label>{{ __('app.apps.password') }}</label>
|
||||
{!! Form::password('config[password]', array('placeholder' => __('app.apps.password'), 'data-config' => 'password', 'class' => 'form-control config-item')) !!}
|
||||
</div>
|
||||
<div class="input">
|
||||
<label>Stats to show</label>
|
||||
{!! Form::select('config[availablestats][]', App\SupportedApps\Kodi\Kodi::getAvailableStats(), isset($item) ? ($item->getConfig()->availablestats ?? null) : null, array('multiple'=>'multiple')) !!}
|
||||
</div>
|
||||
<div class="input">
|
||||
<button style="margin-top: 32px;" class="btn test" id="test_config">Test</button>
|
||||
</div>
|
||||
</div>
|
||||
BIN
heimdall/config/www/SupportedApps/Kodi/kodi.png
Executable file
BIN
heimdall/config/www/SupportedApps/Kodi/kodi.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 1.8 KiB |
8
heimdall/config/www/SupportedApps/Kodi/livestats.blade.php
Executable file
8
heimdall/config/www/SupportedApps/Kodi/livestats.blade.php
Executable file
@@ -0,0 +1,8 @@
|
||||
<ul class="livestats">
|
||||
@foreach ($visiblestats as $stat)
|
||||
<li>
|
||||
<span class="title">{!! $stat->title !!}</span>
|
||||
<strong>{!! $stat->value !!}</strong>
|
||||
</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
Reference in New Issue
Block a user