Make Emby enhanced

This commit is contained in:
Nagy Róbert 2020-08-15 13:10:38 +02:00
parent 3be7d64a5e
commit f74e6a60f6
4 changed files with 87 additions and 3 deletions

View File

@ -1,5 +1,62 @@
<?php namespace App\SupportedApps\Emby;
class Emby extends \App\SupportedApps {
class Emby extends \App\SupportedApps implements \App\EnhancedApps {
}
public $config;
function __construct() {
}
public function test()
{
$test = parent::appTest($this->url('System/Info'), $this->getAttrs());
echo $test->status;
}
public function livestats()
{
$status = 'inactive';
$res = parent::execute($this->url('/emby/Items/Counts'), $this->getAttrs());
$result = json_decode($res->getBody());
$details = ['visiblestats'=>[]];
foreach($this->config->availablestats as $stat) {
$newstat = new \stdClass();
$newstat->title = self::getAvailableStats()[$stat];
$newstat->value = $result->{$stat};
$details['visiblestats'][] = $newstat;
}
return parent::getLiveStats($status, $details);
}
public function url($endpoint)
{
$api_url = parent::normaliseurl($this->config->url).$endpoint;
return $api_url;
}
private function getAttrs() {
return [
'headers' => [
'X-Emby-Token' => $this->config->password,
]
];
}
public static function getAvailableStats() {
return [
'MovieCount'=>'Movies',
'SeriesCount'=>'Series',
'EpisodeCount'=>'Episodes',
'GameCount'=>'Games',
'ArtistCount'=>'Artists',
'ProgramCount'=>'Programs',
'GameSystemCount'=>'GameSystems',
'TrailerCount'=>'Trailers',
'SongCount'=>'Songs',
'AlbumCount'=>'Albums',
'MusicVideoCount'=>'MusicVideos',
'BoxSetCount'=>'BoxSets',
'BookCount'=>'Books',
'ItemCount'=>'Items',
];
}
}

View File

@ -4,7 +4,7 @@
"website": "https://emby.media/",
"license": "Proprietary",
"description": "Emby (formerly Media Browser) is a media server designed to organize, play, and stream audio and video to a variety of devices.",
"enhanced": false,
"enhanced": true,
"tile_background": "dark",
"icon": "emby.png"
}

19
Emby/config.blade.php Normal file
View 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]', 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') }} (secret token)</label>
{!! Form::text('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">
<label>Stats to show</label>
{!! Form::select('config[availablestats][]', App\SupportedApps\Emby\Emby::getAvailableStats(), isset($item)?$item->getConfig()->availablestats:null, array('multiple'=>'multiple')) !!}
</div>
<div class="input">
<button style="margin-top: 32px;" class="btn test" id="test_config">Test</button>
</div>
</div>

8
Emby/livestats.blade.php Normal file
View 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>