debug: rohe Discover-Ergebnisse für Neuerscheinungen-Zeitfenster prüfen (Disney+ etc.)

This commit is contained in:
2026-06-20 01:07:34 +02:00
parent 2cf03e71d2
commit 1aacd8a192

View File

@@ -918,6 +918,55 @@ router.get('/streaming/debug-compare/:providerId', authenticate, requireAdmin, a
} catch(e) { res.status(500).json({ error: e.message }); }
});
// Debug: Neuerscheinungen-Discover-Query roh prüfen (ohne Filterung danach)
router.get('/streaming/debug-new/: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 since = (() => {
const d = new Date();
d.setDate(d.getDate() - 21);
return `${d.getFullYear()}-${String(d.getMonth()+1).padStart(2,'0')}-${String(d.getDate()).padStart(2,'0')}`;
})();
const today = (() => {
const d = new Date();
return `${d.getFullYear()}-${String(d.getMonth()+1).padStart(2,'0')}-${String(d.getDate()).padStart(2,'0')}`;
})();
async function raw(mediaKind, sortBy) {
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: sortBy,
...(mediaKind === 'movie'
? { 'primary_release_date.gte': since, 'primary_release_date.lte': today }
: { 'first_air_date.gte': since, 'first_air_date.lte': today }),
};
const data = await tmdb(path, { ...params, page: 1 });
return {
total_results: data.total_results,
sample: (data.results||[]).slice(0,10).map(m => ({
title: m.title||m.name, lang: m.original_language,
vote_count: m.vote_count, popularity: m.popularity,
date: m.release_date||m.first_air_date,
})),
};
}
const [movieByPop, movieByDate, tvByPop, tvByDate] = await Promise.all([
raw('movie', 'popularity.desc'),
raw('movie', 'primary_release_date.desc'),
raw('tv', 'popularity.desc'),
raw('tv', 'first_air_date.desc'),
]);
res.json({ provider: provider.label, since, today, movieByPop, movieByDate, tvByPop, tvByDate });
} catch(e) { res.status(500).json({ error: e.message }); }
});
router.get('/streaming/debug/:providerId', authenticate, requireAdmin, async (req, res) => {
try {
const provider = STREAMING_PROVIDERS.find(p => p.id === req.params.providerId);