diff --git a/app/Core/IniFile.php b/app/Core/IniFile.php index 58ddc49..50dff74 100644 --- a/app/Core/IniFile.php +++ b/app/Core/IniFile.php @@ -60,14 +60,19 @@ class IniFile 'attributes' => [], 'groups' => [], 'channels' => [], - 'onlineCount' => 0, - 'offlineCount' => 0, 'checkedAt' => null, ]; } elseif (!isset($data['attributes'])) { $data['attributes'] = []; } + $data['onlinePercent'] = 0; + $data['offlinePercent'] = 0; + if ($data['isOnline'] === true && count($data['channels'] ?? []) > 0) { + $data['onlinePercent'] = round($data['onlineCount'] / count($data['channels'] ?? []) * 100); + $data['offlinePercent'] = round($data['offlineCount'] / count($data['channels'] ?? []) * 100); + } + $data['hasCatchup'] = str_contains($data['content'] ?? '', 'catchup'); $data['hasTvg'] = !empty($data['attributes']['url-tvg']) || !empty($data['attributes']['x-tvg-url']); diff --git a/views/details.twig b/views/details.twig index b243985..5e80411 100644 --- a/views/details.twig +++ b/views/details.twig @@ -82,10 +82,10 @@