fix: Route-Reihenfolge - all-providers vor :providerId, sonst 404
This commit is contained in:
@@ -497,6 +497,24 @@ const STREAMING_PROVIDERS = [
|
|||||||
{ id: 'rtlplus', label: 'RTL+', tmdbId: '421' },
|
{ 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) => {
|
router.get('/streaming/providers', authenticate, (req, res) => {
|
||||||
res.json(STREAMING_PROVIDERS.map(p => ({ id: p.id, label: p.label })));
|
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
|
// 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.get('/settings', authenticate, requireAdmin, (req, res) => res.json({ configured: !!getToken() }));
|
||||||
router.put('/settings', authenticate, requireAdmin, (req, res) => {
|
router.put('/settings', authenticate, requireAdmin, (req, res) => {
|
||||||
const { tmdb_token } = req.body;
|
const { tmdb_token } = req.body;
|
||||||
|
|||||||
Reference in New Issue
Block a user