mirror of
https://github.com/jakejarvis/sofa.git
synced 2026-08-29 03:55:38 -04:00
Add dynamic color theming from poster art using node-vibrant
Extract dominant colors from movie/TV poster images server-side and use them to create per-title atmospheric effects on detail pages — tinted backdrop gradients, ambient glow orbs, and colored poster shadows. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -2,6 +2,7 @@ import { eq } from "drizzle-orm";
|
||||
import { type NextRequest, NextResponse } from "next/server";
|
||||
import { db } from "@/lib/db/client";
|
||||
import { availabilityOffers, episodes, seasons, titles } from "@/lib/db/schema";
|
||||
import { extractAndStoreColors, parseColorPalette } from "@/lib/services/colors";
|
||||
import { refreshTvChildren } from "@/lib/services/metadata";
|
||||
import { getTvDetails } from "@/lib/tmdb/client";
|
||||
|
||||
@@ -84,8 +85,14 @@ export async function GET(
|
||||
.where(eq(availabilityOffers.titleId, title.id))
|
||||
.all();
|
||||
|
||||
// Lazy color extraction: if no palette yet, fire-and-forget for next load
|
||||
if (!title.colorPalette && title.posterPath) {
|
||||
extractAndStoreColors(title.id, title.posterPath).catch(() => {});
|
||||
}
|
||||
|
||||
return NextResponse.json({
|
||||
...title,
|
||||
colorPalette: parseColorPalette(title.colorPalette),
|
||||
seasons: titleSeasons,
|
||||
availability,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user