fix: TV-Modal, Suche/Favoriten nach Typ getrennt, Pushover korrekte Tabelle
This commit is contained in:
@@ -361,6 +361,39 @@ router.get('/search', authenticate, async (req, res) => {
|
||||
} catch(e) { res.status(500).json({ error: e.message }); }
|
||||
});
|
||||
|
||||
// TV-Serie Detail
|
||||
router.get('/tv/:id', authenticate, async (req, res) => {
|
||||
try {
|
||||
const [detail, genreMap] = await Promise.all([
|
||||
tmdb(`/tv/${req.params.id}`, { append_to_response: 'credits,content_ratings' }),
|
||||
getGenreMap(),
|
||||
]);
|
||||
// FSK aus content_ratings (DE)
|
||||
let fsk = '';
|
||||
const deRating = (detail.content_ratings?.results || []).find(r => r.iso_3166_1 === 'DE');
|
||||
if (deRating?.rating) fsk = deRating.rating;
|
||||
|
||||
res.json({
|
||||
id: detail.id, media_type: 'tv',
|
||||
title: detail.name || detail.original_name,
|
||||
original_title: detail.original_name,
|
||||
tagline: detail.tagline || '',
|
||||
overview: detail.overview,
|
||||
poster_path: detail.poster_path,
|
||||
backdrop_path: detail.backdrop_path,
|
||||
release_date: detail.first_air_date || '',
|
||||
runtime: detail.episode_run_time?.[0] || null,
|
||||
vote_average: detail.vote_average,
|
||||
genres: (detail.genres||[]).map(g=>g.name),
|
||||
fsk,
|
||||
cast: (detail.credits?.cast||[]).slice(0,10).map(c=>({ name:c.name, character:c.character, profile_path:c.profile_path })),
|
||||
number_of_seasons: detail.number_of_seasons,
|
||||
number_of_episodes: detail.number_of_episodes,
|
||||
status: detail.status,
|
||||
});
|
||||
} catch(e) { res.status(500).json({ error: e.message }); }
|
||||
});
|
||||
|
||||
// Modal: TMDb-Daten sofort, xREL via separaten Endpoint
|
||||
router.get('/movie/:id', authenticate, async (req, res) => {
|
||||
try {
|
||||
@@ -496,15 +529,19 @@ router.post('/favorites', authenticate, (req, res) => {
|
||||
|
||||
if (r.changes > 0) {
|
||||
try {
|
||||
const pushToken = db.prepare("SELECT value FROM admin_settings WHERE key='pushover_token'").get()?.value;
|
||||
const pushUser = db.prepare("SELECT value FROM admin_settings WHERE key='pushover_user'").get()?.value;
|
||||
const user = db.prepare('SELECT username FROM users WHERE id=?').get(req.user.id);
|
||||
if (pushToken && pushUser) {
|
||||
// Admin-Pushover-Einstellungen aus pushover_settings Tabelle
|
||||
const adminUser = db.prepare("SELECT id FROM users WHERE role='admin' LIMIT 1").get();
|
||||
const poCfg = adminUser
|
||||
? db.prepare('SELECT user_key, app_token FROM pushover_settings WHERE user_id=?').get(adminUser.id)
|
||||
: null;
|
||||
const user = db.prepare('SELECT username FROM users WHERE id=?').get(req.user.id);
|
||||
if (poCfg?.app_token && poCfg?.user_key) {
|
||||
fetch('https://api.pushover.net/1/messages.json', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
token: pushToken, user: pushUser,
|
||||
token: poCfg.app_token,
|
||||
user: poCfg.user_key,
|
||||
message: `${user?.username || 'Jemand'} hat "${title}" zur Merkliste hinzugefügt`,
|
||||
title: '⭐ Neue Favoriten',
|
||||
priority: 0,
|
||||
|
||||
Reference in New Issue
Block a user