mirror of
https://github.com/jakejarvis/sofa.git
synced 2026-08-29 01:35:39 -04:00
- Change primary argument from TMDB size string (`w500`, `w1280`, etc.) to category name (`posters`, `backdrops`, `stills`, `logos`, `profiles`); optional size override remains as third argument - Update all call sites across services, actions, pages, and route handlers to use the new category-based API - Update image.test.ts to match the new signature and replace size-mapping test descriptions with category-name descriptions
30 lines
796 B
TypeScript
30 lines
796 B
TypeScript
"use server";
|
|
|
|
import { requireSession } from "@/lib/auth/session";
|
|
import { discover } from "@/lib/tmdb/client";
|
|
import { tmdbImageUrl } from "@/lib/tmdb/image";
|
|
|
|
export async function discoverByGenre(
|
|
mediaType: "movie" | "tv",
|
|
genreId: number,
|
|
) {
|
|
await requireSession();
|
|
const results = await discover(mediaType, {
|
|
sort_by: "popularity.desc",
|
|
"vote_count.gte": "50",
|
|
with_genres: String(genreId),
|
|
});
|
|
return results.results
|
|
.filter((r) => r.poster_path)
|
|
.map((r) => ({
|
|
tmdbId: r.id,
|
|
type: mediaType,
|
|
title: (r.title ?? r.name) as string,
|
|
posterPath: tmdbImageUrl(r.poster_path, "posters"),
|
|
releaseDate: (r.release_date ?? r.first_air_date ?? null) as
|
|
| string
|
|
| null,
|
|
voteAverage: r.vote_average,
|
|
}));
|
|
}
|