From f74e6a60f6f4e2d112a52182ee374fa418f1f52d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nagy=20R=C3=B3bert?= Date: Sat, 15 Aug 2020 13:10:38 +0200 Subject: [PATCH] Make Emby enhanced --- Emby/Emby.php | 61 ++++++++++++++++++++++++++++++++++++++-- Emby/app.json | 2 +- Emby/config.blade.php | 19 +++++++++++++ Emby/livestats.blade.php | 8 ++++++ 4 files changed, 87 insertions(+), 3 deletions(-) create mode 100644 Emby/config.blade.php create mode 100644 Emby/livestats.blade.php diff --git a/Emby/Emby.php b/Emby/Emby.php index 2544aaac9..1c59a133f 100644 --- a/Emby/Emby.php +++ b/Emby/Emby.php @@ -1,5 +1,62 @@ 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', + ]; + } +} \ No newline at end of file diff --git a/Emby/app.json b/Emby/app.json index e962e3f1b..81c434a70 100644 --- a/Emby/app.json +++ b/Emby/app.json @@ -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" } \ No newline at end of file diff --git a/Emby/config.blade.php b/Emby/config.blade.php new file mode 100644 index 000000000..27dc58b55 --- /dev/null +++ b/Emby/config.blade.php @@ -0,0 +1,19 @@ +

{{ __('app.apps.config') }} ({{ __('app.optional') }}) @include('items.enable')

+
+
+ + {!! Form::text('config[override_url]', isset($item)?$item->getConfig()->override_url:null, array('placeholder' => __('app.apps.override'), 'id' => 'override_url', 'class' => 'form-control')) !!} +
+
+ + {!! Form::text('config[password]', isset($item)?$item->getConfig()->password:null, array('placeholder' => __('app.apps.password'), 'data-config' => 'password', 'class' => 'form-control config-item')) !!} +
+
+ + {!! Form::select('config[availablestats][]', App\SupportedApps\Emby\Emby::getAvailableStats(), isset($item)?$item->getConfig()->availablestats:null, array('multiple'=>'multiple')) !!} +
+
+ +
+
+ diff --git a/Emby/livestats.blade.php b/Emby/livestats.blade.php new file mode 100644 index 000000000..53ac67bd2 --- /dev/null +++ b/Emby/livestats.blade.php @@ -0,0 +1,8 @@ +