Search: server-known videos first with YouTube results appended as they arrive; On server badge on cards the server holds a copy of

This commit is contained in:
Jonathan Sykes
2026-10-15 19:46:16 +08:00
parent 1383e89a25
commit 450dc80488
4 changed files with 49 additions and 10 deletions

View File

@@ -1564,6 +1564,8 @@ function renderCard(v, index, list) {
const card = document.createElement('div');
const isCached = cachedIds.has(v.id);
const isDownloading = downloading.has(v.id);
if (v.onServer) knownServerCachedIds.add(v.id);
const onServer = !isCached && (v.onServer || knownServerCachedIds.has(v.id));
card.className = 'card' + (isCached ? ' cached' : '') + (isDownloading ? ' downloading' : '') + (selectedIds.has(v.id) ? ' selected' : '');
card.dataset.id = v.id;
card._video = v; // read by f7-layout.js swipe actions
@@ -1572,6 +1574,7 @@ function renderCard(v, index, list) {
<div class="thumb">
<img loading="lazy" decoding="async" src="${escapeHtml(v.thumbnail || '')}" alt="" />
${v.duration ? `<span class="dur">${fmtTime(v.duration)}</span>` : ''}
${onServer ? '<span class="server-badge" title="A copy is on the server: starts fast and plays even when YouTube is slow"><svg viewBox="0 0 24 24" aria-hidden="true"><rect x="4" y="4" width="16" height="6" rx="1.5"/><rect x="4" y="14" width="16" height="6" rx="1.5"/><path d="M8 7h.01M8 17h.01"/></svg>On server</span>' : ''}
<span class="saved-badge" title="${isDownloading ? 'Downloading…' : 'Saved offline'}">${MediaIcons.svg('offline', 'badge-offline')}${MediaIcons.svg('progress', 'badge-progress')}</span>
${isDownloading ? '<div class="dl-progress"><div class="dl-bar"></div></div>' : ''}
</div>