Compare commits
22 Commits
restyle
...
23f388172c
| Author | SHA1 | Date | |
|---|---|---|---|
|
23f388172c
|
|||
|
26f73d31c3
|
|||
|
b9ac2e013a
|
|||
|
b5d3b60356
|
|||
|
c75da39b87
|
|||
|
67349bb909
|
|||
| 07692b08ce | |||
|
a491ffe6d4
|
|||
|
ba8d59644c
|
|||
|
3b0e1d8f18
|
|||
|
a93e427bb0
|
|||
|
c47481795b
|
|||
|
993625aa8f
|
|||
|
71304f6d84
|
|||
|
1b601b39bf
|
|||
|
65c9250c41
|
|||
|
4ee3ae6487
|
|||
|
3eb29a169d
|
|||
|
1f0337768e
|
|||
|
5194e03625
|
|||
|
17b9f465d7
|
|||
| e3df9a6670 |
16
.env.example
16
.env.example
@@ -3,24 +3,24 @@
|
||||
######################################
|
||||
|
||||
# config/app.php
|
||||
APP_URL="http://localhost:8080"
|
||||
APP_URL_MIRROR="https://m3u.su/"
|
||||
APP_TITLE='Проверка плейлистов'
|
||||
APP_URL=http://localhost:8080
|
||||
APP_DEBUG=false
|
||||
APP_ENV="prod"
|
||||
APP_TITLE="IPTV Плейлисты"
|
||||
APP_ENV=prod
|
||||
APP_TIMEZONE=Europe/Moscow
|
||||
PAGE_SIZE=10
|
||||
PAGE_SIZE=0
|
||||
REPO_URL='https://git.axenov.dev/IPTV'
|
||||
|
||||
# config/bot.php
|
||||
# config/api.php
|
||||
TG_BOT_TOKEN=
|
||||
TG_BOT_SECRET=
|
||||
|
||||
# config/cache.php
|
||||
CACHE_HOST="keydb"
|
||||
CACHE_HOST=keydb
|
||||
CACHE_PORT=6379
|
||||
CACHE_PASSWORD=
|
||||
CACHE_DB=0
|
||||
CACHE_TTL=14
|
||||
CACHE_TTL=600
|
||||
|
||||
# config/twig.php
|
||||
TWIG_USE_CACHE=true
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
# Веб-сервис iptv.axenov.dev
|
||||
# Веб-сервис m3u.su
|
||||
|
||||
Содержит исходный код веб-сервиса и консольные инструменты проверки плейлистов и каналов.
|
||||
|
||||
Использует [playlists.ini](https://git.axenov.dev/IPTV/playlists) с описанием плейлистов для своей работы.
|
||||
|
||||
> **Веб-сайт:** [iptv.axenov.dev](https://iptv.axenov.dev)
|
||||
> **Зеркало:** [m3u.su](https://m3u.su)
|
||||
> **Веб-сайт:** [m3u.su](https://m3u.su)
|
||||
> **Документация:** [m3u.su/docs](https://m3u.su/docs)
|
||||
> Исходный код: [git.axenov.dev/IPTV/web](https://git.axenov.dev/IPTV/web)
|
||||
> Telegram-канал: [@iptv_aggregator](https://t.me/iptv_aggregator)
|
||||
> Обсуждение: [@iptv_aggregator_chat](https://t.me/iptv_aggregator_chat)
|
||||
> Бот: [@iptv_aggregator_bot](https://t.me/iptv_aggregator_bot)
|
||||
> Дополнительные сведения: [git.axenov.dev/IPTV/.profile](https://git.axenov.dev/IPTV/.profile)
|
||||
|
||||
## О веб-сервисе
|
||||
@@ -34,7 +35,7 @@
|
||||
* `PAGE_SIZE` -- размер страницы для постраничной навигации на главной странице;
|
||||
* `USER_AGENT` -- user-agent для http-клиента, котоырй будет использоваться при подключении к внешним ресурсам;
|
||||
* `CACHE_HOST`, `CACHE_PORT`, `CACHE_PASSWORD`, `CACHE_DB` -- реквизиты подключения к cache/keydb;
|
||||
* `CACHE_TTL` -- количество часов для кэширования информации;
|
||||
* `CACHE_TTL` -- количество секунд для кэширования информации;
|
||||
* `TWIG_USE_CACHE` -- признак использования кэша компиляции шаблонов Twig.
|
||||
|
||||
У каждой переменной есть умолчание на случай отсутствия файла `.env` или её отсутствия в нём.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright (c) 2025, Антон Аксенов
|
||||
* This file is part of iptv.axenov.dev web interface
|
||||
* This file is part of m3u.su project
|
||||
* MIT License: https://git.axenov.dev/IPTV/web/src/branch/master/LICENSE
|
||||
*/
|
||||
|
||||
@@ -9,6 +9,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
use App\Core\Bot;
|
||||
use App\Core\Kernel;
|
||||
use App\Core\StatisticsService;
|
||||
use App\Errors\PlaylistNotFoundException;
|
||||
use chillerlan\QRCode\QRCode;
|
||||
use chillerlan\QRCode\QROptions;
|
||||
@@ -55,8 +58,9 @@ class ApiController extends BasicController
|
||||
*/
|
||||
public function makeQrCode(ServerRequestInterface $request, ResponseInterface $response): ResponseInterface
|
||||
{
|
||||
$ini = ini()->load();
|
||||
$code = $request->getAttribute('code');
|
||||
$codes = array_keys(ini()->getPlaylists());
|
||||
$codes = array_keys($ini);
|
||||
if (!in_array($code, $codes, true)) {
|
||||
return $response->withStatus(404);
|
||||
}
|
||||
@@ -80,4 +84,106 @@ class ApiController extends BasicController
|
||||
return $response->withStatus(200)
|
||||
->withHeader('Content-Type', $mime);
|
||||
}
|
||||
|
||||
/**
|
||||
* Возвращает информацию о плейлисте
|
||||
*
|
||||
* @param ServerRequestInterface $request
|
||||
* @param ResponseInterface $response
|
||||
* @return ResponseInterface
|
||||
* @throws Exception
|
||||
*/
|
||||
public function version(ServerRequestInterface $request, ResponseInterface $response): ResponseInterface
|
||||
{
|
||||
return $this->responseJson($response, 200, [
|
||||
'web' => Kernel::VERSION,
|
||||
'php' => PHP_VERSION,
|
||||
'keydb' => redis()->info('server')['redis_version'],
|
||||
'checker' => 'todo',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Возвращает информацию о плейлисте
|
||||
*
|
||||
* @param ServerRequestInterface $request
|
||||
* @param ResponseInterface $response
|
||||
* @return ResponseInterface
|
||||
* @throws Exception
|
||||
*/
|
||||
public function health(ServerRequestInterface $request, ResponseInterface $response): ResponseInterface
|
||||
{
|
||||
function getSize(string $directory): int
|
||||
{
|
||||
$size = 0;
|
||||
foreach (glob($directory . '/*') as $path){
|
||||
is_file($path) && $size += filesize($path);
|
||||
is_dir($path) && $size += getSize($path);
|
||||
}
|
||||
return $size;
|
||||
}
|
||||
|
||||
$tgBotInfo = config('bot.token') ? new Bot()->api->getMe() : null;
|
||||
$redisInfoServer = redis()->info('server'); // General information about the Redis server
|
||||
$redisInfoClients = redis()->info('clients'); // Client connections section
|
||||
$redisInfoMemory = redis()->info('memory'); // Memory consumption related information
|
||||
$redisInfoPers = redis()->info('persistence'); // RDB and AOF related information
|
||||
$redisInfoStats = redis()->info('stats'); // General statistics
|
||||
$redisInfoCpu = redis()->info('cpu'); // CPU consumption statistics
|
||||
$redisInfoCmd = redis()->info('commandstats'); // Redis command statistics
|
||||
$redisInfoKeysp = redis()->info('keyspace'); // Database related statistics
|
||||
$redisInfoErr = redis()->info('errorstats'); // Redis error statistics
|
||||
|
||||
$health = [
|
||||
'fileCache' => [
|
||||
'tv-logos' => [
|
||||
'sizeB' => $size = getSize(cache_path('tv-logos')),
|
||||
'sizeMiB' => round($size / 1024 / 1024, 3),
|
||||
'count' => count(glob(cache_path('tv-logos') . '/*')),
|
||||
],
|
||||
'qr-codes' => [
|
||||
'sizeB' => $size = getSize(cache_path('qr-codes')),
|
||||
'sizeMiB' => round($size / 1024 / 1024, 3),
|
||||
'count' => count(glob(cache_path('qr-codes') . '/*')),
|
||||
],
|
||||
],
|
||||
'telegram' => [
|
||||
'id' => $tgBotInfo->getId(),
|
||||
'first_name' => $tgBotInfo->getFirstName(),
|
||||
'username' => $tgBotInfo->getUsername(),
|
||||
],
|
||||
'redis' => [
|
||||
'isConnected' => redis()->isConnected(),
|
||||
'info' => [
|
||||
'server' => [
|
||||
'uptime_in_seconds' => $redisInfoServer['uptime_in_seconds'],
|
||||
'uptime_in_days' => $redisInfoServer['uptime_in_days'],
|
||||
],
|
||||
'clients' => ['connected_clients' => $redisInfoClients['connected_clients']],
|
||||
'memory' => $redisInfoMemory,
|
||||
'persistence' => $redisInfoPers,
|
||||
'stats' => $redisInfoStats,
|
||||
'cpu' => $redisInfoCpu,
|
||||
'commandstats' => $redisInfoCmd,
|
||||
'keyspace' => $redisInfoKeysp,
|
||||
'errorstats' => $redisInfoErr,
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
return $this->responseJson($response, 200, $health);
|
||||
}
|
||||
|
||||
/**
|
||||
* Возвращает информацию о плейлисте
|
||||
*
|
||||
* @param ServerRequestInterface $request
|
||||
* @param ResponseInterface $response
|
||||
* @return ResponseInterface
|
||||
* @throws Exception
|
||||
*/
|
||||
public function stats(ServerRequestInterface $request, ResponseInterface $response): ResponseInterface
|
||||
{
|
||||
return $this->responseJson($response, 200, new StatisticsService()->get());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright (c) 2025, Антон Аксенов
|
||||
* This file is part of iptv.axenov.dev web interface
|
||||
* This file is part of m3u.su project
|
||||
* MIT License: https://git.axenov.dev/IPTV/web/src/branch/master/LICENSE
|
||||
*/
|
||||
|
||||
@@ -49,8 +49,9 @@ class BasicController
|
||||
* @param array $data
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
protected function responseJson(ResponseInterface $response, int $status, array $data): ResponseInterface
|
||||
protected function responseJson(ResponseInterface $response, int $status, mixed $data): ResponseInterface
|
||||
{
|
||||
is_scalar($data) && $data = [$data];
|
||||
$data = array_merge(['timestamp' => time()], $data);
|
||||
$json = json_encode($data, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright (c) 2025, Антон Аксенов
|
||||
* This file is part of iptv.axenov.dev web interface
|
||||
* This file is part of m3u.su project
|
||||
* MIT License: https://git.axenov.dev/IPTV/web/src/branch/master/LICENSE
|
||||
*/
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright (c) 2025, Антон Аксенов
|
||||
* This file is part of iptv.axenov.dev web interface
|
||||
* This file is part of m3u.su project
|
||||
* MIT License: https://git.axenov.dev/IPTV/web/src/branch/master/LICENSE
|
||||
*/
|
||||
|
||||
@@ -36,28 +36,25 @@ class WebController extends BasicController
|
||||
*/
|
||||
public function home(ServerRequestInterface $request, ResponseInterface $response): ResponseInterface
|
||||
{
|
||||
$playlists = ini()->getPlaylists();
|
||||
|
||||
$count = count($playlists);
|
||||
$onlineCount = count(array_filter($playlists, static fn (array $playlist) => $playlist['isOnline'] === true));
|
||||
$uncheckedCount = count(array_filter($playlists, static fn (array $playlist) => $playlist['isOnline'] === null));
|
||||
$offlineCount = $count - $onlineCount - $uncheckedCount;
|
||||
|
||||
$ini = ini()->load();
|
||||
$keys = [];
|
||||
$count = count($ini);
|
||||
$pageSize = config('app.page_size');
|
||||
|
||||
if ($pageSize > 0) {
|
||||
$pageCurrent = (int)($request->getAttributes()['page'] ?? $request->getQueryParams()['page'] ?? 1);
|
||||
$pageCount = ceil($count / $pageSize);
|
||||
$offset = max(0, ($pageCurrent - 1) * $pageSize);
|
||||
$playlists = array_slice($playlists, $offset, $pageSize, true);
|
||||
$ini = array_slice($ini, $offset, $pageSize, true);
|
||||
$keys = array_keys($ini);
|
||||
}
|
||||
|
||||
$playlists = ini()->getPlaylists($keys);
|
||||
|
||||
return $this->view($request, $response, 'list.twig', [
|
||||
'updatedAt' => ini()->updatedAt(),
|
||||
'playlists' => $playlists,
|
||||
'count' => $count,
|
||||
'onlineCount' => $onlineCount,
|
||||
'uncheckedCount' => $uncheckedCount,
|
||||
'offlineCount' => $offlineCount,
|
||||
'pageCount' => $pageCount ?? 1,
|
||||
'pageCurrent' => $pageCurrent ?? 1,
|
||||
]);
|
||||
|
||||
156
app/Core/Bot.php
156
app/Core/Bot.php
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright (c) 2025, Антон Аксенов
|
||||
* This file is part of iptv.axenov.dev web interface
|
||||
* This file is part of m3u.su project
|
||||
* MIT License: https://git.axenov.dev/IPTV/web/src/branch/master/LICENSE
|
||||
*/
|
||||
|
||||
@@ -33,37 +33,35 @@ class Bot
|
||||
/**
|
||||
* @var BotApi Объект Telegram Bot API
|
||||
*/
|
||||
protected BotApi $bot;
|
||||
public readonly BotApi $api;
|
||||
|
||||
/**
|
||||
* @var Update Объект обновления бота
|
||||
*/
|
||||
protected Update $update;
|
||||
|
||||
/**
|
||||
* @var ServerRequestInterface Пришедший от Telegram запрос
|
||||
*/
|
||||
protected ServerRequestInterface $request;
|
||||
|
||||
/**
|
||||
* Конструктор
|
||||
*
|
||||
* @param ServerRequestInterface $request
|
||||
* @param ServerRequestInterface|null $request
|
||||
* @throws InvalidTelegramSecretException
|
||||
* @throws JsonException
|
||||
* @throws InvalidArgumentException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function __construct(ServerRequestInterface $request)
|
||||
public function __construct(?ServerRequestInterface $request = null)
|
||||
{
|
||||
$this->checkSecret($request);
|
||||
|
||||
$body = json_decode((string)$request->getBody(), true);
|
||||
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||
throw new JsonException(json_last_error_msg());
|
||||
$this->api = new BotApi(config('bot.token'));
|
||||
if ($request) {
|
||||
$this->checkSecret($request);
|
||||
$this->request = $request;
|
||||
}
|
||||
|
||||
$this->bot = new BotApi(config('bot.token'));
|
||||
$this->update = Update::fromResponse($body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Запсукает обработку команды
|
||||
* Запускает обработку команды
|
||||
*
|
||||
* @return bool
|
||||
* @throws InvalidArgumentException
|
||||
@@ -72,7 +70,9 @@ class Bot
|
||||
*/
|
||||
public function process(): bool
|
||||
{
|
||||
$this->parseRequestBody();
|
||||
$commandText = $this->getBotCommandText();
|
||||
|
||||
return match (true) {
|
||||
str_starts_with($commandText, '/start') => $this->processHelpCommand(),
|
||||
str_starts_with($commandText, '/list') => $this->processListCommand(),
|
||||
@@ -84,6 +84,22 @@ class Bot
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Подготавливает объект события бота
|
||||
*
|
||||
* @return void
|
||||
* @throws InvalidArgumentException
|
||||
* @throws JsonException
|
||||
*/
|
||||
protected function parseRequestBody(): void
|
||||
{
|
||||
$body = json_decode((string)$this->request->getBody(), true);
|
||||
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||
throw new JsonException(json_last_error_msg());
|
||||
}
|
||||
$this->update = Update::fromResponse($body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Обрабатывает команду /list
|
||||
*
|
||||
@@ -94,7 +110,7 @@ class Bot
|
||||
*/
|
||||
protected function processListCommand(): bool
|
||||
{
|
||||
$this->bot->sendChatAction($this->update->getMessage()->getChat()->getId(), 'typing');
|
||||
$this->api->sendChatAction($this->update->getMessage()->getChat()->getId(), 'typing');
|
||||
|
||||
$playlists = ini()->getPlaylists();
|
||||
if (empty($playlists)) {
|
||||
@@ -139,7 +155,7 @@ class Bot
|
||||
*/
|
||||
protected function processInfoCommand(): bool
|
||||
{
|
||||
$this->bot->sendChatAction($this->update->getMessage()->getChat()->getId(), 'typing');
|
||||
$this->api->sendChatAction($this->update->getMessage()->getChat()->getId(), 'typing');
|
||||
|
||||
$message = $this->update->getMessage();
|
||||
$text = $message->getText();
|
||||
@@ -235,7 +251,7 @@ class Bot
|
||||
*/
|
||||
protected function processHelpCommand(): bool
|
||||
{
|
||||
$this->bot->sendChatAction($this->update->getMessage()->getChat()->getId(), 'typing');
|
||||
$this->api->sendChatAction($this->update->getMessage()->getChat()->getId(), 'typing');
|
||||
|
||||
$replyText[] = 'Бот предоставляет короткую сводку о плейлистах, которые видны на сайте ' .
|
||||
$this->escape(base_url()) . '\.';
|
||||
@@ -265,17 +281,16 @@ class Bot
|
||||
*/
|
||||
protected function processLinksCommand(): bool
|
||||
{
|
||||
$this->bot->sendChatAction($this->update->getMessage()->getChat()->getId(), 'typing');
|
||||
$this->api->sendChatAction($this->update->getMessage()->getChat()->getId(), 'typing');
|
||||
|
||||
$replyText[] = '*Ресурсы и страницы*';
|
||||
$replyText[] = '';
|
||||
$replyText[] = '🌏 Сайт: ' . $this->escape(base_url());
|
||||
config('app.mirror_url') && $replyText[] = '🪞 Зеркало: ' . $this->escape(mirror_url());
|
||||
$replyText[] = '👩💻 Исходный код: ' . $this->escape('https://git.axenov.dev/IPTV');
|
||||
$replyText[] = '👩💻 Исходный код: ' . $this->escape(config('app.repo_url'));
|
||||
$replyText[] = '✈️ Telegram\-канал: @iptv\_aggregator';
|
||||
$replyText[] = '✈️ Обсуждение: @iptv\_aggregator\_chat';
|
||||
$replyText[] = '📚 Доп\. сведения:';
|
||||
$replyText[] = '\- ' . $this->escape('https://git.axenov.dev/IPTV/.profile');
|
||||
$replyText[] = '\- ' . $this->escape(config('app.repo_url') . '/.profile');
|
||||
$replyText[] = '\- ' . $this->escape(base_url('faq'));
|
||||
|
||||
return $this->reply(implode("\n", $replyText));
|
||||
@@ -289,87 +304,30 @@ class Bot
|
||||
*/
|
||||
protected function processStatsCommand(): bool
|
||||
{
|
||||
$this->bot->sendChatAction($this->update->getMessage()->getChat()->getId(), 'typing');
|
||||
|
||||
$allChannels = [];
|
||||
foreach (ini()->getPlaylists() as $pls) {
|
||||
$allChannels = array_merge($allChannels, $pls['channels'] ?? []);
|
||||
}
|
||||
|
||||
$onlinePls = array_filter(
|
||||
ini()->getPlaylists(),
|
||||
static fn (array $pls) => $pls['isOnline'] === true,
|
||||
);
|
||||
|
||||
$offlinePls = array_filter(
|
||||
ini()->getPlaylists(),
|
||||
static fn (array $pls) => $pls['isOnline'] === false,
|
||||
);
|
||||
|
||||
$unknownPls = array_filter(
|
||||
ini()->getPlaylists(),
|
||||
static fn (array $pls) => $pls['isOnline'] === null,
|
||||
);
|
||||
|
||||
$adultPls = array_filter(
|
||||
$onlinePls,
|
||||
static fn (array $pls) => in_array('adult', $pls['tags']),
|
||||
);
|
||||
|
||||
$catchupPls = array_filter(
|
||||
$onlinePls,
|
||||
static fn (array $pls) => $pls['hasCatchup'] === true,
|
||||
);
|
||||
|
||||
$tvgPls = array_filter(
|
||||
$onlinePls,
|
||||
static fn (array $pls) => $pls['hasTvg'] === true,
|
||||
);
|
||||
|
||||
$grouppedPls = array_filter(
|
||||
$onlinePls,
|
||||
static fn (array $pls) => count($pls['groups'] ?? []) > 0
|
||||
);
|
||||
|
||||
$onlineCh = $offlineCh = $adultCh = [];
|
||||
foreach ($onlinePls as $pls) {
|
||||
$tmpOnline = array_filter(
|
||||
$pls['channels'] ?? [],
|
||||
static fn (array $ch) => $ch['isOnline'] === true,
|
||||
);
|
||||
|
||||
$tmpOffline = array_filter(
|
||||
$pls['channels'] ?? [],
|
||||
static fn (array $ch) => $ch['isOnline'] === false,
|
||||
);
|
||||
|
||||
$tmpAdult = array_filter(
|
||||
$pls['channels'] ?? [],
|
||||
static fn (array $ch) => in_array('adult', $ch['tags']),
|
||||
);
|
||||
|
||||
$onlineCh = array_merge($onlineCh, $tmpOnline);
|
||||
$offlineCh = array_merge($offlineCh, $tmpOffline);
|
||||
$adultCh = array_merge($adultCh, $tmpAdult);
|
||||
}
|
||||
$this->api->sendChatAction($this->update->getMessage()->getChat()->getId(), 'typing');
|
||||
$stats = new StatisticsService()->get();
|
||||
|
||||
$replyText[] = '📊 *Статистика*';
|
||||
$replyText[] = '';
|
||||
$replyText[] = '*Список изменён:* ' . $this->escape(ini()->updatedAt());
|
||||
$replyText[] = '';
|
||||
$replyText[] = '*Плейлистов:* ' . count(ini()->getPlaylists());
|
||||
$replyText[] = '🟢 Онлайн \- ' . count($onlinePls);
|
||||
$replyText[] = '🔴 Оффлайн \- ' . count($offlinePls);
|
||||
$replyText[] = '⚪ В очереди \- ' . count($unknownPls);
|
||||
$replyText[] = '🔞 Для взрослых \- ' . count($adultPls);
|
||||
$replyText[] = '⏪ С перемоткой \- ' . count($catchupPls);
|
||||
$replyText[] = '🗞️ С телепрограммой \- ' . count($tvgPls);
|
||||
$replyText[] = '🗂️ С группировкой каналов \- ' . count($grouppedPls);
|
||||
$replyText[] = '*Плейлистов:* ' . $stats['playlists']['all'];
|
||||
$replyText[] = '🟢 Онлайн \- ' . $stats['playlists']['online'];
|
||||
$replyText[] = '🔴 Оффлайн \- ' . $stats['playlists']['offline'];
|
||||
$replyText[] = '⚪ В очереди \- ' . $stats['playlists']['unknown'];
|
||||
$replyText[] = '🔞 Для взрослых \- ' . $stats['playlists']['adult'];
|
||||
$replyText[] = '⏪ С перемоткой \- ' . $stats['playlists']['hasCatchup'];
|
||||
$replyText[] = '🗞️ С телепрограммой \- ' . $stats['playlists']['hasTvg'];
|
||||
$replyText[] = '🗂️ С группировкой каналов \- ' . $stats['playlists']['groupped'];
|
||||
$replyText[] = '';
|
||||
$replyText[] = '*Каналов:* ' . count($allChannels);
|
||||
$replyText[] = '🟢 Онлайн \- ' . count($onlineCh);
|
||||
$replyText[] = '🔴 Оффлайн \- ' . count($offlineCh);
|
||||
$replyText[] = '🔞 Для взрослых \- ' . count($adultCh);
|
||||
$replyText[] = '*Каналов:* ' . $stats['channels']['all'];
|
||||
$replyText[] = '🟢 Онлайн \- ' . $stats['channels']['online'];
|
||||
$replyText[] = '🔴 Оффлайн \- ' . $stats['channels']['offline'];
|
||||
$replyText[] = '🔞 Для взрослых \- ' . $stats['channels']['adult'];
|
||||
$replyText[] = '';
|
||||
$replyText[] = '*Самая свежая проверка* ';
|
||||
$replyText[] = '🕔 ' . $this->escape($stats['playlists']['latest']['timeFmt']);
|
||||
$replyText[] = $this->escape(base_url($stats['playlists']['latest']['code'] . '/details'));
|
||||
$replyText[] = '';
|
||||
$replyText[] = '';
|
||||
|
||||
@@ -433,7 +391,7 @@ class Bot
|
||||
InlineKeyboardMarkup|ReplyKeyboardMarkup|ReplyKeyboardRemove|ForceReply|null $keyboard = null,
|
||||
): bool {
|
||||
try {
|
||||
$this->bot->sendMessage(
|
||||
$this->api->sendMessage(
|
||||
chatId: $this->update->getMessage()->getChat()->getId(),
|
||||
text: $text,
|
||||
parseMode: 'MarkdownV2',
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright (c) 2025, Антон Аксенов
|
||||
* This file is part of iptv.axenov.dev web interface
|
||||
* This file is part of m3u.su project
|
||||
* MIT License: https://git.axenov.dev/IPTV/web/src/branch/master/LICENSE
|
||||
*/
|
||||
|
||||
@@ -31,56 +31,13 @@ class IniFile
|
||||
* Считывает ini-файл и инициализирует плейлисты
|
||||
*
|
||||
* @return array
|
||||
* @throws Exception
|
||||
*/
|
||||
public function load(): array
|
||||
{
|
||||
$filepath = config_path('playlists.ini');
|
||||
$ini = parse_ini_file($filepath, true);
|
||||
$this->playlists = parse_ini_file($filepath, true);
|
||||
$this->updatedAt = date('d.m.Y h:i', filemtime($filepath));
|
||||
|
||||
// сохраняем порядок
|
||||
foreach (array_keys($ini) as $code) {
|
||||
try {
|
||||
$data = @redis()->get($code);
|
||||
} catch (Throwable) {
|
||||
$data = false;
|
||||
}
|
||||
if ($data === false) {
|
||||
$raw = $ini[$code];
|
||||
$data = [
|
||||
'code' => $code,
|
||||
'name' => $raw['name'] ?? "Playlist #$code",
|
||||
'description' => $raw['desc'] ?? null,
|
||||
'url' => $raw['pls'],
|
||||
'source' => $raw['src'] ?? null,
|
||||
'content' => null,
|
||||
'isOnline' => null,
|
||||
'attributes' => [],
|
||||
'groups' => [],
|
||||
'channels' => [],
|
||||
'onlineCount' => 0,
|
||||
'offlineCount' => 0,
|
||||
'checkedAt' => null,
|
||||
];
|
||||
} elseif (!isset($data['attributes'])) {
|
||||
$data['attributes'] = [];
|
||||
}
|
||||
|
||||
$data['hasCatchup'] = str_contains($data['content'] ?? '', 'catchup');
|
||||
$data['hasTvg'] = !empty($data['attributes']['url-tvg'])
|
||||
|| !empty($data['attributes']['x-tvg-url']);
|
||||
|
||||
$data['tags'] = [];
|
||||
foreach ($data['channels'] ?? [] as $channel) {
|
||||
$data['tags'] = array_merge($data['tags'], $channel['tags']);
|
||||
}
|
||||
$data['tags'] = array_values(array_unique($data['tags']));
|
||||
sort($data['tags']);
|
||||
|
||||
$this->playlists[$code] = $data;
|
||||
}
|
||||
|
||||
return $this->playlists;
|
||||
}
|
||||
|
||||
@@ -90,9 +47,32 @@ class IniFile
|
||||
* @return array[]
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getPlaylists(): array
|
||||
public function getPlaylists(array $plsCodes = []): array
|
||||
{
|
||||
return $this->playlists ??= $this->load();
|
||||
$playlists = [];
|
||||
empty($this->playlists) && $this->load();
|
||||
empty($plsCodes) && $plsCodes = array_keys($this->playlists);
|
||||
$cached = array_combine($plsCodes, redis()->mget($plsCodes));
|
||||
foreach ($cached as $code => $data) {
|
||||
$playlists[$code] = $this->initPlaylist($code, $data);
|
||||
}
|
||||
|
||||
return $playlists;
|
||||
}
|
||||
|
||||
/**
|
||||
* Возвращает плейлист по его коду
|
||||
*
|
||||
* @param string $code Код плейлиста
|
||||
* @return array|null
|
||||
* @throws PlaylistNotFoundException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getPlaylist(string $code): ?array
|
||||
{
|
||||
empty($this->playlists) && $this->load();
|
||||
$data = redis()->get($code);
|
||||
return $this->initPlaylist($code, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -106,19 +86,103 @@ class IniFile
|
||||
}
|
||||
|
||||
/**
|
||||
* Возвращает плейлист по его коду
|
||||
* Подготавливает данные о плейлисте в расширенном формате
|
||||
*
|
||||
* @param string $code Код плейлиста
|
||||
* @return array|null
|
||||
* @param string $code
|
||||
* @param array|false $data
|
||||
* @return array
|
||||
* @throws PlaylistNotFoundException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getPlaylist(string $code): ?array
|
||||
protected function initPlaylist(string $code, array|false $data): array
|
||||
{
|
||||
if (empty($this->playlists)) {
|
||||
$this->load();
|
||||
if ($data === false) {
|
||||
$raw = $this->playlists[$code]
|
||||
?? throw new PlaylistNotFoundException($code);
|
||||
$data = [
|
||||
'code' => $code,
|
||||
'name' => $raw['name'] ?? "Плейлист #$code",
|
||||
'description' => $raw['desc'] ?? null,
|
||||
'url' => $raw['pls'],
|
||||
'source' => $raw['src'] ?? null,
|
||||
'content' => null,
|
||||
'isOnline' => null,
|
||||
'attributes' => [],
|
||||
'groups' => [],
|
||||
'channels' => [],
|
||||
'checkedAt' => null,
|
||||
];
|
||||
}
|
||||
|
||||
return $this->playlists[$code] ?? throw new PlaylistNotFoundException($code);
|
||||
// приколы golang
|
||||
$data['attributes'] === null && $data['attributes'] = [];
|
||||
$data['groups'] === null && $data['groups'] = [];
|
||||
$data['channels'] === null && $data['channels'] = [];
|
||||
|
||||
$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']);
|
||||
$data['hasTokens'] = $this->hasTokens($data);
|
||||
|
||||
$data['tags'] = [];
|
||||
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,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright (c) 2025, Антон Аксенов
|
||||
* This file is part of iptv.axenov.dev web interface
|
||||
* This file is part of m3u.su project
|
||||
* MIT License: https://git.axenov.dev/IPTV/web/src/branch/master/LICENSE
|
||||
*/
|
||||
|
||||
|
||||
132
app/Core/StatisticsService.php
Normal file
132
app/Core/StatisticsService.php
Normal file
@@ -0,0 +1,132 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright (c) 2025, Антон Аксенов
|
||||
* This file is part of m3u.su project
|
||||
* MIT License: https://git.axenov.dev/IPTV/web/src/branch/master/LICENSE
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Core;
|
||||
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Обработчик команд бота
|
||||
*/
|
||||
class StatisticsService
|
||||
{
|
||||
/**
|
||||
* @var array[]
|
||||
*/
|
||||
protected array $playlists = [];
|
||||
|
||||
protected array $channels = [];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->playlists = ini()->getPlaylists();
|
||||
$this->channels = $this->getAllChannels();
|
||||
}
|
||||
|
||||
protected function getPlaylistsByField(string $field, int|string|bool|null $value): array
|
||||
{
|
||||
return array_filter(
|
||||
$this->playlists,
|
||||
static fn (array $pls) => $pls[$field] === $value,
|
||||
);
|
||||
}
|
||||
|
||||
protected function getPlaylistsByTag(string $tag): array
|
||||
{
|
||||
return array_filter(
|
||||
$this->playlists,
|
||||
static fn (array $pls) => in_array($tag, $pls['tags']),
|
||||
);
|
||||
}
|
||||
|
||||
protected function getPlaylistsWithGroups(): array
|
||||
{
|
||||
return array_filter(
|
||||
$this->playlists,
|
||||
static fn (array $pls) => !empty($pls['groups']),
|
||||
);
|
||||
}
|
||||
|
||||
protected function getLatestPlaylist(): array
|
||||
{
|
||||
$e = array_combine(
|
||||
array_column($this->playlists, 'code'),
|
||||
array_column($this->playlists, 'checkedAt'),
|
||||
);
|
||||
$e = array_filter($e);
|
||||
asort($e);
|
||||
$latest = array_slice($e, 0, 1);
|
||||
|
||||
return [
|
||||
'code' => array_first(array_keys($latest)),
|
||||
'time' => $time = array_first($latest),
|
||||
'timeFmt' => date('H:i:s d.m.Y', $time),
|
||||
];
|
||||
}
|
||||
|
||||
protected function getAllChannels(): array
|
||||
{
|
||||
$channels = [];
|
||||
foreach ($this->playlists as $pls) {
|
||||
$channels = array_merge($channels, $pls['channels']);
|
||||
}
|
||||
|
||||
return $channels;
|
||||
}
|
||||
|
||||
protected function getAllChannelsCount(): int
|
||||
{
|
||||
return count($this->channels);
|
||||
}
|
||||
|
||||
protected function getChannelsByField(string $field, int|string|bool|null $value): array
|
||||
{
|
||||
return array_filter(
|
||||
$this->channels,
|
||||
static fn (array $channel) => $channel[$field] === $value,
|
||||
);
|
||||
}
|
||||
|
||||
protected function getChannelsByTag(string $tag): array
|
||||
{
|
||||
return array_filter(
|
||||
$this->channels,
|
||||
static fn (array $channel) => in_array($tag, $channel['tags']),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Обрабатывает команду /stats
|
||||
*
|
||||
* @return bool
|
||||
* @throws Exception
|
||||
*/
|
||||
public function get(): array
|
||||
{
|
||||
return [
|
||||
'playlists' => [
|
||||
'all' => count($this->playlists),
|
||||
'online' => count($this->getPlaylistsByField('isOnline', true)),
|
||||
'offline' => count($this->getPlaylistsByField('isOnline', false)),
|
||||
'unknown' => count($this->getPlaylistsByField('isOnline', null)),
|
||||
'adult' => count($this->getPlaylistsByTag('adult')),
|
||||
'hasCatchup' => count($this->getPlaylistsByField('hasCatchup', true)),
|
||||
'hasTvg' => count($this->getPlaylistsByField('hasTvg', true)),
|
||||
'groupped' => count($this->getPlaylistsWithGroups()),
|
||||
'latest' => $this->getLatestPlaylist(),
|
||||
],
|
||||
'channels' => [
|
||||
'all' => $this->getAllChannelsCount(),
|
||||
'online' => count($this->getChannelsByField('isOnline', true)),
|
||||
'offline' => count($this->getChannelsByField('isOnline', false)),
|
||||
'adult' => count($this->getChannelsByTag('adult')),
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright (c) 2025, Антон Аксенов
|
||||
* This file is part of iptv.axenov.dev web interface
|
||||
* This file is part of m3u.su project
|
||||
* MIT License: https://git.axenov.dev/IPTV/web/src/branch/master/LICENSE
|
||||
*/
|
||||
|
||||
@@ -66,17 +66,6 @@ class TwigExtention extends AbstractExtension
|
||||
return base_url($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Возвращает зеркальный URL приложения
|
||||
*
|
||||
* @param string $path
|
||||
* @return string
|
||||
*/
|
||||
public function mirrorUrl(string $path = ''): string
|
||||
{
|
||||
return mirror_url($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Проверячет существование файла
|
||||
*
|
||||
@@ -97,6 +86,6 @@ class TwigExtention extends AbstractExtension
|
||||
*/
|
||||
public function toDate(?float $timestamp, string $format = 'd.m.Y H:i:s'): string
|
||||
{
|
||||
return $timestamp === null ? '(неизвестно)' : date($format, (int)$timestamp);
|
||||
return $timestamp === null ? '' : date($format, (int)$timestamp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright (c) 2025, Антон Аксенов
|
||||
* This file is part of iptv.axenov.dev web interface
|
||||
* This file is part of m3u.su project
|
||||
* MIT License: https://git.axenov.dev/IPTV/web/src/branch/master/LICENSE
|
||||
*/
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright (c) 2025, Антон Аксенов
|
||||
* This file is part of iptv.axenov.dev web interface
|
||||
* This file is part of m3u.su project
|
||||
* MIT License: https://git.axenov.dev/IPTV/web/src/branch/master/LICENSE
|
||||
*/
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright (c) 2025, Антон Аксенов
|
||||
* This file is part of iptv.axenov.dev web interface
|
||||
* This file is part of m3u.su project
|
||||
* MIT License: https://git.axenov.dev/IPTV/web/src/branch/master/LICENSE
|
||||
*/
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright (c) 2025, Антон Аксенов
|
||||
* This file is part of iptv.axenov.dev web interface
|
||||
* This file is part of m3u.su project
|
||||
* MIT License: https://git.axenov.dev/IPTV/web/src/branch/master/LICENSE
|
||||
*/
|
||||
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright (c) 2025, Антон Аксенов
|
||||
* This file is part of iptv.axenov.dev web interface
|
||||
* This file is part of m3u.su project
|
||||
* MIT License: https://git.axenov.dev/IPTV/web/src/branch/master/LICENSE
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
return [
|
||||
'title' => env('APP_TITLE', 'Агрегатор плейлистов'),
|
||||
'base_url' => rtrim(trim(env('APP_URL', 'http://localhost:8080')), '/'),
|
||||
'mirror_url' => rtrim(trim(env('APP_URL_MIRROR') ?? '', '/')),
|
||||
'debug' => bool(env('APP_DEBUG', false)),
|
||||
'env' => env('APP_ENV', env('IPTV_ENV', 'prod')),
|
||||
'title' => 'IPTV Плейлисты',
|
||||
'timezone' => env('APP_TIMEZONE', 'UTC'),
|
||||
'timezone' => env('APP_TIMEZONE', 'GMT'),
|
||||
'page_size' => int(env('PAGE_SIZE', 10)),
|
||||
'repo_url' => env('REPO_URL', 'https://git.axenov.dev/IPTV'),
|
||||
'pls_encodings' => [
|
||||
'UTF-8',
|
||||
'CP1251',
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright (c) 2025, Антон Аксенов
|
||||
* This file is part of iptv.axenov.dev web interface
|
||||
* This file is part of m3u.su project
|
||||
* MIT License: https://git.axenov.dev/IPTV/web/src/branch/master/LICENSE
|
||||
*/
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright (c) 2025, Антон Аксенов
|
||||
* This file is part of iptv.axenov.dev web interface
|
||||
* This file is part of m3u.su project
|
||||
* MIT License: https://git.axenov.dev/IPTV/web/src/branch/master/LICENSE
|
||||
*/
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright (c) 2025, Антон Аксенов
|
||||
* This file is part of iptv.axenov.dev web interface
|
||||
* This file is part of m3u.su project
|
||||
* MIT License: https://git.axenov.dev/IPTV/web/src/branch/master/LICENSE
|
||||
*/
|
||||
|
||||
@@ -67,6 +67,24 @@ return [
|
||||
'handler' => [ApiController::class, 'makeQrCode'],
|
||||
'name' => 'api::makeQrCode',
|
||||
],
|
||||
[
|
||||
'method' => 'GET',
|
||||
'path' => '/api/version',
|
||||
'handler' => [ApiController::class, 'version'],
|
||||
'name' => 'api::version',
|
||||
],
|
||||
[
|
||||
'method' => 'GET',
|
||||
'path' => '/api/health',
|
||||
'handler' => [ApiController::class, 'health'],
|
||||
'name' => 'api::health',
|
||||
],
|
||||
[
|
||||
'method' => 'GET',
|
||||
'path' => '/api/stats',
|
||||
'handler' => [ApiController::class, 'stats'],
|
||||
'name' => 'api::stats',
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright (c) 2025, Антон Аксенов
|
||||
* This file is part of iptv.axenov.dev web interface
|
||||
* This file is part of m3u.su project
|
||||
* MIT License: https://git.axenov.dev/IPTV/web/src/branch/master/LICENSE
|
||||
*/
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 15 KiB |
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright (c) 2025, Антон Аксенов
|
||||
* This file is part of iptv.axenov.dev web interface
|
||||
* This file is part of m3u.su project
|
||||
* MIT License: https://git.axenov.dev/IPTV/web/src/branch/master/LICENSE
|
||||
*/
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{###########################################################################
|
||||
# Copyright (c) 2025, Антон Аксенов
|
||||
# This file is part of iptv.axenov.dev web interface
|
||||
# This file is part of m3u.su project
|
||||
# MIT License: https://git.axenov.dev/IPTV/web/src/branch/master/LICENSE
|
||||
###########################################################################}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
{% block title %}[{{ playlist.code }}] {{ playlist.name }} - {{ config('app.title') }}{% endblock %}
|
||||
|
||||
{% block metadescription %}Смотреть бесплатный самообновляемый плейлист {{ playlist.name }}, посмотреть статус плейлиста {{ playlist.description }}{% endblock %}
|
||||
{% block metadescription %}Смотреть бесплатный самообновляемый плейлист {{ playlist.name }}, проверить статус, {{ playlist.description }}{% endblock %}
|
||||
|
||||
{% block metakeywords %}самообновляемый,бесплатный,iptv-плейлист,iptv,плейлист{% if (playlist.groups|length > 1) %}{% for group in playlist.groups %},{{ group.name|lower }}{% endfor %}{% endif %},{{ playlist.tags|join(',') }}{% endblock %}
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
|
||||
{% block header %}
|
||||
<h2>О плейлисте: {{ playlist.name }}</h2>
|
||||
{% if playlist.isOnline is same as(false) %}
|
||||
{% if playlist.isOnline is same as (false) %}
|
||||
<div class="alert alert-danger small" role="alert">
|
||||
Ошибка плейлиста: {{ playlist.content }}
|
||||
</div>
|
||||
@@ -49,7 +49,7 @@
|
||||
data-bs-toggle="tab"
|
||||
data-bs-target="#tab-data"
|
||||
>
|
||||
<ion-icon name="radio-outline"></ion-icon> Основные данные
|
||||
<ion-icon name="radio-outline"></ion-icon> Основные данные
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item small">
|
||||
@@ -59,7 +59,17 @@
|
||||
data-bs-toggle="tab"
|
||||
data-bs-target="#tab-raw"
|
||||
>
|
||||
<ion-icon name="document-text-outline"></ion-icon> Исходный текст
|
||||
<ion-icon name="document-text-outline"></ion-icon> Исходный текст
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item small">
|
||||
<a class="nav-link"
|
||||
type="button"
|
||||
href="#tab-abuse"
|
||||
data-bs-toggle="tab"
|
||||
data-bs-target="#tab-abuse"
|
||||
>
|
||||
<ion-icon name="wallet-outline"></ion-icon> Правообладателям
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
@@ -70,18 +80,19 @@
|
||||
<tr>
|
||||
<th class="w-25" scope="row">Код</th>
|
||||
<th class="text-break">
|
||||
{% if playlist.isOnline is same as(true) %}
|
||||
<span class="font-monospace text-success">{{ playlist.code }}</span>
|
||||
<span class="badge small text-dark bg-success">онлайн</span>
|
||||
{% elseif playlist.isOnline is same as(false) %}
|
||||
<span class="font-monospace text-danger">{{ playlist.code }}</span>
|
||||
<span class="badge small text-dark bg-danger">оффлайн</span>
|
||||
{% elseif playlist.isOnline is same as(null) %}
|
||||
<span class="font-monospace">{{ playlist.code }}</span>
|
||||
<span class="badge small text-dark bg-secondary" title="Не проверялся">unknown</span>
|
||||
{% endif %}
|
||||
{% if "adult" in playlist.tags %}
|
||||
<span class="badge small bg-warning text-dark" title="Есть каналы для взрослых!">18+</span>
|
||||
<span class="pe-3 font-monospace">{{ playlist.code }}</span>
|
||||
{% if playlist.isOnline is same as (true) %}
|
||||
<span class="cursor-help badge small text-dark bg-success"
|
||||
title="Вероятно, работает"
|
||||
>online</span>
|
||||
{% elseif playlist.isOnline is same as (false) %}
|
||||
<span class="cursor-help badge small text-dark bg-danger"
|
||||
title="Вероятно, не работает"
|
||||
>offline</span>
|
||||
{% elseif playlist.isOnline is same as (null) %}
|
||||
<span class="cursor-help badge small text-dark bg-secondary"
|
||||
title="Не проверялся"
|
||||
>unknown</span>
|
||||
{% endif %}
|
||||
</th>
|
||||
</tr>
|
||||
@@ -92,11 +103,13 @@
|
||||
<tr>
|
||||
<th scope="row">Ccылка для ТВ</th>
|
||||
<td>
|
||||
<b onclick="prompt('Скопируй адрес плейлиста. Если не работает, добавь \'.m3u\' в конец.', '{{ mirror_url(playlist.code) }}')"
|
||||
data-bs-toggle="tooltip"
|
||||
data-bs-placement="top"
|
||||
title="Нажми на ссылку, чтобы скопировать её в буфер обмена"
|
||||
class="font-monospace cursor-pointer text-break">{{ mirror_url(playlist.code) }}</b>
|
||||
<span onclick="copyPlaylistUrl('{{ playlist.code }}')"
|
||||
class="cursor-pointer"
|
||||
title="Нажми на ссылку, чтобы скопировать её в буфер обмена"
|
||||
>
|
||||
<b class="cursor-pointer font-monospace text-break">{{ base_url(playlist.code) }}</b>
|
||||
<ion-icon name="copy-outline"></ion-icon>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -106,16 +119,37 @@
|
||||
<tr>
|
||||
<th scope="row">Наполнение</th>
|
||||
<td class="text-break">
|
||||
<ion-icon name="folder-open-outline"></ion-icon> группы: {{ playlist.groups|length }},
|
||||
<ion-icon name="videocam-outline"></ion-icon> каналы: {{ playlist.channels|length }}
|
||||
(<span class="text-success">{{ playlist.onlineCount }}</span> + <span class="text-danger">{{ playlist.offlineCount }}</span>)
|
||||
{% if playlist.isOnline is same as (true) %}
|
||||
{% if playlist.hasTokens is same as (true) %}
|
||||
<span class="cursor-help badge bg-info text-dark">
|
||||
<ion-icon name="paw"></ion-icon>
|
||||
</span> могут быть нестабильные каналы<br>
|
||||
{% endif %}
|
||||
|
||||
{% if "adult" in playlist.tags %}
|
||||
<span class="cursor-help badge small bg-warning text-dark">18+</span> есть каналы для взрослых<br>
|
||||
{% endif %}
|
||||
|
||||
<ion-icon name="folder-open-outline"></ion-icon> группы: {{ playlist.groups|length }}<br>
|
||||
<ion-icon name="videocam-outline"></ion-icon> каналы:
|
||||
<span class="cursor-help text-success" title="Возможно, рабочие каналы">
|
||||
{{ playlist.onlineCount }} ({{ playlist.onlinePercent }}%)
|
||||
</span>
|
||||
+
|
||||
<span class="cursor-help text-danger" title="Возможно, НЕрабочие каналы">
|
||||
{{ playlist.offlineCount }} ({{ playlist.offlinePercent }}%)
|
||||
</span>
|
||||
= {{ playlist.channels|length }}
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Возможности</th>
|
||||
<td class="text-break">
|
||||
<ion-icon name="newspaper-outline"></ion-icon> Программа передач: {{ playlist.hasTvg ? 'есть' : 'нет' }}<br>
|
||||
<ion-icon name="play-back"></ion-icon> Перемотка (архив): {{ playlist.hasCatchup ? 'есть' : 'нет' }}
|
||||
{% if playlist.isOnline is same as (true) %}
|
||||
<ion-icon name="newspaper-outline"></ion-icon> Программа передач: {{ playlist.hasTvg ? 'есть' : 'нет' }}<br>
|
||||
<ion-icon name="play-back"></ion-icon> Перемотка (архив): {{ playlist.hasCatchup ? 'есть' : 'нет' }}
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="text-secondary">
|
||||
@@ -130,7 +164,7 @@
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
{% if playlist.isOnline is same as(false) %}
|
||||
{% if playlist.isOnline is same as (false) %}
|
||||
<tr class="text-secondary">
|
||||
<th class="w-25" scope="row">Ошибка проверки</th>
|
||||
<td class="text-break">{{ playlist.content }}</td>
|
||||
@@ -186,6 +220,50 @@
|
||||
readonly
|
||||
>{{ playlist.content }}</textarea>
|
||||
</div>
|
||||
<div class="tab-pane fade" id="tab-abuse" tabindex="2">
|
||||
<p class="my-3">
|
||||
Данные, представленные на данной странице, получены автоматически из открыто доступных в
|
||||
интернете IPTV-плейлистов, опубликованных третьими лицами.
|
||||
При наличии технической возможности, источник плейлиста может быть указан на вкладке "Основные
|
||||
данные".
|
||||
</p>
|
||||
<p class="my-3">
|
||||
Сервис {{ base_url() }} не размещает и не транслирует медиаконтент, не создаёт, не призывает
|
||||
использовать и распространять плейлисты третьих лиц, а также не оказывает услуг по ретрансляции
|
||||
телепрограмм.
|
||||
</p>
|
||||
<p class="my-3">
|
||||
Подробности о проекте и о том, как здесь оказались объекты ваших прав,
|
||||
<a href="{{ base_url('docs') }}" target="_blank">читайте здесь</a>.
|
||||
</p>
|
||||
<p class="my-3">
|
||||
Информация о телеканалах (наименования, логотипы, технический статус и другие сведения)
|
||||
формируется исключительно путём обработки содержимого самого плейлиста.
|
||||
Вся информация носит технический и ознакомительный характер, и её достоверность не гарантируется.
|
||||
</p>
|
||||
<p class="my-3">
|
||||
Все права на торговые марки и графические изображения принадлежат их законным владельцам.
|
||||
Если вы являетесь правообладателем и считаете, что сведения на этой странице затрагивают ваши
|
||||
права, вот какие меры вы можете предпринять прямо сейчас:
|
||||
</p>
|
||||
<ul>
|
||||
<li>
|
||||
создать pull-request в открытом репозитории проекта с удалением данных о плейлисте из файла
|
||||
<a href="{{ config('app.repo_url') }}/playlists/src/branch/master/playlists.ini"
|
||||
target="_blank"
|
||||
>playlists.ini</a>, указав в комментарии к коммиту юридически значимую информацию;
|
||||
</li>
|
||||
<li>
|
||||
<a href="{{ config('app.repo_url') }}/playlists/issues/new" target="_blank">создать
|
||||
публичное обращение</a> в открытом репозитории проекта, указав юридически значимую
|
||||
информацию;
|
||||
</li>
|
||||
<li>
|
||||
направить конфиденциальное уведомление на адрес:
|
||||
<a href="mailto:abuse@m3u.su" target="_blank">abuse@m3u.su</a>.
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -230,7 +308,7 @@
|
||||
<div class="input-group">
|
||||
<input type="text"
|
||||
id="search-field"
|
||||
class="form-control form-control-sm border-secondary bg-dark text-light fuzzy-search"
|
||||
class="cursor-help form-control form-control-sm border-secondary bg-dark text-light fuzzy-search"
|
||||
placeholder="Поиск каналов..."
|
||||
title="Начни вводить название"
|
||||
/>
|
||||
@@ -261,7 +339,7 @@
|
||||
for="chfOnline"
|
||||
title="Выбрать только онлайн каналы"
|
||||
>
|
||||
<ion-icon name="radio-button-on-outline"></ion-icon>
|
||||
<ion-icon name="radio-button-on-outline"></ion-icon>{{ playlist.onlineCount }}
|
||||
</label>
|
||||
|
||||
<input type="radio"
|
||||
@@ -275,7 +353,7 @@
|
||||
for="chfOffline"
|
||||
title="Выбрать только оффлайн каналы"
|
||||
>
|
||||
<ion-icon name="radio-button-on-outline"></ion-icon>
|
||||
<ion-icon name="radio-button-on-outline"></ion-icon>{{ playlist.offlineCount }}
|
||||
</label>
|
||||
|
||||
<button type="button"
|
||||
@@ -289,17 +367,17 @@
|
||||
|
||||
<div class="my-3">
|
||||
{% for tag in playlist.tags %}
|
||||
<input type="checkbox"
|
||||
class="btn-check"
|
||||
id="btn-tag-{{ tag }}"
|
||||
data-tag="{{ tag }}"
|
||||
autocomplete="off"
|
||||
onclick="updateFilter()"
|
||||
>
|
||||
<label class="badge btn btn-sm btn-outline-secondary rounded-pill"
|
||||
for="btn-tag-{{ tag }}"
|
||||
title="Нажми для фильтрации каналов по тегу, нажми ещё раз чтобы снять фильтр"
|
||||
>#{{ tag }}</label>
|
||||
<input type="checkbox"
|
||||
class="btn-check"
|
||||
id="btn-tag-{{ tag }}"
|
||||
data-tag="{{ tag }}"
|
||||
autocomplete="off"
|
||||
onclick="updateFilter()"
|
||||
>
|
||||
<label class="badge btn btn-sm btn-outline-secondary rounded-pill"
|
||||
for="btn-tag-{{ tag }}"
|
||||
title="Нажми для фильтрации каналов по тегу, нажми ещё раз чтобы снять фильтр"
|
||||
>#{{ tag }}</label>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
@@ -309,65 +387,86 @@
|
||||
<table id="chlist" class="table table-dark table-hover small">
|
||||
<tbody class="list">
|
||||
{% for channel in playlist.channels %}
|
||||
<tr class="chrow"
|
||||
data-id="{{ channel.id }}"
|
||||
data-group="{{ channel.groupId ?? 'all' }}"
|
||||
data-online="{{ channel.isOnline ? 1 : 0 }}"
|
||||
data-chtags="{{ channel.tags|join('|') }}"
|
||||
title="
HTTP: {{ channel.status ?: '(неизвестно)' }}
Error: {{ channel.error ?: '(нет)' }}"
|
||||
>
|
||||
<td class="chindex">{{ loop.index }}</td>
|
||||
<tr class="chrow"
|
||||
data-id="{{ channel.id }}"
|
||||
data-group="{{ channel.groupId ?? 'all' }}"
|
||||
data-online="{{ channel.isOnline ? 1 : 0 }}"
|
||||
data-chtags="{{ channel.tags|join('|') }}"
|
||||
title="
HTTP: {{ channel.status ?: '(неизвестно)' }}
Error: {{ channel.error ?: '(нет)' }}"
|
||||
>
|
||||
<td class="chindex">{{ loop.index }}</td>
|
||||
|
||||
<td class="chlogo text-center">
|
||||
{% if (channel.attributes['tvg-logo']) %}
|
||||
<img class="tvg-logo"
|
||||
alt="Логотип канала '{{ channel.title }}'"
|
||||
title="Логотип канала '{{ channel.title }}'"
|
||||
src="{{ channel.attributes['tvg-logo'] }}"
|
||||
onerror="setDefaultLogo(this)"
|
||||
/>
|
||||
{% else %}
|
||||
<img class="tvg-logo"
|
||||
alt="Нет логотипа для канала '{{ channel.title }}'"
|
||||
title="Нет логотипа для канала '{{ channel.title }}'"
|
||||
src="/no-tvg-logo.png"
|
||||
/>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="chlogo text-center">
|
||||
{% if (channel.attributes['tvg-logo']) %}
|
||||
<img class="tvg-logo"
|
||||
alt="Логотип канала '{{ channel.title }}'"
|
||||
title="Логотип канала '{{ channel.title }}'"
|
||||
src="{{ channel.attributes['tvg-logo'] }}"
|
||||
onerror="setDefaultLogo(this)"
|
||||
/>
|
||||
{% else %}
|
||||
<img class="tvg-logo"
|
||||
alt="Нет логотипа для канала '{{ channel.title }}'"
|
||||
title="Нет логотипа для канала '{{ channel.title }}'"
|
||||
src="/no-tvg-logo.png"
|
||||
/>
|
||||
{% endif %}
|
||||
</td>
|
||||
|
||||
<td class="text-break">
|
||||
<ion-icon name="radio-button-on-outline"
|
||||
{% if (channel.isOnline) %}
|
||||
class="me-1 text-success"
|
||||
title="Состояние: онлайн"
|
||||
{% else %}
|
||||
class="me-1 text-danger"
|
||||
title="Состояние: оффлайн"
|
||||
{% endif %}
|
||||
<td class="text-break">
|
||||
{% if channel.isOnline is same as (true) %}
|
||||
<ion-icon name="radio-button-on-outline"
|
||||
class="cursor-help me-1 text-success"
|
||||
title="Состояние: онлайн (возможно, работает прямо сейчас)"
|
||||
></ion-icon>
|
||||
{% else %}
|
||||
<ion-icon name="radio-button-on-outline"
|
||||
class="cursor-help me-1 text-danger"
|
||||
title="Состояние: оффлайн (не работал в момент проверки или не удалось проверить)"
|
||||
></ion-icon>
|
||||
{% endif %}
|
||||
|
||||
></ion-icon>{% if "adult" in channel.tags %}
|
||||
<span class="badge small bg-warning text-dark" title="Канал для взрослых!">18+</span>
|
||||
{% endif %}<span class="chname">{{ channel.title }}</span>
|
||||
<div class="text-secondary small">
|
||||
{% if (channel.attributes['tvg-id']) %}
|
||||
<div title="tvg-id">
|
||||
<ion-icon name="star-outline" class="me-1"></ion-icon> {{ channel.attributes['tvg-id'] }}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if (channel.contentType != null) %}
|
||||
<div title="MIME type">
|
||||
<ion-icon name="eye-outline" class="me-1"></ion-icon> {{ channel.contentType }}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if channel.tags|length > 0 %}
|
||||
<ion-icon name="pricetag-outline" class="me-1"></ion-icon>
|
||||
{% for tag in channel.tags %}
|
||||
<span class="chtag">#{{ tag }}</span>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if "adult" in channel.tags %}
|
||||
<span class="badge small bg-warning text-dark"
|
||||
title="Канал для взрослых!"
|
||||
>18+</span>
|
||||
{% endif %}
|
||||
|
||||
{% if channel.hasToken is same as (true) %}
|
||||
<span class="cursor-help badge small bg-info text-dark"
|
||||
title="Может быть нестабилен"
|
||||
>
|
||||
<ion-icon name="paw"></ion-icon>
|
||||
</span>
|
||||
{% endif %}
|
||||
|
||||
<span class="chname">{{ channel.title }}</span>
|
||||
|
||||
<div class="text-secondary small">
|
||||
{% if (channel.attributes['tvg-id']) %}
|
||||
<div title="Идентификатор канала для телепрограммы (tvg-id)" class="cursor-help">
|
||||
<ion-icon name="star-outline" class="me-1"></ion-icon> {{ channel.attributes['tvg-id'] }}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
|
||||
{% if (channel.contentType != null) %}
|
||||
<div title="Тип контента (mime-type)" class="cursor-help">
|
||||
<ion-icon name="eye-outline" class="me-1"></ion-icon> {{ channel.contentType }}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if channel.tags|length > 0 %}
|
||||
<ion-icon name="pricetag-outline"
|
||||
class="cursor-help me-1"
|
||||
title="Теги"
|
||||
></ion-icon>
|
||||
{% for tag in channel.tags %}
|
||||
<span class="chtag">#{{ tag }}</span>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -378,84 +477,84 @@
|
||||
{% endblock %}
|
||||
|
||||
{% block footer %}
|
||||
<script src="/js/list.min.js"></script>
|
||||
<script>
|
||||
const options = {
|
||||
valueNames: [
|
||||
'chname',
|
||||
{data: ['online', 'group', 'tag', 'chtags']}
|
||||
],
|
||||
};
|
||||
<script src="/js/list.min.js"></script>
|
||||
<script>
|
||||
const options = {
|
||||
valueNames: [
|
||||
'chname',
|
||||
{data: ['online', 'group', 'tag', 'chtags']}
|
||||
],
|
||||
};
|
||||
|
||||
const list = new List('chlist', options)
|
||||
list.on('updated', (data) => document.getElementById('chcount').innerText = data.visibleItems.length)
|
||||
document.getElementById('search-field').addEventListener('keyup', (e) => list.search(e.target.value))
|
||||
const list = new List('chlist', options)
|
||||
list.on('updated', (data) => document.getElementById('chcount').innerText = data.visibleItems.length)
|
||||
document.getElementById('search-field').addEventListener('keyup', (e) => list.search(e.target.value))
|
||||
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
const alert = document.getElementById("toomuchalert");
|
||||
!!alert && alert.remove()
|
||||
});
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
const alert = document.getElementById("toomuchalert");
|
||||
!!alert && alert.remove()
|
||||
});
|
||||
|
||||
function savePlaylist() {
|
||||
const link = document.createElement("a");
|
||||
const content = document.getElementById("m3u-raw").value
|
||||
const file = new Blob([content], { type: 'text/plain' });
|
||||
link.href = URL.createObjectURL(file);
|
||||
link.download = "{{ playlist.code }}.m3u8";
|
||||
link.click();
|
||||
URL.revokeObjectURL(link.href);
|
||||
function savePlaylist() {
|
||||
const link = document.createElement("a");
|
||||
const content = document.getElementById("m3u-raw").value
|
||||
const file = new Blob([content], { type: 'text/plain' });
|
||||
link.href = URL.createObjectURL(file);
|
||||
link.download = "{{ playlist.code }}.m3u8";
|
||||
link.click();
|
||||
URL.revokeObjectURL(link.href);
|
||||
}
|
||||
|
||||
function resetGroup() {
|
||||
document.getElementById('groupSelector').value = 'all'
|
||||
updateFilter()
|
||||
}
|
||||
|
||||
function resetSearch() {
|
||||
list.search('')
|
||||
document.getElementById('search-field').value = ''
|
||||
document.getElementById('chfAll').checked = true
|
||||
document.querySelectorAll('input[id*="btn-tag-"]:checked').forEach(tag => tag.checked = false)
|
||||
updateFilter()
|
||||
}
|
||||
|
||||
function updateFilter() {
|
||||
const groupHash = document.getElementById('groupSelector')?.value ?? 'all';
|
||||
const tagsElements = document.querySelectorAll('input[id*="btn-tag-"]:checked')
|
||||
const tagsSelected = []
|
||||
tagsElements.forEach(tag => tagsSelected.push(tag.attributes['data-tag'].value));
|
||||
const activeType = document.querySelector('input[name="chFilter"]:checked').id;
|
||||
switch (activeType) {
|
||||
case 'chfAll':
|
||||
list.filter(item => {
|
||||
const chTags = item.values().chtags.split('|');
|
||||
const isGroupValid = item.values().group === groupHash || groupHash === 'all';
|
||||
const tagsIntersection = tagsSelected.filter(tagSelected => chTags.includes(tagSelected));
|
||||
const hasValidTags = tagsIntersection.length > 0 || tagsSelected.length === 0;
|
||||
return isGroupValid && hasValidTags;
|
||||
})
|
||||
break
|
||||
case 'chfOnline':
|
||||
list.filter(item => {
|
||||
const isOnline = item.values().online === '1'
|
||||
const chTags = item.values().chtags.split('|');
|
||||
const isGroupValid = item.values().group === groupHash || groupHash === 'all';
|
||||
const tagsIntersection = tagsSelected.filter(tagSelected => chTags.includes(tagSelected));
|
||||
const hasValidTags = tagsIntersection.length > 0 || tagsSelected.length === 0;
|
||||
return isGroupValid && isOnline && hasValidTags
|
||||
})
|
||||
break
|
||||
case 'chfOffline':
|
||||
list.filter(item => {
|
||||
const isOffline = item.values().online === '0'
|
||||
const chTags = item.values().chtags.split('|');
|
||||
const isGroupValid = item.values().group === groupHash || groupHash === 'all';
|
||||
const tagsIntersection = tagsSelected.filter(tagSelected => chTags.includes(tagSelected));
|
||||
const hasValidTags = tagsIntersection.length > 0 || tagsSelected.length === 0;
|
||||
return isGroupValid && isOffline && hasValidTags
|
||||
})
|
||||
break
|
||||
}
|
||||
|
||||
function resetGroup() {
|
||||
document.getElementById('groupSelector').value = 'all'
|
||||
updateFilter()
|
||||
}
|
||||
|
||||
function resetSearch() {
|
||||
list.search('')
|
||||
document.getElementById('search-field').value = ''
|
||||
document.getElementById('chfAll').checked = true
|
||||
document.querySelectorAll('input[id*="btn-tag-"]:checked').forEach(tag => tag.checked = false)
|
||||
updateFilter()
|
||||
}
|
||||
|
||||
function updateFilter() {
|
||||
const groupHash = document.getElementById('groupSelector')?.value ?? 'all';
|
||||
const tagsElements = document.querySelectorAll('input[id*="btn-tag-"]:checked')
|
||||
const tagsSelected = []
|
||||
tagsElements.forEach(tag => tagsSelected.push(tag.attributes['data-tag'].value));
|
||||
const activeType = document.querySelector('input[name="chFilter"]:checked').id;
|
||||
switch (activeType) {
|
||||
case 'chfAll':
|
||||
list.filter(item => {
|
||||
const chTags = item.values().chtags.split('|');
|
||||
const isGroupValid = item.values().group === groupHash || groupHash === 'all';
|
||||
const tagsIntersection = tagsSelected.filter(tagSelected => chTags.includes(tagSelected));
|
||||
const hasValidTags = tagsIntersection.length > 0 || tagsSelected.length === 0;
|
||||
return isGroupValid && hasValidTags;
|
||||
})
|
||||
break
|
||||
case 'chfOnline':
|
||||
list.filter(item => {
|
||||
const isOnline = item.values().online === '1'
|
||||
const chTags = item.values().chtags.split('|');
|
||||
const isGroupValid = item.values().group === groupHash || groupHash === 'all';
|
||||
const tagsIntersection = tagsSelected.filter(tagSelected => chTags.includes(tagSelected));
|
||||
const hasValidTags = tagsIntersection.length > 0 || tagsSelected.length === 0;
|
||||
return isGroupValid && isOnline && hasValidTags
|
||||
})
|
||||
break
|
||||
case 'chfOffline':
|
||||
list.filter(item => {
|
||||
const isOffline = item.values().online === '0'
|
||||
const chTags = item.values().chtags.split('|');
|
||||
const isGroupValid = item.values().group === groupHash || groupHash === 'all';
|
||||
const tagsIntersection = tagsSelected.filter(tagSelected => chTags.includes(tagSelected));
|
||||
const hasValidTags = tagsIntersection.length > 0 || tagsSelected.length === 0;
|
||||
return isGroupValid && isOffline && hasValidTags
|
||||
})
|
||||
break
|
||||
}
|
||||
}
|
||||
</script>
|
||||
}
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
||||
122
views/list.twig
122
views/list.twig
@@ -1,6 +1,6 @@
|
||||
{###########################################################################
|
||||
# Copyright (c) 2025, Антон Аксенов
|
||||
# This file is part of iptv.axenov.dev web interface
|
||||
# This file is part of m3u.su project
|
||||
# MIT License: https://git.axenov.dev/IPTV/web/src/branch/master/LICENSE
|
||||
###########################################################################}
|
||||
|
||||
@@ -11,32 +11,27 @@
|
||||
{% block metakeywords %}самообновляемые,бесплатные,iptv-плейлисты,iptv,плейлисты{% endblock %}
|
||||
|
||||
{% block head %}
|
||||
<style>
|
||||
.card {transition: box-shadow .2s, transform .2s}
|
||||
.card.hover-success:hover {transform: translateY(-7px); box-shadow: rgba(var(--bs-success-rgb), 1) 0 5px 20px -5px}
|
||||
.card.hover-danger:hover {transform: translateY(-7px); box-shadow: rgba(var(--bs-danger-rgb), 1) 0 5px 20px -5px}
|
||||
.card.hover-secondary:hover {transform: translateY(-7px); box-shadow: rgba(var(--bs-secondary-rgb), 1) 0 5px 20px -5px}
|
||||
</style>
|
||||
<script>
|
||||
function setDefaultLogo(imgtag) {
|
||||
imgtag.onerror = null
|
||||
imgtag.src = '/no-tvg-logo.png'
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
.card {transition: box-shadow .2s, transform .2s}
|
||||
.card.hover-success:hover {transform: translateY(-7px); box-shadow: rgba(var(--bs-success-rgb), 1) 0 5px 20px -5px}
|
||||
.card.hover-danger:hover {transform: translateY(-7px); box-shadow: rgba(var(--bs-danger-rgb), 1) 0 5px 20px -5px}
|
||||
.card.hover-secondary:hover {transform: translateY(-7px); box-shadow: rgba(var(--bs-secondary-rgb), 1) 0 5px 20px -5px}
|
||||
</style>
|
||||
<script>
|
||||
function setDefaultLogo(imgtag) {
|
||||
imgtag.onerror = null
|
||||
imgtag.src = '/no-tvg-logo.png'
|
||||
}
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
||||
{% block header %}
|
||||
<div class="d-flex flex-wrap justify-content-between align-items-center mb-4">
|
||||
<div class="mb-2">
|
||||
<h2 class="mb-0">Список плейлистов ({{ count }})</h2>
|
||||
<div class="text-muted small">Изменён {{ updatedAt }} МСК</div>
|
||||
</div>
|
||||
<div class="d-flex flex-wrap gap-2 mb-2">
|
||||
<span class="badge bg-success">online: {{ onlineCount }}</span>
|
||||
<span class="badge bg-danger">offline: {{ offlineCount }}</span>
|
||||
<span class="badge bg-secondary">unknown: {{ uncheckedCount }}</span>
|
||||
</div>
|
||||
<div class="d-flex flex-wrap justify-content-between align-items-center mb-4">
|
||||
<div class="mb-2">
|
||||
<h2 class="mb-0">Список плейлистов ({{ count }})</h2>
|
||||
<div class="text-muted small">Изменён {{ updatedAt }} МСК</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
@@ -54,14 +49,37 @@
|
||||
<a href="/{{ code }}/details" class="text-decoration-none">
|
||||
<div class="card-header d-flex align-items-center gap-2">
|
||||
<span class="font-monospace text-{{ statusClass }}">{{ code }}</span>
|
||||
<span class="badge bg-{{ statusClass }} ms-auto">
|
||||
{% 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 %}
|
||||
</span>
|
||||
|
||||
{% if playlist.isOnline is same as(true) %}
|
||||
<span class="cursor-help badge bg-{{ statusClass }} ms-auto"
|
||||
title="Возможно, этот плейлист рабочий"
|
||||
>online</span>
|
||||
{% elseif playlist.isOnline is same as(false) %}
|
||||
<span class="cursor-help badge bg-{{ statusClass }} ms-auto"
|
||||
title="Этот плейлист нерабочий или его не удалось проверить"
|
||||
>offline</span>
|
||||
{% elseif playlist.isOnline is same as(null) %}
|
||||
<span class="cursor-help badge bg-{{ statusClass }} ms-auto"
|
||||
title="Плейлист ещё не проверялся, придётся подождать"
|
||||
>unknown</span>
|
||||
{% endif %}
|
||||
|
||||
{% if playlist.isOnline is same as(true) %}
|
||||
<span class="cursor-help badge border border-success"
|
||||
title="Процент рабочих каналов"
|
||||
>{{ playlist.onlinePercent }}%</span>
|
||||
{% endif %}
|
||||
|
||||
{% if "adult" in playlist.tags %}
|
||||
<span class="badge bg-warning text-dark" title="Есть каналы для взрослых!">18+</span>
|
||||
<span class="cursor-help badge bg-warning text-dark"
|
||||
title="Есть каналы для взрослых!"
|
||||
>18+</span>
|
||||
{% endif %}
|
||||
|
||||
{% if playlist.hasTokens is same as(true) %}
|
||||
<span class="cursor-help badge bg-info text-dark"
|
||||
title="В плейлисте есть каналы, которые могут быть нестабильны"
|
||||
><ion-icon name="paw"></ion-icon></span>
|
||||
{% endif %}
|
||||
</div>
|
||||
</a>
|
||||
@@ -71,39 +89,39 @@
|
||||
<h5 class="card-title text-light">{{ playlist.name }}</h5>
|
||||
</a>
|
||||
{% if playlist.description is not same as(null) %}
|
||||
<p class="card-text small text-secondary d-none d-md-block">{{ playlist.description }}</p>
|
||||
<p class="card-text small text-secondary d-none d-md-block">{{ playlist.description }}</p>
|
||||
{% endif %}
|
||||
<div class="d-flex flex-wrap gap-2 mb-1">
|
||||
{% if playlist.isOnline is not same as(null) %}
|
||||
<span class="badge border border-secondary">
|
||||
<ion-icon name="videocam-outline" class="me-1"></ion-icon> {{ playlist.channels|length }}<span class="d-none d-xl-inline-block"> каналов</span>
|
||||
</span>
|
||||
{% endif %}
|
||||
{% if playlist.groups|length > 0 %}
|
||||
{% if playlist.isOnline is same as(true) %}
|
||||
<span class="badge border border-secondary">
|
||||
<ion-icon name="folder-open-outline" class="me-1"></ion-icon> {{ playlist.groups|length }}<span class="d-none d-xl-inline-block"> групп</span>
|
||||
</span>
|
||||
{% endif %}
|
||||
{% if playlist.hasTvg %}
|
||||
<span class="badge border border-secondary">
|
||||
<ion-icon name="newspaper-outline" class="me-1"></ion-icon><span class="d-none d-xl-inline-block"> ТВ-программа</span>
|
||||
</span>
|
||||
{% endif %}
|
||||
{% if playlist.hasCatchup %}
|
||||
<span class="badge border border-secondary">
|
||||
<ion-icon name="play-back-outline" class="me-1"></ion-icon><span class="d-none d-xl-inline-block"> Архив</span>
|
||||
<ion-icon name="videocam-outline" class="me-1"></ion-icon> {{ playlist.channels|length }}<span class="d-none d-xl-inline-block"> каналов</span>
|
||||
</span>
|
||||
{% if playlist.groups|length > 0 %}
|
||||
<span class="badge border border-secondary">
|
||||
<ion-icon name="folder-open-outline" class="me-1"></ion-icon> {{ playlist.groups|length }}<span class="d-none d-xl-inline-block"> групп</span>
|
||||
</span>
|
||||
{% endif %}
|
||||
{% if playlist.hasTvg %}
|
||||
<span class="badge border border-secondary">
|
||||
<ion-icon name="newspaper-outline" class="me-1"></ion-icon><span class="d-none d-xl-inline-block"> ТВ-программа</span>
|
||||
</span>
|
||||
{% endif %}
|
||||
{% if playlist.hasCatchup %}
|
||||
<span class="badge border border-secondary">
|
||||
<ion-icon name="play-back-outline" class="me-1"></ion-icon><span class="d-none d-xl-inline-block"> Архив</span>
|
||||
</span>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card-footer cursor-pointer"
|
||||
onclick="prompt('Скопируй адрес плейлиста. Если не работает, добавь \'.m3u\' в конец.', '{{ mirror_url(playlist.code) }}')"
|
||||
title="Нажми чтобы скопировать"
|
||||
onclick="copyPlaylistUrl('{{ playlist.code }}')"
|
||||
title="Нажми на ссылку, чтобы скопировать её в буфер обмена"
|
||||
>
|
||||
<div class="d-flex justify-content-between align-items-center small">
|
||||
<span class="font-monospace text-truncate">
|
||||
{{ mirror_url(playlist.code) }}
|
||||
{{ base_url(playlist.code) }}
|
||||
</span>
|
||||
<ion-icon name="copy-outline"></ion-icon>
|
||||
</div>
|
||||
@@ -125,7 +143,7 @@
|
||||
</li>
|
||||
{% else %}
|
||||
<li class="page-item">
|
||||
<a class="page-link bg-dark text-light" href="page/{{ page }}">{{ page }}</a>
|
||||
<a class="page-link bg-dark text-light" href="/page/{{ page }}">{{ page }}</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{###########################################################################
|
||||
# Copyright (c) 2025, Антон Аксенов
|
||||
# This file is part of iptv.axenov.dev web interface
|
||||
# This file is part of m3u.su project
|
||||
# MIT License: https://git.axenov.dev/IPTV/web/src/branch/master/LICENSE
|
||||
###########################################################################}
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
<p class="text-muted small">
|
||||
Если хочешь, чтобы здесь был плейлист, предложи его к добавлению.
|
||||
<br />
|
||||
<a href="https://iptv.axenov.dev/docs/support.html#participate">Как это сделать?</a>
|
||||
<a href="/docs/support.html#participate">Как это сделать?</a>
|
||||
</p>
|
||||
<a class="btn btn-outline-light" href="/" title="На главную">
|
||||
<ion-icon name="list-outline" class="me-1"></ion-icon>Перейти к списку плейлистов
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{###########################################################################
|
||||
# Copyright (c) 2025, Антон Аксенов
|
||||
# This file is part of iptv.axenov.dev web interface
|
||||
# MIT License: https://git.axenov.dev/IPTV/web/src/branch/master/LICENSE
|
||||
# This file is part of m3u.su project
|
||||
# MIT License: {{config('app.repo_url}}/web/src/branch/master/LICENSE
|
||||
###########################################################################}
|
||||
|
||||
<!DOCTYPE html>
|
||||
@@ -13,7 +13,7 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="keywords" content="{% block metakeywords %}{% endblock %}" />
|
||||
<meta http-equiv="x-ua-compatible" content="ie=edge">
|
||||
<style>.cursor-pointer{cursor:pointer}</style>
|
||||
<style>.cursor-pointer{cursor:pointer}.cursor-help{cursor:help}</style>
|
||||
<script async type="module" src="https://unpkg.com/ionicons@7.1.0/dist/ionicons/ionicons.esm.js"></script>
|
||||
<script async nomodule src="https://unpkg.com/ionicons@7.1.0/dist/ionicons/ionicons.js"></script>
|
||||
<link href="/css/bootstrap.min.css" rel="stylesheet">
|
||||
@@ -47,6 +47,11 @@
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="navbarNav">
|
||||
<ul class="navbar-nav ms-auto">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" target="_blank" href="https://status.m3u.su">
|
||||
<ion-icon name="pulse-outline" class="me-1"></ion-icon> Аптайм
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" target="_blank" href="/docs">
|
||||
<ion-icon name="document-text-outline" class="me-1"></ion-icon> Документация
|
||||
@@ -102,7 +107,7 @@
|
||||
<a target="_blank" href="/docs" class="text-light text-decoration-none d-flex align-items-center gap-1">
|
||||
<ion-icon name="document-text-outline"></ion-icon>Документация
|
||||
</a>
|
||||
<a target="_blank" href="https://git.axenov.dev/IPTV" class="text-light text-decoration-none d-flex align-items-center gap-1">
|
||||
<a target="_blank" href="{{ config('app.repo_url') }}" class="text-light text-decoration-none d-flex align-items-center gap-1">
|
||||
<ion-icon name="code-slash-outline"></ion-icon>Исходники
|
||||
</a>
|
||||
<a target="_blank" href="https://axenov.dev" class="text-light text-decoration-none d-flex align-items-center gap-1">
|
||||
@@ -120,7 +125,7 @@
|
||||
</div>
|
||||
<div>
|
||||
<a class="small text-secondary d-inline-flex align-items-center gap-1"
|
||||
href="https://git.axenov.dev/IPTV/web/releases/tag/v{{ version() }}"
|
||||
href="{{ config('app.repo_url') }}/web/releases/tag/v{{ version() }}"
|
||||
target="_blank"
|
||||
>
|
||||
<ion-icon name="pricetag-outline"></ion-icon>v{{ version() }}
|
||||
@@ -132,6 +137,55 @@
|
||||
<script src="/js/bootstrap.bundle.min.js"></script>
|
||||
{% block footer %}{% endblock %}
|
||||
|
||||
<div class="toast-container position-fixed bottom-0 end-0 p-3">
|
||||
<div class="toast align-items-center text-bg-success border-0" role="alert" id="clipboardToast">
|
||||
<div class="d-flex">
|
||||
<div class="toast-body" id="clipboardToastBody"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function showToast(message) {
|
||||
const toastEl = document.getElementById('clipboardToast');
|
||||
const toastBodyEl = document.getElementById('clipboardToastBody');
|
||||
toastBodyEl.innerHTML = message;
|
||||
const toast = new bootstrap.Toast(toastEl, {delay: 5000});
|
||||
toast.show();
|
||||
}
|
||||
|
||||
function copyPlaylistUrl(code) {
|
||||
const url = '{{ base_url() }}/' + code;
|
||||
if (navigator.clipboard && window.isSecureContext) {
|
||||
navigator.clipboard
|
||||
.writeText(url)
|
||||
.then(() => showToast(`Ссылка на плейлист '${code}' скопирована в буфер обмена`))
|
||||
.catch(err => console.error('Failed to copy:', err));
|
||||
} else {
|
||||
try {
|
||||
const textArea = document.createElement("textarea");
|
||||
textArea.value = url;
|
||||
textArea.style.position = "fixed"; // Avoid scrolling to bottom
|
||||
document.body.appendChild(textArea);
|
||||
textArea.focus();
|
||||
textArea.select();
|
||||
|
||||
const successful = document.execCommand('copy');
|
||||
document.body.removeChild(textArea);
|
||||
|
||||
if (successful) {
|
||||
showToast(`Ссылка на плейлист '${code}' скопирована в буфер обмена`);
|
||||
} else {
|
||||
showToast('Ошибка при копировании ссылки', true);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Fallback copy failed:', err);
|
||||
showToast('Ошибка при копировании ссылки', true);
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
{% include("custom.twig") ignore missing %}
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user