From 3b0e1d8f18175da09cdf010196d9373fcc9ab624 Mon Sep 17 00:00:00 2001 From: AnthonyAxenov Date: Tue, 28 Oct 2025 11:32:25 +0800 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B2=D0=B8=D1=87=D0=BD?= =?UTF-8?q?=D0=B0=D1=8F=20=D0=BF=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=BA=D0=B0?= =?UTF-8?q?=20=D1=81=D1=82=D0=B0=D0=B1=D0=B8=D0=BB=D1=8C=D0=BD=D0=BE=D1=81?= =?UTF-8?q?=D1=82=D0=B8=20=D0=BF=D0=BB=D0=B5=D0=B9=D0=BB=D0=B8=D1=81=D1=82?= =?UTF-8?q?=D0=BE=D0=B2/=D0=BA=D0=B0=D0=BD=D0=B0=D0=BB=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Core/IniFile.php | 53 ++++++- views/details.twig | 337 ++++++++++++++++++++++++------------------- views/list.twig | 72 +++++---- views/template.twig | 2 +- 4 files changed, 282 insertions(+), 182 deletions(-) diff --git a/app/Core/IniFile.php b/app/Core/IniFile.php index 610c165..2fd7a47 100644 --- a/app/Core/IniFile.php +++ b/app/Core/IniFile.php @@ -126,16 +126,63 @@ class IniFile } $data['hasCatchup'] = str_contains($data['content'] ?? '', 'catchup'); - $data['hasTvg'] = !empty($data['attributes']['url-tvg']) - || !empty($data['attributes']['x-tvg-url']); + $data['hasTvg'] = !empty($data['attributes']['url-tvg']) || !empty($data['attributes']['x-tvg-url']); + $data['hasTokens'] = $this->hasTokens($data); $data['tags'] = []; - foreach ($data['channels'] as $channel) { + foreach ($data['channels'] as &$channel) { $data['tags'] = array_merge($data['tags'], $channel['tags']); + $channel['hasToken'] = $this->hasTokens($channel); } $data['tags'] = array_values(array_unique($data['tags'])); sort($data['tags']); return $data; } + + /** + * Проверяет наличие токенов в плейлисте + * + * Сделано именно так, а не через тег unstable, чтобы разделить логику: есть заведомо нестабильные каналы, + * которые могут не транслироваться круглосуточно, а есть платные круглосуточные, которые могут оборваться + * в любой момент. + * + * @param array $data + * @return bool + */ + protected function hasTokens(array $data): bool + { + $string = ($data['url'] ?? '') . ($data['content'] ?? ''); + if (empty($string)) { + return false; + } + + $badAttributes = [ + // токены и ключи + '[?&]token=', + '[?&]drmreq=', + // логины + '[?&]u=', + '[?&]user=', + '[?&]username=', + // пароли + '[?&]p=', + '[?&]pwd=', + '[?&]password=', + // неизвестные + // 'free=true', + // 'uid=', + // 'c_uniq_tag=', + // 'rlkey=', + // '?s=', + // '&s=', + // '?q=', + // '&q=', + ]; + + return array_any( + $badAttributes, + static fn (string $badAttribute) => preg_match_all("/$badAttribute/", $string) >= 1, + ); + } } diff --git a/views/details.twig b/views/details.twig index e1a124e..0431c6d 100644 --- a/views/details.twig +++ b/views/details.twig @@ -81,17 +81,20 @@ Код {% if playlist.isOnline is same as(true) %} - {{ playlist.code }} + {{ playlist.code }} online {% elseif playlist.isOnline is same as(false) %} - {{ playlist.code }} + {{ playlist.code }} offline {% elseif playlist.isOnline is same as(null) %} - {{ playlist.code }} + {{ playlist.code }} unknown {% endif %} + {% if "adult" in playlist.tags %} - 18+ + 18+ {% endif %} @@ -116,11 +119,20 @@ Наполнение -  группы: {{ playlist.groups|length }}
-  каналы: {{ playlist.channels|length }}: - {{ playlist.onlineCount }} ({{ playlist.onlinePercent }}%) + {{ playlist.offlineCount }} ({{ playlist.offlinePercent }}%) +  группы: {{ playlist.groups|length }}
+  каналы: + + {{ playlist.onlineCount }} ({{ playlist.onlinePercent }}%) + + + + + {{ playlist.offlineCount }} ({{ playlist.offlinePercent }}%) + + = {{ playlist.channels|length }} + + {% if playlist.hasTokens is same as (true) %} +
 могут быть нестабильные каналы + {% endif %} @@ -286,7 +298,7 @@
@@ -345,17 +357,17 @@
{% for tag in playlist.tags %} - - + + {% endfor %}
@@ -365,65 +377,86 @@ {% for channel in playlist.channels %} - - + + - + - - + {% endif %} + + {% if (channel.contentType != null) %} +
+  {{ channel.contentType }} +
+ {% endif %} + + {% if channel.tags|length > 0 %} + + {% for tag in channel.tags %} + #{{ tag }} + {% endfor %} + {% endif %} + + + {% endfor %}
{{ loop.index }}
{{ loop.index }} - + {% if channel.isOnline is same as (true) %} + + {% else %} + + {% endif %} - >{% if "adult" in channel.tags %} - 18+ - {% endif %}{{ channel.title }} -
- {% if (channel.attributes['tvg-id']) %} -
-  {{ channel.attributes['tvg-id'] }} -
- {% endif %} - {% if (channel.contentType != null) %} -
-  {{ channel.contentType }} -
- {% endif %} - {% if channel.tags|length > 0 %} - - {% for tag in channel.tags %} - #{{ tag }} - {% endfor %} - {% endif %} + {% if "adult" in channel.tags %} + 18+ + {% endif %} + + {% if channel.hasToken is same as (true) %} + + + + {% endif %} + + {{ channel.title }} + +
+ {% if (channel.attributes['tvg-id']) %} +
+  {{ channel.attributes['tvg-id'] }}
-
@@ -434,84 +467,84 @@ {% endblock %} {% block footer %} - - + + } + {% endblock %} diff --git a/views/list.twig b/views/list.twig index b4daec3..b2eda04 100644 --- a/views/list.twig +++ b/views/list.twig @@ -11,27 +11,27 @@ {% block metakeywords %}самообновляемые,бесплатные,iptv-плейлисты,iptv,плейлисты{% endblock %} {% block head %} - - + + {% endblock %} {% block header %} -
-
-

Список плейлистов ({{ count }})

-
Изменён {{ updatedAt }} МСК
-
+
+
+

Список плейлистов ({{ count }})

+
Изменён {{ updatedAt }} МСК
+
{% endblock %} {% block content %} @@ -49,17 +49,37 @@
{{ code }} - - {% if playlist.isOnline is same as(true) %}online - {% elseif playlist.isOnline is same as(false) %}offline - {% elseif playlist.isOnline is same as(null) %}unknown - {% endif %} - + {% if playlist.isOnline is same as(true) %} - {{ playlist.onlinePercent }}% + online + {% elseif playlist.isOnline is same as(false) %} + offline + {% elseif playlist.isOnline is same as(null) %} + unknown {% endif %} + + {% if playlist.isOnline is same as(true) %} + {{ playlist.onlinePercent }}% + {% endif %} + {% if "adult" in playlist.tags %} - 18+ + 18+ + {% endif %} + + {% if playlist.hasTokens is same as(true) %} + {% endif %}
@@ -69,7 +89,7 @@
{{ playlist.name }}
{% if playlist.description is not same as(null) %} -

{{ playlist.description }}

+

{{ playlist.description }}

{% endif %}
{% if playlist.isOnline is not same as(null) %} diff --git a/views/template.twig b/views/template.twig index 8042fc0..02e7d9d 100644 --- a/views/template.twig +++ b/views/template.twig @@ -13,7 +13,7 @@ - +