Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 54 additions & 1 deletion Tracearr/Tracearr.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
2 changes: 1 addition & 1 deletion Tracearr/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
31 changes: 31 additions & 0 deletions Tracearr/config.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<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, ['placeholder' => __('app.apps.override'), 'id' => 'override_url', 'class' => 'form-control']) !!}
</div>
<div class="input">
<label>{{ __('app.apps.apikey') }}</label>
{!! Form::text('config[apikey]', isset($item) ? $item->getconfig()->apikey : null, ['placeholder' => __('app.apps.apikey'), 'data-config' => 'apikey', 'class' => 'form-control config-item']) !!}
</div>
<div class="input">
<label>Skip TLS verification</label>
<div class="toggleinput" style="margin-top: 26px; padding-left: 15px;">
{!! Form::hidden('config[ignore_tls]', 0, ['class' => 'config-item', 'data-config' => 'ignore_tls']) !!}
<label class="switch">
<?php
$checked = false;
if (isset($item) && !empty($item) && isset($item->getconfig()->ignore_tls)) {
$checked = $item->getconfig()->ignore_tls;
}
$set_checked = $checked ? ' checked="checked"' : '';
?>
<input type="checkbox" class="config-item" data-config="ignore_tls" name="config[ignore_tls]" value="1" <?php echo $set_checked; ?> />
<span class="slider round"></span>
</label>
</div>
</div>
<div class="input">
<button style="margin-top: 32px;" class="btn test" id="test_config">Test</button>
</div>
</div>
14 changes: 14 additions & 0 deletions Tracearr/livestats.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<ul class="livestats">
<li>
<span class="title">Streams</span>
<strong>{!! $streams !!}</strong>
</li>
<li>
<span class="title">Transcodes</span>
<strong>{!! $transcodes !!}</strong>
</li>
<li>
<span class="title">Bandwidth</span>
<strong>{!! $bandwidth !!}</strong>
</li>
</ul>