debug: RTL+ Treffer-Anzahl pro Schwelle/Jahresfilter prüfen

This commit is contained in:
2026-06-19 14:43:10 +02:00
parent 26c753b835
commit 46fe7bc588

View File

@@ -744,6 +744,55 @@ router.post('/favorites/:id/acknowledge', authenticate, requireAdmin, (req, res)
// Admin: ALLE verfügbaren Watch-Provider für Deutschland live von TMDb holen
// Admin: Streaming-Top10-Cache leeren (z.B. nach Logik-Änderungen)
// Debug: rohe TMDb-Treffer pro Anbieter/Schwelle prüfen
router.get('/streaming/debug/:providerId', authenticate, requireAdmin, async (req, res) => {
try {
const provider = STREAMING_PROVIDERS.find(p => p.id === req.params.providerId);
if (!provider) return res.status(404).json({ error: 'Unbekannter Anbieter' });
const minYear = new Date().getFullYear() - 1;
const minDate = `${minYear}-01-01`;
async function countFor(mediaKind, minVotes) {
const path = mediaKind === 'movie' ? '/discover/movie' : '/discover/tv';
const params = {
watch_region: 'DE',
with_watch_providers: provider.tmdbId,
with_watch_monetization_types: 'flatrate',
sort_by: 'popularity.desc',
'vote_count.gte': minVotes,
...(mediaKind === 'movie' ? { 'primary_release_date.gte': minDate } : { 'first_air_date.gte': minDate }),
};
const data = await tmdb(path, { ...params, page: 1 });
return { total_results: data.total_results, total_pages: data.total_pages, sample: (data.results||[]).slice(0,3).map(m=>m.title||m.name) };
}
// Auch OHNE Jahresfilter testen, um zu sehen ob der Jahresfilter das Problem ist
async function countNoYearFilter(mediaKind, minVotes) {
const path = mediaKind === 'movie' ? '/discover/movie' : '/discover/tv';
const params = {
watch_region: 'DE',
with_watch_providers: provider.tmdbId,
with_watch_monetization_types: 'flatrate',
sort_by: 'popularity.desc',
'vote_count.gte': minVotes,
};
const data = await tmdb(path, { ...params, page: 1 });
return { total_results: data.total_results, total_pages: data.total_pages };
}
const [movies300, movies50, movies0, moviesNoYear, tv300, tv50, tv0, tvNoYear] = await Promise.all([
countFor('movie', 300), countFor('movie', 50), countFor('movie', 0), countNoYearFilter('movie', 0),
countFor('tv', 300), countFor('tv', 50), countFor('tv', 0), countNoYearFilter('tv', 0),
]);
res.json({
provider: provider.label, tmdbId: provider.tmdbId, minDate,
movies: { withVotes300: movies300, withVotes50: movies50, withVotes0: movies0, noYearFilter: moviesNoYear },
tv: { withVotes300: tv300, withVotes50: tv50, withVotes0: tv0, noYearFilter: tvNoYear },
});
} catch(e) { res.status(500).json({ error: e.message }); }
});
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 });