Первичная проверка стабильности плейлистов/каналов

This commit is contained in:
2025-10-28 11:32:25 +08:00
parent a93e427bb0
commit 3b0e1d8f18
4 changed files with 282 additions and 182 deletions

View File

@@ -81,17 +81,20 @@
<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="pe-3 font-monospace text-success">{{ playlist.code }}</span>
<span class="badge small text-dark bg-success">online</span>
{% elseif playlist.isOnline is same as(false) %}
<span class="font-monospace text-danger">{{ playlist.code }}</span>
<span class="pe-3 font-monospace text-danger">{{ playlist.code }}</span>
<span class="badge small text-dark bg-danger">offline</span>
{% elseif playlist.isOnline is same as(null) %}
<span class="font-monospace">{{ playlist.code }}</span>
<span class="pe-3 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="cursor-help badge small bg-warning text-dark"
title="Есть каналы для взрослых!"
>18+</span>
{% endif %}
</th>
</tr>
@@ -116,11 +119,20 @@
<tr>
<th scope="row">Наполнение</th>
<td class="text-break">
<ion-icon name="folder-open-outline"></ion-icon>&nbsp;группы:&nbsp;{{ playlist.groups|length }}<br>
<ion-icon name="videocam-outline"></ion-icon>&nbsp;каналы:&nbsp;{{ playlist.channels|length }}:
<span class="text-success"
>{{ playlist.onlineCount }} ({{ playlist.onlinePercent }}%)</span>&nbsp;+&nbsp;<span class="text-danger"
>{{ playlist.offlineCount }} ({{ playlist.offlinePercent }}%)</span>
<ion-icon name="folder-open-outline"></ion-icon>&nbsp;группы: {{ playlist.groups|length }}<br>
<ion-icon name="videocam-outline"></ion-icon>&nbsp;каналы:
<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 }}
{% if playlist.hasTokens is same as (true) %}
<br><ion-icon name="paw" class="text-info"></ion-icon>&nbsp;могут быть нестабильные каналы
{% endif %}
</td>
</tr>
<tr>
@@ -286,7 +298,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="Начни вводить название"
/>
@@ -345,17 +357,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>
@@ -365,65 +377,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="&#010;HTTP: {{ channel.status ?: '(неизвестно)' }}&#010;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="&#010;HTTP: {{ channel.status ?: '(неизвестно)' }}&#010;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>&nbsp;{{ channel.attributes['tvg-id'] }}
</div>
{% endif %}
{% if (channel.contentType != null) %}
<div title="MIME type">
<ion-icon name="eye-outline" class="me-1"></ion-icon>&nbsp;{{ 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>&nbsp;{{ 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>&nbsp;{{ 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>
@@ -434,84 +467,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 %}