debug: Tudum-Fetch und Regex-Parsing-Ergebnis prüfen

This commit is contained in:
2026-06-19 22:15:29 +02:00
parent 03043fc8ba
commit 7f470070d9

View File

@@ -945,6 +945,37 @@ router.get('/streaming/debug/:providerId', authenticate, requireAdmin, async (re
} catch(e) { res.status(500).json({ error: e.message }); }
});
// Debug: rohen Tudum-Abruf + Parsing-Ergebnis prüfen
router.get('/streaming/debug-tudum/:mediaKind', authenticate, requireAdmin, async (req, res) => {
const mediaKind = req.params.mediaKind === 'tv' ? 'tv' : 'movie';
try {
const path = mediaKind === 'tv' ? '/germany/tv' : '/germany';
const resp = await fetch(`https://www.netflix.com/tudum/top10${path}`, {
headers: { 'User-Agent': 'Mozilla/5.0 (compatible; DickenDock/1.0)' },
signal: AbortSignal.timeout(8000),
});
const html = await resp.text();
const tableSection = html.split(/Top 10 (?:Shows|Movies) in Germany overview/i)[1] || '';
const lineMatches = [...tableSection.matchAll(/\|\s*(\d{2})!\[[^\]]*\]\([^)]*\)([^|]+?)\s*\|\s*(\d+)\s*\|/g)];
const altMatches = [...html.matchAll(/!\[([^\]]+?)(?::\s*(?:Limited Series|Season \d+))?\]\([^)]*\)[\s\S]{0,80}?#(\d{1,2}) in (?:Shows|Movies)/g)];
res.json({
httpStatus: resp.status,
htmlLength: html.length,
hasOverviewSection: tableSection.length > 0,
tableSectionPreview: tableSection.slice(0, 500),
lineMatchesCount: lineMatches.length,
lineMatchesSample: lineMatches.slice(0, 3).map(m => ({ rank: m[1], title: m[2], weeks: m[3] })),
altMatchesCount: altMatches.length,
altMatchesSample: altMatches.slice(0, 5).map(m => ({ title: m[1], rank: m[2] })),
});
} catch (e) {
res.status(500).json({ error: e.message, stack: e.stack });
}
});
router.post('/streaming/clear-cache', authenticate, requireAdmin, (req, res) => {
const r = db.prepare("DELETE FROM xrel_cache WHERE cache_key LIKE 'streaming-top10:%'").run();
res.json({ ok: true, cleared: r.changes });