- Quatre pages distinctes (Confidentialité, Conditions d'utilisation, Mentions légales, Crédits) et une page 404, au thème « Encre » (clair / sombre selon l'appareil, police Epilogue) ; le logo des anciennes pages affichait encore « Kino » - Crédits : rubrique « Données des œuvres » (TMDB, AniList, JustWatch) qui remplace « Bases de films » - Réglages : retirés « Bases de films » (clé TMDB), « Installer l'application », l'état / bouton de synchro et les petites légendes inutiles - Stats : retirés Statuts, Plateformes, Records, Mes mieux notés et la note de bas de page - Accueil et Stats : plus de sous-titre sous le titre - Code et ~50 textes devenus inutiles retirés (pwa.ts, vérification de clé / proxy TMDB, recommandations) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YVo1qxKoBQCaMd7Ue8PGbe
This commit is contained in:
37 files changed
+275
-1496
No files matched your search
@@ -197,18 +197,6 @@ export async function searchTmdb(query: string, key: string): Promise<SearchResu
|
||||
.filter((r): r is SearchResult => r !== null)
|
||||
}
|
||||
|
||||
/** Titres recommandés par TMDB à partir d'un film / d'une série. */
|
||||
export async function tmdbRecommendations(externalId: string, key: string): Promise<SearchResult[]> {
|
||||
if (!isSafeExternalId(externalId) || !externalId.startsWith('tmdb:')) return []
|
||||
const [, kind, id] = externalId.split(':') as ['tmdb', 'movie' | 'tv', string]
|
||||
const data = await tmdbFetch<{ results: TmdbItem[] }>(`/${kind}/${id}/recommendations`, key)
|
||||
return (Array.isArray(data.results) ? data.results : [])
|
||||
.filter((r) => r.poster_path)
|
||||
.slice(0, 15)
|
||||
.map((r) => tmdbToResult(r, r.media_type === 'movie' || r.media_type === 'tv' ? r.media_type : kind))
|
||||
.filter((r): r is SearchResult => r !== null)
|
||||
}
|
||||
|
||||
interface TmdbDetails {
|
||||
title?: string
|
||||
name?: string
|
||||
@@ -370,16 +358,6 @@ export async function getTmdbSeasonEpisodes(externalId: string, season: number,
|
||||
return list
|
||||
}
|
||||
|
||||
/** Vérifie qu'une clé TMDB fonctionne. */
|
||||
export async function testTmdbKey(key: string): Promise<boolean> {
|
||||
try {
|
||||
await tmdbFetch('/configuration', key)
|
||||
return true
|
||||
} catch {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// ─────────────────────────── AniList ───────────────────────────
|
||||
|
||||
const ANILIST = 'https://graphql.anilist.co'
|
||||
@@ -546,32 +524,6 @@ export async function findTmdbSeries(titles: (string | undefined)[], key: string
|
||||
return undefined
|
||||
}
|
||||
|
||||
/** Animes recommandés par AniList à partir d'un anime. */
|
||||
export async function aniListRecommendations(externalId: string): Promise<SearchResult[]> {
|
||||
if (!isSafeExternalId(externalId) || !externalId.startsWith('anilist:')) return []
|
||||
const id = Number(externalId.split(':')[1])
|
||||
const res = await fetch(ANILIST, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json', Accept: 'application/json' },
|
||||
body: JSON.stringify({
|
||||
query: `query ($id: Int) { Media(id: $id) { recommendations(sort: RATING_DESC, perPage: 15) { nodes { mediaRecommendation { isAdult ${ANILIST_FIELDS} } } } } }`,
|
||||
variables: { id },
|
||||
}),
|
||||
referrerPolicy: 'no-referrer',
|
||||
credentials: 'omit',
|
||||
signal: timeout(),
|
||||
})
|
||||
if (!res.ok) throw new Error(t('err.anilistStatus', { status: res.status }))
|
||||
const json = (await res.json()) as { data?: { Media?: { recommendations?: { nodes?: { mediaRecommendation?: AniMedia | null }[] } } } }
|
||||
const nodes = json.data?.Media?.recommendations?.nodes
|
||||
return (Array.isArray(nodes) ? nodes : [])
|
||||
.map((n) => n.mediaRecommendation)
|
||||
// Pas de contenu adulte (comme la recherche, qui demande isAdult: false)
|
||||
.filter((m): m is AniMedia => !!m && !m.isAdult)
|
||||
.map(aniToResult)
|
||||
.filter((r): r is SearchResult => r !== null)
|
||||
}
|
||||
|
||||
// ─────────────────────────── Générique (pour les affiches partagées) ───────────────────────────
|
||||
|
||||
export interface Credits {
|
||||
|
||||
@@ -47,31 +47,3 @@ export async function tmdbViaCloud<T>(path: string, params: Record<string, strin
|
||||
if (!res.ok) throw new Error(t('err.tmdbStatus', { status: res.status }))
|
||||
return res.json() as Promise<T>
|
||||
}
|
||||
|
||||
export type ProxyState = 'ok' | 'missing-key' | 'not-deployed' | 'offline' | 'error'
|
||||
|
||||
/** Vérifie que le proxy TMDB est déployé et que la clé TMDB est bien enregistrée côté serveur. */
|
||||
export async function checkTmdbProxy(): Promise<ProxyState> {
|
||||
if (!navigator.onLine) return 'offline'
|
||||
try {
|
||||
const path = `/functions/v1/tmdb?${new URLSearchParams({ path: '/configuration' })}`
|
||||
let res: Response
|
||||
try {
|
||||
res = await cloudFetch(path)
|
||||
} catch (e) {
|
||||
// Pas de session valable : ce n'est pas le proxy qui manque, on le teste sans compte (comme la recherche)
|
||||
if (!(e instanceof AuthError)) throw e
|
||||
res = await timedFetch(SUPABASE_URL + path, { headers: { apikey: SUPABASE_ANON_KEY }, credentials: 'omit', referrerPolicy: 'no-referrer' })
|
||||
}
|
||||
if (res.ok) return 'ok'
|
||||
if (res.status === 404) return 'not-deployed'
|
||||
const body = (await res.json().catch(() => ({}))) as { error?: string; status?: number }
|
||||
if (res.status === 500 && body.error?.includes('TMDB_API_KEY')) return 'missing-key'
|
||||
if (res.status === 502 && body.status === 401) return 'missing-key'
|
||||
return 'error'
|
||||
} catch (e) {
|
||||
if (!navigator.onLine) return 'offline'
|
||||
// Échec réseau (fonction absente) ; un serveur qui ne répond pas à temps n'est pas « non déployé »
|
||||
return e instanceof TypeError ? 'not-deployed' : 'error'
|
||||
}
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
import { useEffect, useState } from 'react'
|
||||
|
||||
/** Événement non standard déclenché par le navigateur avant l'invite d'installation. */
|
||||
interface BeforeInstallPromptEvent extends Event {
|
||||
prompt: () => Promise<void>
|
||||
userChoice: Promise<{ outcome: 'accepted' | 'dismissed'; platform: string }>
|
||||
}
|
||||
|
||||
let deferredPrompt: BeforeInstallPromptEvent | null = null
|
||||
const listeners = new Set<() => void>()
|
||||
|
||||
function notify() {
|
||||
listeners.forEach((fn) => fn())
|
||||
}
|
||||
|
||||
if (typeof window !== 'undefined') {
|
||||
window.addEventListener('beforeinstallprompt', (e) => {
|
||||
e.preventDefault()
|
||||
deferredPrompt = e as BeforeInstallPromptEvent
|
||||
notify()
|
||||
})
|
||||
window.addEventListener('appinstalled', () => {
|
||||
deferredPrompt = null
|
||||
notify()
|
||||
})
|
||||
}
|
||||
|
||||
function isStandalone(): boolean {
|
||||
if (typeof window === 'undefined') return false
|
||||
return window.matchMedia?.('(display-mode: standalone)').matches || (navigator as { standalone?: boolean }).standalone === true
|
||||
}
|
||||
|
||||
/** Plateforme, pour expliquer comment ajouter l'app à l'écran d'accueil. */
|
||||
export type Platform = 'ios' | 'android' | 'desktop' | 'other'
|
||||
|
||||
export function detectPlatform(): Platform {
|
||||
if (typeof navigator === 'undefined') return 'other'
|
||||
const ua = navigator.userAgent || ''
|
||||
const touch = navigator.maxTouchPoints ?? 0
|
||||
// iPhone / iPad (iPadOS récent se présente comme « MacIntel » mais avec un écran tactile)
|
||||
if (/iphone|ipod|ipad/i.test(ua) || ((navigator.platform === 'MacIntel' || /Mac/.test(ua)) && touch > 1)) return 'ios'
|
||||
if (/android/i.test(ua)) return 'android'
|
||||
// Ordinateur « classique » : pas d'écran tactile principal
|
||||
if (/windows|macintosh|linux|cros/i.test(ua) && touch <= 1) return 'desktop'
|
||||
return 'other'
|
||||
}
|
||||
|
||||
export function useInstallPrompt(): { canInstall: boolean; installed: boolean; install: () => Promise<boolean> } {
|
||||
const [canInstall, setCanInstall] = useState(() => deferredPrompt !== null)
|
||||
const [installed, setInstalled] = useState(isStandalone)
|
||||
|
||||
useEffect(() => {
|
||||
const update = () => {
|
||||
setCanInstall(deferredPrompt !== null)
|
||||
setInstalled(isStandalone())
|
||||
}
|
||||
listeners.add(update)
|
||||
const mql = window.matchMedia?.('(display-mode: standalone)')
|
||||
mql?.addEventListener?.('change', update)
|
||||
update()
|
||||
return () => {
|
||||
listeners.delete(update)
|
||||
mql?.removeEventListener?.('change', update)
|
||||
}
|
||||
}, [])
|
||||
|
||||
const install = async (): Promise<boolean> => {
|
||||
if (!deferredPrompt) return false
|
||||
const prompt = deferredPrompt
|
||||
deferredPrompt = null
|
||||
notify()
|
||||
await prompt.prompt()
|
||||
const { outcome } = await prompt.userChoice
|
||||
return outcome === 'accepted'
|
||||
}
|
||||
|
||||
return { canInstall, installed, install }
|
||||
}
|
||||
+1
-27
@@ -1,5 +1,5 @@
|
||||
import { locale } from '../i18n'
|
||||
import type { MediaItem, MediaType, WatchStatus } from '../types'
|
||||
import type { MediaItem, MediaType } from '../types'
|
||||
import { episodeCap } from './franchise'
|
||||
import { DEFAULT_FILM_MINUTES, MEDIA_TYPES, STATUSES, TYPE_BY_VALUE } from './constants'
|
||||
|
||||
@@ -52,9 +52,7 @@ export interface LibraryStats {
|
||||
avgRating?: number
|
||||
ratedCount: number
|
||||
byType: (Count & { type: MediaType; completed: number; minutes: number })[]
|
||||
byStatus: (Count & { status: WatchStatus })[]
|
||||
topGenres: Count[]
|
||||
topPlatforms: Count[]
|
||||
/** Répartition des notes : 10 tranches sur l'échelle /10 (0,5–1, 1,5–2, …). */
|
||||
ratingBuckets: number[]
|
||||
completedThisYear: number
|
||||
@@ -70,7 +68,6 @@ function top(map: Map<string, number>, n: number): Count[] {
|
||||
export function computeStats(items: MediaItem[]): LibraryStats {
|
||||
const year = String(new Date().getFullYear())
|
||||
const genres = new Map<string, number>()
|
||||
const platforms = new Map<string, number>()
|
||||
const ratingBuckets = new Array(10).fill(0) as number[]
|
||||
let totalMinutes = 0
|
||||
let episodesWatched = 0
|
||||
@@ -98,7 +95,6 @@ export function computeStats(items: MediaItem[]): LibraryStats {
|
||||
|
||||
if (item.status !== 'a_voir') {
|
||||
for (const g of item.genres) genres.set(g, (genres.get(g) ?? 0) + 1)
|
||||
if (item.platform) platforms.set(item.platform, (platforms.get(item.platform) ?? 0) + 1)
|
||||
}
|
||||
if (item.rating != null && item.rating > 0) {
|
||||
ratingSum += item.rating
|
||||
@@ -117,9 +113,7 @@ export function computeStats(items: MediaItem[]): LibraryStats {
|
||||
avgRating: ratedCount ? ratingSum / ratedCount : undefined,
|
||||
ratedCount,
|
||||
byType,
|
||||
byStatus,
|
||||
topGenres: top(genres, 8),
|
||||
topPlatforms: top(platforms, 6),
|
||||
ratingBuckets,
|
||||
completedThisYear,
|
||||
}
|
||||
@@ -209,23 +203,3 @@ export function countries(items: MediaItem[]): { list: CountryCount[]; missing:
|
||||
return { list, missing }
|
||||
}
|
||||
|
||||
export interface Records {
|
||||
marathon?: { item: MediaItem; episodes: number }
|
||||
longestFilm?: MediaItem
|
||||
bestRated?: MediaItem[]
|
||||
}
|
||||
|
||||
export function records(items: MediaItem[]): Records {
|
||||
const seen = items.filter((i) => i.status !== 'a_voir')
|
||||
const series = seen.filter((i) => TYPE_BY_VALUE[i.type].episodic && i.episodesWatched > 0)
|
||||
const marathonItem = series.sort((a, b) => b.episodesWatched - a.episodesWatched)[0]
|
||||
const films = seen.filter((i) => i.type === 'film' && i.status === 'termine' && i.duration)
|
||||
return {
|
||||
marathon: marathonItem ? { item: marathonItem, episodes: marathonItem.episodesWatched } : undefined,
|
||||
longestFilm: films.sort((a, b) => (b.duration ?? 0) - (a.duration ?? 0))[0],
|
||||
bestRated: seen
|
||||
.filter((i) => (i.rating ?? 0) > 0)
|
||||
.sort((a, b) => (b.rating ?? 0) - (a.rating ?? 0) || (watchDate(b) ?? '').localeCompare(watchDate(a) ?? ''))
|
||||
.slice(0, 12),
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user