From 70500a43324b9a83462b1dce3aa6c1168f137a0a Mon Sep 17 00:00:00 2001 From: Dicken Date: Fri, 19 Jun 2026 08:26:25 +0200 Subject: [PATCH] fix: Route-Reihenfolge - all-providers vor :providerId, sonst 404 --- backend/src/tools/media/routes.js | 34 ++++++++++++++++--------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/backend/src/tools/media/routes.js b/backend/src/tools/media/routes.js index 4157af4..0c118e8 100644 --- a/backend/src/tools/media/routes.js +++ b/backend/src/tools/media/routes.js @@ -497,6 +497,24 @@ const STREAMING_PROVIDERS = [ { id: 'rtlplus', label: 'RTL+', tmdbId: '421' }, ]; +// Admin: ALLE verfügbaren Watch-Provider für Deutschland live von TMDb holen +// MUSS vor /streaming/:providerId stehen, sonst matched Express "all-providers" als providerId! +router.get('/streaming/all-providers', authenticate, requireAdmin, async (req, res) => { + try { + const [movieProv, tvProv] = await Promise.all([ + tmdb('/watch/providers/movie', { watch_region: 'DE' }), + tmdb('/watch/providers/tv', { watch_region: 'DE' }), + ]); + const merged = {}; + for (const p of [...(movieProv.results||[]), ...(tvProv.results||[])]) { + merged[p.provider_id] = { id: p.provider_id, name: p.provider_name, logo: p.logo_path, + priority: p.display_priorities?.DE ?? p.display_priority ?? 999 }; + } + const list = Object.values(merged).sort((a,b) => a.priority - b.priority); + res.json(list); + } catch(e) { res.status(500).json({ error: e.message }); } +}); + router.get('/streaming/providers', authenticate, (req, res) => { res.json(STREAMING_PROVIDERS.map(p => ({ id: p.id, label: p.label }))); }); @@ -652,22 +670,6 @@ router.post('/favorites/:id/acknowledge', authenticate, requireAdmin, (req, res) }); // Admin: ALLE verfügbaren Watch-Provider für Deutschland live von TMDb holen -router.get('/streaming/all-providers', authenticate, requireAdmin, async (req, res) => { - try { - const [movieProv, tvProv] = await Promise.all([ - tmdb('/watch/providers/movie', { watch_region: 'DE' }), - tmdb('/watch/providers/tv', { watch_region: 'DE' }), - ]); - const merged = {}; - for (const p of [...(movieProv.results||[]), ...(tvProv.results||[])]) { - merged[p.provider_id] = { id: p.provider_id, name: p.provider_name, logo: p.logo_path, - priority: p.display_priorities?.DE ?? p.display_priority ?? 999 }; - } - const list = Object.values(merged).sort((a,b) => a.priority - b.priority); - res.json(list); - } catch(e) { res.status(500).json({ error: e.message }); } -}); - router.get('/settings', authenticate, requireAdmin, (req, res) => res.json({ configured: !!getToken() })); router.put('/settings', authenticate, requireAdmin, (req, res) => { const { tmdb_token } = req.body;