418 lines
16 KiB
HTML
418 lines
16 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="de">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>xStream Downloader</title>
|
|
<style>
|
|
* { box-sizing: border-box; margin: 0; padding: 0; }
|
|
body { font-family: -apple-system, sans-serif; background: #1a1a2e; color: #eee; }
|
|
header { background: #16213e; padding: 12px 20px; display: flex; align-items: center; gap: 20px; border-bottom: 1px solid #0f3460; }
|
|
header h1 { color: #e94560; font-size: 1.1rem; }
|
|
header input { flex: 1; max-width: 400px; padding: 8px 12px; border-radius: 6px; border: 1px solid #333; background: #0f3460; color: #fff; }
|
|
header button { padding: 8px 16px; background: #e94560; border: none; border-radius: 6px; color: white; cursor: pointer; }
|
|
#app { display: flex; height: calc(100vh - 52px); }
|
|
#sidebar { width: 200px; background: #16213e; overflow-y: auto; padding: 8px; border-right: 1px solid #0f3460; }
|
|
#sidebar h3 { font-size: 0.75rem; text-transform: uppercase; color: #888; padding: 8px 4px 4px; }
|
|
.site-btn { display: block; width: 100%; padding: 8px 10px; margin: 2px 0; background: transparent; border: 1px solid transparent; border-radius: 6px; color: #ccc; text-align: left; cursor: pointer; font-size: 0.9rem; }
|
|
.site-btn:hover { background: #0f3460; }
|
|
.site-btn.active { background: #e94560; color: white; border-color: #e94560; }
|
|
#main { flex: 1; overflow-y: auto; padding: 16px; }
|
|
#breadcrumb { color: #888; margin-bottom: 16px; font-size: 0.85rem; }
|
|
#breadcrumb span { cursor: pointer; color: #e94560; }
|
|
#breadcrumb span:hover { text-decoration: underline; }
|
|
.entries { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
|
|
.card { background: #16213e; border-radius: 8px; overflow: hidden; cursor: pointer; transition: transform 0.1s; }
|
|
.card:hover { transform: translateY(-2px); }
|
|
.card img { width: 100%; height: 240px; object-fit: cover; background: #0f3460; }
|
|
.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; }
|
|
.hoster-quality { color: #e94560; font-size: 0.8rem; }
|
|
.hoster button { padding: 6px 16px; background: #0f3460; border: 1px solid #e94560; border-radius: 6px; color: #e94560; cursor: pointer; font-size: 0.85rem; }
|
|
.hoster button:hover { background: #e94560; color: white; }
|
|
.hoster button.downloading { background: #e94560; color: white; cursor: not-allowed; }
|
|
#downloads { max-width: 600px; margin: 20px auto; }
|
|
.download-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; background: #16213e; border-radius: 8px; margin: 4px 0; }
|
|
.download-item .name { flex: 1; font-size: 0.9rem; }
|
|
.download-item .progress-bar { flex: 2; height: 6px; background: #333; border-radius: 3px; overflow: hidden; }
|
|
.download-item .progress-bar .fill { height: 100%; background: #e94560; transition: width 0.3s; }
|
|
.download-item .status { font-size: 0.75rem; color: #888; width: 80px; text-align: right; }
|
|
.section-title { color: #e94560; font-size: 1rem; margin-bottom: 12px; cursor: pointer; }
|
|
.loading { text-align: center; padding: 40px; color: #888; }
|
|
.error { background: #3d0000; border: 1px solid #e94560; padding: 12px; border-radius: 8px; margin: 10px 0; }
|
|
.hidden { display: none; }
|
|
.tab-bar { display: flex; gap: 4px; margin-bottom: 16px; }
|
|
.tab { padding: 6px 14px; background: transparent; border: 1px solid #333; border-radius: 6px; color: #888; cursor: pointer; font-size: 0.85rem; }
|
|
.tab.active { background: #e94560; color: white; border-color: #e94560; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<header>
|
|
<h1>🎬 xStream Downloader</h1>
|
|
<input type="text" id="searchInput" placeholder="Film oder Serie suchen..." onkeydown="if(event.key==='Enter')doSearch()">
|
|
<button onclick="doSearch()">🔍</button>
|
|
<button onclick="showDownloads()" style="background:#0f3460;">📥 Downloads</button>
|
|
</header>
|
|
<div id="app">
|
|
<div id="sidebar">
|
|
<h3>📺 Sites</h3>
|
|
<div id="siteList"></div>
|
|
</div>
|
|
<div id="main">
|
|
<div id="breadcrumb"></div>
|
|
<div id="content"></div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
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);
|
|
if (!r.ok) { const e = await r.json(); throw new Error(e.error || 'API error'); }
|
|
return r.json();
|
|
}
|
|
|
|
async function loadSites() {
|
|
try {
|
|
state.sites = await api('/sites');
|
|
// backends response has id already so we just use it directly
|
|
state.sites = state.sites;
|
|
renderSidebar();
|
|
} catch(e) { console.error(e); }
|
|
}
|
|
|
|
function renderSidebar() {
|
|
const el = document.getElementById('siteList');
|
|
el.innerHTML = state.sites.map(s =>
|
|
`<button class="site-btn${state.site && state.site.id === s.id ? ' active' : ''}" onclick="loadSite('${s.id}')">${s.name}</button>`
|
|
).join('');
|
|
}
|
|
|
|
async function loadSite(id) {
|
|
state.site = state.sites.find(s => s.id === id);
|
|
if (!state.site) return;
|
|
state.view = 'site';
|
|
state.entries = [];
|
|
state.hosters = [];
|
|
setBC(['Sites', state.site.name]);
|
|
document.getElementById('content').innerHTML = '<div class="loading">Lade...</div>';
|
|
try {
|
|
const data = await api(`/sites/${id}/entries`);
|
|
state.entries = data.entries || [];
|
|
renderEntries();
|
|
} catch(e) {
|
|
document.getElementById('content').innerHTML = `<div class="error">${e.message}</div>`;
|
|
}
|
|
renderSidebar();
|
|
}
|
|
|
|
function renderEntries() {
|
|
const el = document.getElementById('content');
|
|
if (!state.entries.length) {
|
|
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>` : ''}
|
|
</div>
|
|
</div>`).join('')}</div>`;
|
|
}
|
|
|
|
async function selectEntry(idx) {
|
|
const entry = state.entries[idx];
|
|
state.currentEntry = entry;
|
|
state.hosters = [];
|
|
|
|
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>`;
|
|
}
|
|
}
|
|
}
|
|
|
|
function renderHosters(entry) {
|
|
const el = document.getElementById('content');
|
|
if (!state.hosters.length) {
|
|
el.innerHTML = `<div class="error">Keine Hosters gefunden</div><button class="tab" onclick="loadSite('${state.site.id}')">← Zurück</button>`;
|
|
return;
|
|
}
|
|
el.innerHTML = `
|
|
<div class="hoster-list">
|
|
<h2 class="section-title">⬇️ "${entry.title}" herunterladen</h2>
|
|
${state.hosters.map((h, i) => `
|
|
<div class="hoster">
|
|
<span class="hoster-name">${h.displayedName || h.name}</span>
|
|
${h.quality ? `<span class="hoster-quality">${h.quality}</span>` : ''}
|
|
<button id="dlbtn${i}" onclick="resolveAndDownload(${i}, '${jsEscape(h.link || h.url)}', '${jsEscape(entry.title)}')">⬇ Download</button>
|
|
</div>`).join('')}
|
|
</div>
|
|
<button class="tab" onclick="loadSite('${state.site.id}')">← Zurück</button>
|
|
`;
|
|
}
|
|
|
|
function jsEscape(s) {
|
|
return (s || '').replace(/'/g, "\\'").replace(/"/g, '\\"');
|
|
}
|
|
|
|
|
|
|
|
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(`/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) {
|
|
alert('Fehler beim Laden der Streams: ' + e.message);
|
|
}
|
|
}
|
|
|
|
async function pollDownload(did, idx, title) {
|
|
const btn = document.getElementById(`dlbtn${idx}`);
|
|
const maxWait = 120;
|
|
const start = Date.now();
|
|
async function poll() {
|
|
try {
|
|
const d = await api(`/downloads/${did}`);
|
|
if (d.status === 'complete') {
|
|
btn.textContent = '✅ Fertig';
|
|
downloads[did] = d;
|
|
} else if (d.status === 'error') {
|
|
btn.textContent = '❌ ' + (d.error || 'Fehler');
|
|
btn.title = d.error;
|
|
} else {
|
|
btn.textContent = `📥 ${d.progress}%`;
|
|
if (Date.now() - start < maxWait * 1000) {
|
|
setTimeout(poll, 1000);
|
|
}
|
|
}
|
|
} catch(e) {
|
|
btn.textContent = '❌ API Fehler';
|
|
}
|
|
}
|
|
poll();
|
|
}
|
|
|
|
async function doSearch() {
|
|
const q = document.getElementById('searchInput').value.trim();
|
|
if (!q) return;
|
|
state.view = 'search';
|
|
state.entries = [];
|
|
setBC([`Suche: "${q}"`]);
|
|
document.getElementById('content').innerHTML = '<div class="loading">Suche läuft...</div>';
|
|
|
|
// Global search across all sites
|
|
const results = [];
|
|
const errors = [];
|
|
for (const site of state.sites) {
|
|
try {
|
|
const data = await api(`/sites/${site.id}/search?q=${encodeURIComponent(q)}`);
|
|
if (data.entries && data.entries.length) {
|
|
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) {
|
|
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();
|
|
}
|
|
}
|
|
|
|
async function showDownloads() {
|
|
state.view = 'downloads';
|
|
setBC(['Downloads']);
|
|
const el = document.getElementById('content');
|
|
el.innerHTML = '<div id="downloads"><div class="loading">Lade...</div></div>';
|
|
try {
|
|
const list = await api('/downloads');
|
|
el.innerHTML = `<div id="downloads">
|
|
<h2 class="section-title">📥 Aktive Downloads</h2>
|
|
${list.length ? list.map(d => `
|
|
<div class="download-item">
|
|
<span class="name">${d.title}</span>
|
|
<div class="progress-bar"><div class="fill" style="width:${d.progress}%"></div></div>
|
|
<span class="status">${d.status === 'complete' ? '✅' : d.status === 'error' ? '❌' : d.progress + '%'}</span>
|
|
${d.status === 'complete' ? `<button class="tab" onclick="location.href='/api/downloads/${d.id}/file'">💾 Speichern</button>` : ''}
|
|
</div>`).join('') : '<div class="loading">Keine Downloads</div>'}
|
|
</div>`;
|
|
} catch(e) {
|
|
el.innerHTML = `<div class="error">${e.message}</div>`;
|
|
}
|
|
// Auto-refresh
|
|
if (state.view === 'downloads') setTimeout(showDownloads, 3000);
|
|
}
|
|
|
|
function setBC(parts) {
|
|
const el = document.getElementById('breadcrumb');
|
|
let html = '<span onclick="goHome()">Home</span>';
|
|
let path = '';
|
|
parts.forEach((p, i) => {
|
|
path += '/' + (state.sites.find(s => s.name === p) ? state.sites.find(s => s.name === p).id : '');
|
|
html += ` > <span>${p}</span>`;
|
|
});
|
|
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>';
|
|
}
|
|
|
|
// Init
|
|
loadSites();
|
|
goHome();
|
|
</script>
|
|
</body>
|
|
</html>
|