feat: initial project

This commit is contained in:
MasutaYunikon committed 2026-03-10 22:36:34 +01:00
commit eaf01cfc59
38 files changed
+5807

No files matched your search

+80
View File
@@ -0,0 +1,80 @@
const BASE = '/api'
export interface Production {
id: number
name: string
description: string
kaieur: string
cover: string | null
background: string | null
banner: string | null
status: string
torrents: string | null
multi: number
link: string
episodes_count: number
}
export interface Episode {
id: number
serie_id: number
season_id: number
name: string
number: number
cover: string | null
duration: string
description: string
episodes: string
path_jap: string | null
path_fr: string | null
}
export interface Season {
id: number
serie_id: number
name: string
number: number
cover: string | null
episodes: Episode[]
}
export interface ProductionDetail extends Production {
seasons: Season[]
episodes: Episode[]
}
export interface Torrent {
name: string
url: string
}
// Parse "Nom@url|Nom@url" → Torrent[]
export function parseTorrents(raw: string | null): Torrent[] {
if (!raw) return []
return raw.split('|').flatMap(item => {
const parts = item.split('@')
if (parts.length !== 2) return []
return [{ name: parts[0] as string, url: parts[1] as string }]
})
}
// Préfixe les images relatives
export function imageUrl(path: string | null): string | null {
if (!path) return null
const encoded = encodeURIComponent(`https://api.fankai.fr${path}`)
return `https://fankai.fr/_next/image?url=${encoded}&w=640&q=100`
}
export async function fetchProductions(): Promise<Production[]> {
const res = await fetch(`${BASE}/productions`)
if (!res.ok) throw new Error('Erreur chargement catalogue')
const data = await res.json()
return data.pageProps.data
}
export async function fetchProduction(id: number, name: string): Promise<ProductionDetail> {
const res = await fetch(`${BASE}/productions/${id}?name=${encodeURIComponent(name)}`)
if (!res.ok) throw new Error('Erreur chargement production')
const data = await res.json()
return data.pageProps.data
}