From 663c81f679008a367ec2c890febbe12e8b05bfec Mon Sep 17 00:00:00 2001 From: mikley Date: Sun, 11 May 2025 16:18:01 +0200 Subject: [PATCH] Plex section status (#828) * Update livestats.blade.php Print the media section information * Update config.blade.php Setting media section keys * Update Plex.php Querying media section data * Update Plex.php PHPCS fix 30 | ERROR | [x] Expected 1 space after IF keyword; 0 found 45 | ERROR | [x] Expected 1 space after IF keyword; 0 found --- Plex/Plex.php | 54 +++++++++++++++++++--------------------- Plex/config.blade.php | 8 ++++++ Plex/livestats.blade.php | 8 +++--- 3 files changed, 38 insertions(+), 32 deletions(-) diff --git a/Plex/Plex.php b/Plex/Plex.php index 1aeeda6b1..e440e9f9d 100644 --- a/Plex/Plex.php +++ b/Plex/Plex.php @@ -26,37 +26,35 @@ class Plex extends \App\SupportedApps implements \App\EnhancedApps public function livestats() { $status = "inactive"; - $res = parent::execute( - $this->url("/library/recentlyAdded"), - $this->attrs() - ); - $body = $res->getBody(); - $xml = simplexml_load_string( - $body, - "SimpleXMLElement", - LIBXML_NOCDATA | LIBXML_NOBLANKS - ); - $data = []; - - if ($xml) { - $data["recently_added"] = $xml["size"]; - $status = "active"; + if ($this->config->section_1_key > 0) { + $res = parent::execute($this->url("/library/sections/{$this->config->section_1_key}/all"), $this->attrs()); + $body = $res->getBody(); + $xml = simplexml_load_string( + $body, + "SimpleXMLElement", + LIBXML_NOCDATA | LIBXML_NOBLANKS + ); + if ($xml) { + $data["section_1_number"] = $xml["size"]; + $data["section_1_title"] = $xml["librarySectionTitle"]; + $status = "active"; + } } - $res = parent::execute($this->url("/library/onDeck")); - - $res = parent::execute($this->url("/library/onDeck"), $this->attrs()); - - $body = $res->getBody(); - $xml = simplexml_load_string( - $body, - "SimpleXMLElement", - LIBXML_NOCDATA | LIBXML_NOBLANKS - ); - if ($xml) { - $data["on_deck"] = $xml["size"]; - $status = "active"; + if ($this->config->section_2_key > 0) { + $res = parent::execute($this->url("/library/sections/{$this->config->section_2_key}/all"), $this->attrs()); + $body = $res->getBody(); + $xml = simplexml_load_string( + $body, + "SimpleXMLElement", + LIBXML_NOCDATA | LIBXML_NOBLANKS + ); + if ($xml) { + $data["section_2_number"] = $xml["size"]; + $data["section_2_title"] = $xml["librarySectionTitle"]; + $status = "active"; + } } return parent::getLiveStats($status, $data); diff --git a/Plex/config.blade.php b/Plex/config.blade.php index 9fb338066..f572e37e4 100644 --- a/Plex/config.blade.php +++ b/Plex/config.blade.php @@ -5,6 +5,14 @@ {!! Form::text('config[override_url]', isset($item) ? $item->getconfig()->override_url : null, ['placeholder' => __('app.apps.override'), 'id' => 'override_url', 'class' => 'form-control']) !!} +
+ + {!! Form::text('config[section_1_key]', isset($item) ? $item->getconfig()->section_1_key : null, ['placeholder' => __('section_1_key'), 'data-config' => 'section_1_key', 'class' => 'form-control config-i +
+
+ + {!! Form::text('config[section_2_key]', isset($item) ? $item->getconfig()->section_2_key : null, ['placeholder' => __('section_2_key'), 'data-config' => 'section_2_key', 'class' => 'form-control config-i +
{!! Form::text('config[token]', isset($item) ? $item->getconfig()->token : null, ['placeholder' => __('token'), 'data-config' => 'token', 'class' => 'form-control config-item']) !!} diff --git a/Plex/livestats.blade.php b/Plex/livestats.blade.php index 33e5b11ac..5c20c12b2 100644 --- a/Plex/livestats.blade.php +++ b/Plex/livestats.blade.php @@ -1,11 +1,11 @@