- docs/store : bannière 1024×500 et 7 captures 1080×1920, en français et en anglais - Coller une liste : « S2E14 » converti aussi quand la fiche ne découpe pas les saisons (taille des saisons demandée à TMDB) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YVo1qxKoBQCaMd7Ue8PGbe
This commit is contained in:
19 files changed
+21
-10
No files matched your search
@@ -99,6 +99,7 @@ export default function ImportTextReview({
|
||||
{editing === e.key && (
|
||||
<Picker
|
||||
initial={e.fullTitle ?? e.title}
|
||||
progressSeason={e.progress?.season}
|
||||
tmdbKey={tmdbKey}
|
||||
onPick={(match) => {
|
||||
onChange(e.key, match)
|
||||
@@ -118,7 +119,7 @@ export default function ImportTextReview({
|
||||
}
|
||||
|
||||
/** Recherche d'un autre titre pour une ligne. */
|
||||
function Picker({ initial, tmdbKey, onPick }: { initial: string; tmdbKey?: string; onPick: (m: Match) => void }) {
|
||||
function Picker({ initial, progressSeason, tmdbKey, onPick }: { initial: string; progressSeason?: number; tmdbKey?: string; onPick: (m: Match) => void }) {
|
||||
const [q, setQ] = useState(initial)
|
||||
const [results, setResults] = useState<SearchResult[]>()
|
||||
const [busy, setBusy] = useState(false)
|
||||
@@ -141,7 +142,7 @@ function Picker({ initial, tmdbKey, onPick }: { initial: string; tmdbKey?: strin
|
||||
const pick = async (r: SearchResult) => {
|
||||
setBusy(true)
|
||||
try {
|
||||
onPick(await matchFor(r, tmdbKey?.trim() || undefined))
|
||||
onPick(await matchFor(r, tmdbKey?.trim() || undefined, progressSeason))
|
||||
} finally {
|
||||
setBusy(false)
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { t } from '../../i18n'
|
||||
import { ANILIST, ANILIST_FIELDS, aniToResult, CLOUD_TMDB, getTmdbDetails, sanitizeMeta, searchAll, tmdbFindExternal, tmdbImportSearch, type AniMedia, type SearchResult } from '../catalogApi'
|
||||
import { ANILIST, ANILIST_FIELDS, aniToResult, CLOUD_TMDB, getTmdbDetails, getTmdbExtras, sanitizeMeta, searchAll, tmdbFindExternal, tmdbImportSearch, type AniMedia, type SearchResult } from '../catalogApi'
|
||||
import type { MediaInput } from '../../types'
|
||||
import { anilistEntries, titleKey, type AniListEntry, type ImportEntry } from './sources'
|
||||
import type { TextEntry } from './textList'
|
||||
@@ -16,6 +16,8 @@ export interface Match {
|
||||
result: SearchResult
|
||||
/** Métadonnées prêtes pour la fiche (titre, type, affiche, saisons…) */
|
||||
meta: Partial<MediaInput>
|
||||
/** Épisodes par saison quand la fiche n'en garde pas (animes) : sert à convertir « S2E14 » */
|
||||
seasonSizes?: number[]
|
||||
}
|
||||
|
||||
export interface Progress {
|
||||
@@ -418,7 +420,7 @@ export function pickTextMatch(list: SearchResult[], e: Pick<TextEntry, 'title' |
|
||||
}
|
||||
|
||||
/** Métadonnées d'un résultat choisi : la fiche TMDB complète (référence, année, durée, saisons…). */
|
||||
export async function matchFor(result: SearchResult, key?: string): Promise<Match> {
|
||||
export async function matchFor(result: SearchResult, key?: string, progressSeason?: number): Promise<Match> {
|
||||
let meta: Partial<MediaInput> = {
|
||||
title: result.title,
|
||||
originalTitle: result.originalTitle,
|
||||
@@ -435,6 +437,14 @@ export async function matchFor(result: SearchResult, key?: string): Promise<Matc
|
||||
})
|
||||
if (details) meta = { ...meta, ...details, poster: result.posterUrl ?? meta.poster }
|
||||
}
|
||||
// « S2E14 » sur un anime : la fiche ne découpe pas en saisons, on demande leur taille
|
||||
if (key && progressSeason && progressSeason > 1 && !meta.seasons?.length && result.externalId.startsWith('tmdb:tv:')) {
|
||||
const extras = await getTmdbExtras(result.externalId, key).catch((err) => {
|
||||
if (isRateError(err)) throw err
|
||||
return undefined
|
||||
})
|
||||
if (extras?.seasons?.length) return { result, meta, seasonSizes: extras.seasons }
|
||||
}
|
||||
return { result, meta }
|
||||
}
|
||||
|
||||
@@ -472,7 +482,7 @@ export async function resolveTextEntries(entries: TextEntry[], opts: ResolveOpti
|
||||
}
|
||||
}
|
||||
if (!pick.result) return
|
||||
found.set(e.key, await withRetry(() => matchFor(pick.result!, key), token, onWait))
|
||||
found.set(e.key, await withRetry(() => matchFor(pick.result!, key, e.progress?.season), token, onWait))
|
||||
if (!pick.sure) unsure.add(e.key)
|
||||
} catch (err) {
|
||||
if (err instanceof CancelledError) throw err
|
||||
@@ -488,7 +498,7 @@ export async function resolveTextEntries(entries: TextEntry[], opts: ResolveOpti
|
||||
/** « S3E12 » → épisodes vus, une fois les saisons connues. */
|
||||
export function withProgress(e: TextEntry, match?: Match): TextEntry {
|
||||
if (!e.progress) return e
|
||||
const seasons = match?.meta.seasons
|
||||
const seasons = match?.meta.seasons?.length ? match.meta.seasons : match?.seasonSizes
|
||||
const { season, episode } = e.progress
|
||||
let watched: number | undefined
|
||||
if (seasons?.length) watched = seasons.slice(0, season - 1).reduce((a, b) => a + b, 0) + episode
|
||||
|
||||
Reference in new issue
Block a user