diff --git a/backend/controllers/entryController.js b/backend/controllers/entryController.js index a2a761f..551c338 100644 --- a/backend/controllers/entryController.js +++ b/backend/controllers/entryController.js @@ -171,6 +171,30 @@ class EntryController { const data = await tmdbService.fetchEntryData(tmdbId, is_tvserie); if (!data) return res.status(404).json({ message: 'Entry not found on TMDB' }); + // Fetch credits in parallel + const creditsData = await tmdbService.fetchEntryCredits(tmdbId, is_tvserie); + + // Map credits to a shape similar to our Credit model + const credits = []; + if (creditsData?.cast) { + for (const c of creditsData.cast) { + credits.push({ + id: c.credit_id || c.id, + cast_type: 'cast', + character: is_tvserie + ? (c.roles?.[0]?.character || c.character || null) + : (c.character || null), + people_id: c.id, + people: { + id: c.id, + name: c.name || c.original_name, + profile_path: c.profile_path, + tmdb_id: c.id, + }, + }); + } + } + // Normalize to a shape similar to our Entry model const preview = { tmdb_id: data.id, @@ -192,6 +216,7 @@ class EntryController { networks: data.networks || [], homepage: data.homepage || null, imdb_id: data.imdb_id || data.external_ids?.imdb_id || null, + credits, }; res.status(200).json(preview);