Initial commit to Gitea

This commit is contained in:
2026-07-07 13:56:09 +02:00
parent 0dd018bbc6
commit 631559f134
13 changed files with 4417 additions and 1915 deletions
+160 -32
View File
@@ -28,6 +28,19 @@ header button { padding: 8px 16px; background: #e94560; border: none; border-rad
.card-body { padding: 10px; }
.card-title { font-size: 0.85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-meta { font-size: 0.75rem; color: #888; margin-top: 4px; }
/* Suchergebnisse Liste */
.search-results { max-width: 700px; margin: 0 auto; }
.entry-list { display: flex; flex-direction: column; gap: 6px; }
.entry-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; background: #16213e; border-radius: 8px; cursor: pointer; transition: background 0.15s; }
.entry-item:hover { background: #1a2744; }
.entry-item .entry-thumb { width: 50px; height: 70px; object-fit: cover; border-radius: 4px; background: #0f3460; flex-shrink: 0; }
.entry-item .entry-thumb.placeholder { display: flex; align-items: center; justify-content: center; font-size: 1.5rem; }
.entry-item .entry-info { flex: 1; min-width: 0; }
.entry-item .entry-title { font-size: 0.95rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entry-item .entry-meta { font-size: 0.75rem; color: #888; margin-top: 4px; display: flex; gap: 10px; }
.entry-item .entry-year { }
.entry-item .entry-site { color: #e94560; }
.entry-item .entry-arrow { color: #888; font-size: 0.8rem; }
.hoster-list { max-width: 500px; margin: 20px auto; }
.hoster { display: flex; align-items: center; gap: 12px; padding: 12px; background: #16213e; border-radius: 8px; margin: 6px 0; }
.hoster-name { flex: 1; font-weight: 600; }
@@ -72,6 +85,8 @@ header button { padding: 8px 16px; background: #e94560; border: none; border-rad
const API = '/api';
let state = { view: 'home', sites: [], site: null, entries: [], hosters: [], currentEntry: null, downloadId: null };
let downloads = {};
// Navigation stack: [{site, entries, breadcrumb}]
let navStack = [];
async function api(url) {
const r = await fetch(API + url);
@@ -82,7 +97,8 @@ async function api(url) {
async function loadSites() {
try {
state.sites = await api('/sites');
state.sites = state.sites.map(s => ({ ...s, id: s.identifier }));
// backends response has id already so we just use it directly
state.sites = state.sites;
renderSidebar();
} catch(e) { console.error(e); }
}
@@ -118,13 +134,36 @@ function renderEntries() {
el.innerHTML = '<div class="loading">Keine Einträge gefunden</div>';
return;
}
// Suchergebnisse als Liste anzeigen
if (state.view === 'search') {
el.innerHTML = `<div class="search-results">
<h2 class="section-title">Suchergebnisse (${state.entries.length})</h2>
<div class="entry-list">
${state.entries.map((e, i) => `
<div class="entry-item" onclick="openSearchResult(${i})">
${e.thumb ? `<img src="${e.thumb}" class="entry-thumb" onerror="this.style.display='none'">` : '<div class="entry-thumb placeholder">🎬</div>'}
<div class="entry-info">
<div class="entry-title">${e.title || 'Unnamed'}</div>
<div class="entry-meta">
${e.year ? `<span class="entry-year">${e.year}</span>` : ''}
${e._site ? `<span class="entry-site">${e._site.name}</span>` : ''}
</div>
</div>
<div class="entry-arrow">▶</div>
</div>`).join('')}
</div>
</div>`;
return;
}
// Normale Kartenansicht
el.innerHTML = `<div class="entries">${state.entries.map(e => `
<div class="card" onclick="selectEntry(${state.entries.indexOf(e)})">
${e.thumb ? `<img src="${e.thumb}" onerror="this.style.display='none'">` : ''}
<div class="card-body">
<div class="card-title">${e.title || 'Unnamed'}</div>
${e.year ? `<div class="card-meta">${e.year}</div>` : ''}
${e.quality ? `<div class="card-meta">${e.quality}</div>` : ''}
</div>
</div>`).join('')}</div>`;
}
@@ -133,16 +172,38 @@ async function selectEntry(idx) {
const entry = state.entries[idx];
state.currentEntry = entry;
state.hosters = [];
setBC([state.site.name, entry.title]);
const el = document.getElementById('content');
el.innerHTML = `<div class="loading">Lade Hosters für "${entry.title}"...</div>`;
try {
const params = new URLSearchParams({ entryUrl: entry.url || '', episode: entry.episode || '' });
const data = await api(`/sites/${state.site.id}/hosters?${params}`);
state.hosters = (data.hosters || []).filter(h => typeof h === 'object');
renderHosters(entry);
} catch(e) {
el.innerHTML = `<div class="error">${e.message}</div>`;
if (entry.isFolder) {
// Folder: aktuellen Stand merken und tiefer navigieren
navStack.push({ site: state.site, entries: [...state.entries] });
const el = document.getElementById('content');
el.innerHTML = `<div class="loading">Lade "${entry.title}"...</div>`;
try {
const encoded = encodeURIComponent(entry.url);
const data = await api(`/sites/${state.site.id}/entries/${encoded}`);
state.entries = data.entries || [];
setBC([state.site.name, entry.title]);
if (state.entries.length === 0) {
el.innerHTML = `<div class="error">Keine Eintraege gefunden</div><button class="tab" onclick="goBack()">← Zurueck</button>`;
} else {
renderEntries();
}
} catch(e) {
el.innerHTML = `<div class="error">${e.message}</div><button class="tab" onclick="goBack()">← Zurueck</button>`;
}
} else {
// Nicht-Folder: Hosters laden
setBC([state.site.name, entry.title]);
const el = document.getElementById('content');
el.innerHTML = `<div class="loading">Lade Hosters für "${entry.title}"...</div>`;
try {
const params = new URLSearchParams({ url: entry.url || '', episode: entry.episode || '' });
const data = await api(`/sites/${state.site.id}/hosters?${params}`);
state.hosters = (data.hosters || []).filter(h => typeof h === 'object');
renderHosters(entry);
} catch(e) {
el.innerHTML = `<div class="error">${e.message}</div><button class="tab" onclick="goBack()">← Zurueck</button>`;
}
}
}
@@ -170,23 +231,43 @@ function jsEscape(s) {
return (s || '').replace(/'/g, "\\'").replace(/"/g, '\\"');
}
async function resolveAndDownload(idx, url, title) {
const btn = document.getElementById(`dlbtn${idx}`);
btn.textContent = '⏳ Warte auf URL...';
btn.classList.add('downloading');
function resolveAndDownload(idx, url, title) {
// Öffnet den Link direkt in einem neuen Tab
const link = url || '';
if (link) {
window.open(link, '_blank');
} else {
alert('Kein Link verfügbar');
}
}
async function openSearchResult(idx) {
const entry = state.entries[idx];
if (!entry) return;
const site = entry._site;
if (!site) {
alert('Site nicht gefunden');
return;
}
// Öffne Link direkt im neuen Tab - lade erst Hosters im Hintergrund
const params = new URLSearchParams({ url: entry.url || '' });
try {
const data = await api(`/resolve?url=${encodeURIComponent(url)}&title=${encodeURIComponent(title)}&download=true`);
if (data.download_id) {
downloads[data.download_id] = { title, progress: 0, status: 'queued' };
btn.textContent = '📥 queued';
pollDownload(data.download_id, idx, title);
} else if (data.resolved) {
window.open(data.resolved, '_blank');
btn.textContent = '✅ Stream';
const data = await api(`/sites/${site.id}/hosters?${params}`);
const hosters = (data.hosters || []).filter(h => typeof h === 'object');
if (hosters.length > 0) {
const link = hosters[0].link || hosters[0].url;
window.open(link, '_blank');
} else {
alert('Keine Streams gefunden für "' + entry.title + '"');
}
} catch(e) {
btn.textContent = '❌ Fehler';
btn.title = e.message;
alert('Fehler beim Laden der Streams: ' + e.message);
}
}
@@ -223,19 +304,49 @@ async function doSearch() {
state.entries = [];
setBC([`Suche: "${q}"`]);
document.getElementById('content').innerHTML = '<div class="loading">Suche läuft...</div>';
// Try global search across all sites by searching each
// Global search across all sites
const results = [];
const errors = [];
for (const site of state.sites) {
try {
const data = await api(`/sites/${site.id}/entries?search=${encodeURIComponent(q)}`);
const data = await api(`/sites/${site.id}/search?q=${encodeURIComponent(q)}`);
if (data.entries && data.entries.length) {
data.entries.forEach(e => e._site = site);
data.entries.forEach(e => {
e._site = site;
// Kein Prefix mehr - Titel kommen sauber zurück
});
results.push(...data.entries);
} else if (data.error) {
errors.push(`${site.name}: ${data.error}`);
}
} catch(e) {}
} catch(e) {
errors.push(`${site.name}: ${e.message}`);
}
}
// Duplikate zusammenfassen (gleiche Titel nur einmal zeigen)
const seen = new Set();
const uniqueResults = [];
for (const r of results) {
const key = r.title.toLowerCase().trim();
if (!seen.has(key)) {
seen.add(key);
uniqueResults.push(r);
}
}
if (results.length === 0) {
document.getElementById('content').innerHTML = `
<div class="error">
<h3>Keine Ergebnisse gefunden</h3>
<p>Versuche einen anderen Suchbegriff</p>
${errors.length ? `<details><summary>Fehler</summary><pre>${errors.join('\n')}</pre></details>` : ''}
</div>`;
} else {
state.entries = uniqueResults;
renderEntries();
}
state.entries = results;
renderEntries();
}
async function showDownloads() {
@@ -273,10 +384,27 @@ function setBC(parts) {
el.innerHTML = html;
}
function goBack() {
if (navStack.length === 0) {
goHome();
return;
}
const prev = navStack.pop();
state.site = prev.site;
state.entries = prev.entries;
state.hosters = [];
state.currentEntry = null;
setBC([state.site.name]);
renderEntries();
}
function goHome() {
state.view = 'home';
state.site = null;
state.entries = [];
state.hosters = [];
state.currentEntry = null;
navStack = [];
setBC([]);
document.getElementById('content').innerHTML = '<div class="loading">Wähle eine Site aus dem Menü oder suche nach einem Film.</div>';
}