From 46fe7bc588f545632f939fe182285c071c1ee531 Mon Sep 17 00:00:00 2001 From: Dicken Date: Fri, 19 Jun 2026 14:43:10 +0200 Subject: [PATCH] =?UTF-8?q?debug:=20RTL+=20Treffer-Anzahl=20pro=20Schwelle?= =?UTF-8?q?/Jahresfilter=20pr=C3=BCfen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/tools/media/routes.js | 49 +++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/backend/src/tools/media/routes.js b/backend/src/tools/media/routes.js index 99a9c4b..c0c3420 100644 --- a/backend/src/tools/media/routes.js +++ b/backend/src/tools/media/routes.js @@ -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 });