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 @@ {% if playlist.isOnline is same as(true) %} {{ playlist.code }} - онлайн + online {% elseif playlist.isOnline is same as(false) %} {{ playlist.code }} - оффлайн + offline {% elseif playlist.isOnline is same as(null) %} {{ playlist.code }} unknown @@ -116,16 +116,18 @@ Наполнение -  группы: {{ playlist.groups|length }}, -  каналы: {{ playlist.channels|length }} - ({{ playlist.onlineCount }} + {{ playlist.offlineCount }}) +  группы: {{ playlist.groups|length }}
+  каналы: {{ playlist.channels|length }}: + {{ playlist.onlineCount }} ({{ playlist.onlinePercent }}%) + {{ playlist.offlineCount }} ({{ playlist.offlinePercent }}%) Возможности  Программа передач: {{ playlist.hasTvg ? 'есть' : 'нет' }}
-  Перемотка (архив): {{ playlist.hasCatchup ? 'есть' : 'нет' }} +  Перемотка (архив): {{ playlist.hasCatchup ? 'есть' : 'нет' }} @@ -315,7 +317,7 @@ for="chfOnline" title="Выбрать только онлайн каналы" > - + {{ playlist.onlineCount }} - + {{ playlist.offlineCount }}