diff --git a/Tracearr/Tracearr.php b/Tracearr/Tracearr.php index 7980725704..e96ac9b93b 100644 --- a/Tracearr/Tracearr.php +++ b/Tracearr/Tracearr.php @@ -2,6 +2,59 @@ namespace App\SupportedApps\Tracearr; -class Tracearr extends \App\SupportedApps +class Tracearr extends \App\SupportedApps implements \App\EnhancedApps { + public $config; + + public function test() + { + $test = parent::appTest($this->url("api/v2/public/streams?summary=true"), $this->getAttrs()); + echo $test->status; + } + + public function livestats() + { + $status = "inactive"; + $data = [ + "streams" => 0, + "transcodes" => 0, + "bandwidth" => "0 Mbps", + ]; + + $res = parent::execute($this->url("api/v2/public/streams?summary=true"), $this->getAttrs()); + $summary = $res ? (json_decode($res->getBody())->summary ?? null) : null; + + if ($summary) { + $data["streams"] = $summary->total; + $data["transcodes"] = $summary->transcodes; + $data["bandwidth"] = $summary->total_bitrate; + if ($summary->total > 0) { + $status = "active"; + } + } + + return parent::getLiveStats($status, $data); + } + + public function url($endpoint) + { + $api_url = parent::normaliseurl($this->config->url) . $endpoint; + return $api_url; + } + + private function getAttrs() + { + $attrs = [ + "headers" => [ + "Accept" => "application/json", + "Authorization" => "Bearer " . $this->config->apikey, + ], + ]; + + if (!empty($this->config->ignore_tls)) { + $attrs["verify"] = false; + } + + return $attrs; + } } diff --git a/Tracearr/app.json b/Tracearr/app.json index 8e73220bfe..9ccdd58865 100644 --- a/Tracearr/app.json +++ b/Tracearr/app.json @@ -4,7 +4,7 @@ "website": "https://tracearr.com", "license": "Other", "description": "Real-time monitoring for Plex, Jellyfin, and Emby servers. Track streams, analyze playback, and detect account sharing from a single dashboard.", - "enhanced": false, + "enhanced": true, "tile_background": "dark", "icon": "tracearr.png" } diff --git a/Tracearr/config.blade.php b/Tracearr/config.blade.php new file mode 100644 index 0000000000..a97c9979e8 --- /dev/null +++ b/Tracearr/config.blade.php @@ -0,0 +1,31 @@ +