Audit : code mort retiré (fonctions jamais utilisées, imports, 83 traductions inutilisées)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YVo1qxKoBQCaMd7Ue8PGbe
This commit is contained in:
28 files changed
+9
-1625
No files matched your search
@@ -283,35 +283,3 @@ export async function refreshAiring(items: MediaItem[], cache: AiringCache, tmdb
|
||||
}
|
||||
return next
|
||||
}
|
||||
|
||||
export interface Novelty {
|
||||
item: MediaItem
|
||||
info: AiringInfo
|
||||
/** Épisodes sortis que je n'ai pas encore vus */
|
||||
unwatched: number
|
||||
kind: 'new_episodes' | 'new_season' | 'upcoming'
|
||||
}
|
||||
|
||||
/** Ce qu'il faut signaler sur l'accueil. */
|
||||
export function novelties(items: MediaItem[], cache: AiringCache): Novelty[] {
|
||||
const out: Novelty[] = []
|
||||
const soon = Date.now() + 14 * 24 * 3600 * 1000
|
||||
for (const item of trackable(items)) {
|
||||
const info = cache[item.id]
|
||||
if (!info) continue
|
||||
const unwatched = Math.max(0, info.aired - item.episodesWatched)
|
||||
// Série terminée depuis (ex. Friends) : les épisodes non vus ne sont pas des nouveautés,
|
||||
// et une « nouvelle saison » n'y est qu'un décalage de numérotation entre TMDB et AniList.
|
||||
if (info.ended) continue
|
||||
if (item.status === 'termine') {
|
||||
// Terminé de mon côté, mais de nouveaux épisodes sont sortis depuis → nouvelle saison
|
||||
if (unwatched > 0 && episodeCap(item) && info.aired > episodeCap(item)!) out.push({ item, info, unwatched, kind: 'new_season' })
|
||||
} else if (unwatched > 0) {
|
||||
out.push({ item, info, unwatched, kind: 'new_episodes' })
|
||||
} else if (info.next && new Date(info.next.date).getTime() < soon) {
|
||||
out.push({ item, info, unwatched: 0, kind: 'upcoming' })
|
||||
}
|
||||
}
|
||||
const order = { new_season: 0, new_episodes: 1, upcoming: 2 }
|
||||
return out.sort((a, b) => order[a.kind] - order[b.kind] || (a.info.next?.date ?? '').localeCompare(b.info.next?.date ?? ''))
|
||||
}
|
||||
@@ -620,43 +620,6 @@ export async function getTmdbCredits(externalId: string, key: string): Promise<C
|
||||
}
|
||||
}
|
||||
|
||||
// ─────────────────────────── Notes du public ───────────────────────────
|
||||
|
||||
/** Note moyenne TMDB d'un film / d'une série (undefined si trop peu de votes). */
|
||||
export async function getTmdbPublicRating(externalId: string, key: string): Promise<number | undefined> {
|
||||
if (!isSafeExternalId(externalId) || !externalId.startsWith('tmdb:')) return undefined
|
||||
const [, kind, id] = externalId.split(':') as ['tmdb', 'movie' | 'tv', string]
|
||||
const d = await tmdbFetch<TmdbDetails>(`/${kind}/${id}`, key)
|
||||
return tmdbPublicRating(d.vote_average, d.vote_count)
|
||||
}
|
||||
|
||||
/** Notes moyennes AniList (sur 10) pour plusieurs animes d'un coup. */
|
||||
export async function getAniListPublicRatings(ids: number[]): Promise<Map<number, number>> {
|
||||
const out = new Map<number, number>()
|
||||
const clean = ids.filter((n) => Number.isInteger(n) && n > 0).slice(0, 500)
|
||||
for (let i = 0; i < clean.length; i += 50) {
|
||||
const res = await fetch(ANILIST, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json', Accept: 'application/json' },
|
||||
referrerPolicy: 'no-referrer',
|
||||
credentials: 'omit',
|
||||
body: JSON.stringify({
|
||||
query: 'query ($ids: [Int]) { Page(perPage: 50) { media(id_in: $ids, type: ANIME) { id averageScore } } }',
|
||||
variables: { ids: clean.slice(i, i + 50) },
|
||||
}),
|
||||
})
|
||||
if (!res.ok) throw new Error(t('err.anilistStatus', { status: res.status }))
|
||||
const json = (await res.json()) as { data?: { Page?: { media?: { id: number; averageScore?: number | null }[] } } }
|
||||
const media = json.data?.Page?.media
|
||||
for (const m of Array.isArray(media) ? media : []) {
|
||||
if (Number.isInteger(m?.id) && typeof m.averageScore === 'number' && m.averageScore > 0 && m.averageScore <= 100) {
|
||||
out.set(m.id, Math.round(m.averageScore) / 10)
|
||||
}
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// ─────────────────────────── Dates de sortie (calendrier) ───────────────────────────
|
||||
|
||||
export interface ReleaseInfo {
|
||||
|
||||
+1
-2
@@ -3,7 +3,7 @@ import type { MediaItem } from '../types'
|
||||
import { loadAiring, trackable, CACHE_EVENT } from './airing'
|
||||
import { getAniListReleases, getTmdbRelease, type ReleaseInfo } from './catalogApi'
|
||||
import { isPlainObject, isSafeExternalId, isSafeId, readStorage, safeDay, safeIso } from './security'
|
||||
import { localDay, todayISO } from './utils'
|
||||
import { localDay } from './utils'
|
||||
|
||||
/**
|
||||
* Calendrier des sorties :
|
||||
@@ -110,4 +110,3 @@ export function calendarEvents(items: MediaItem[], releases: ReleaseCache = load
|
||||
return events.sort((a, b) => a.date.localeCompare(b.date) || a.item.title.localeCompare(b.item.title, locale()))
|
||||
}
|
||||
|
||||
export const isToday = (d: string) => d === todayISO()
|
||||
@@ -19,8 +19,6 @@ export const MAX_REWATCHES = 200
|
||||
export const canTrackRewatch = (item: Pick<MediaItem, 'type' | 'status'> & Partial<Pick<MediaItem, 'seasons' | 'episodesTotal'>>) =>
|
||||
item.status === 'termine' && TYPE_BY_VALUE[item.type].episodic && !!episodeCap(item as MediaItem)
|
||||
|
||||
export const isRewatching = (item: Pick<MediaItem, 'rewatch'>): item is MediaItem & { rewatch: Rewatch } => !!item.rewatch
|
||||
|
||||
/** Nombre total de visionnages (premier + revisionnages terminés). */
|
||||
export const viewCount = (item: Pick<MediaItem, 'status' | 'rewatchDates'>) => (item.status === 'termine' ? 1 : 0) + (item.rewatchDates?.length ?? 0)
|
||||
|
||||
|
||||
@@ -92,11 +92,6 @@ function themeColors(color: string, resolved: Exclude<ThemeMode, 'auto'>): Theme
|
||||
}
|
||||
}
|
||||
|
||||
/** Compat : thème calculé pour le rendu sombre par défaut. */
|
||||
export function themeFromColor(color: string): ThemeColors {
|
||||
return themeColors(color, 'dark')
|
||||
}
|
||||
|
||||
/** Applique le thème à toute l'app (les classes Tailwind lisent ces variables). */
|
||||
export function applyTheme(accentColor: string, mode: ThemeMode) {
|
||||
const resolved: Exclude<ThemeMode, 'auto'> =
|
||||
|
||||
Reference in new issue
Block a user