From 6d9bccef13d089361475e4b3fbbf18d484dd8d60 Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Wed, 18 Mar 2026 15:02:14 +0100 Subject: [PATCH] Last anilist cleanups --- front/src/models/entry.ts | 21 +++++++++++-- front/src/ui/home/news.tsx | 3 ++ front/src/ui/unmatched/index.tsx | 1 - scanner/scanner/identifiers/anilist.py | 41 ++++++++++++++++++-------- 4 files changed, 51 insertions(+), 15 deletions(-) diff --git a/front/src/models/entry.ts b/front/src/models/entry.ts index 2690eead..59816537 100644 --- a/front/src/models/entry.ts +++ b/front/src/models/entry.ts @@ -1,7 +1,6 @@ import { z } from "zod/v4"; import { Show } from "./show"; import { KImage } from "./utils/images"; -import { Metadata } from "./utils/metadata"; import { zdate } from "./utils/utils"; const Base = z.object({ @@ -59,7 +58,25 @@ export const MovieEntry = Base.extend({ kind: z.literal("movie"), tagline: z.string().nullable(), poster: KImage.nullable(), - externalId: Metadata, + externalId: z.record( + z.string(), + z.array( + z.union([ + z.object({ + serieId: z.string(), + season: z.int().nullable(), + episode: z.int(), + link: z.string().nullable(), + label: z.string().optional().nullable(), + }), + z.object({ + dataId: z.string(), + link: z.string().nullable(), + label: z.string().optional().nullable(), + }), + ]), + ), + ), }); export type MovieEntry = z.infer; diff --git a/front/src/ui/home/news.tsx b/front/src/ui/home/news.tsx index ff56ae46..5d352ea5 100644 --- a/front/src/ui/home/news.tsx +++ b/front/src/ui/home/news.tsx @@ -1,6 +1,9 @@ +import { useCallback } from "react"; import { useTranslation } from "react-i18next"; import { EntryBox, entryDisplayNumber } from "~/components/entries"; +import { EntrySelect } from "~/components/entries/select"; import { Entry } from "~/models"; +import { usePopup } from "~/primitives"; import { InfiniteFetch, type QueryIdentifier } from "~/query"; import { EmptyView } from "~/ui/empty-view"; import { Header } from "./genre"; diff --git a/front/src/ui/unmatched/index.tsx b/front/src/ui/unmatched/index.tsx index 94b63433..b5b1b04b 100644 --- a/front/src/ui/unmatched/index.tsx +++ b/front/src/ui/unmatched/index.tsx @@ -10,7 +10,6 @@ import { z } from "zod/v4"; import { ScanRequest, Video } from "~/models"; import { Button, - Container, DottedSeparator, HR, IconButton, diff --git a/scanner/scanner/identifiers/anilist.py b/scanner/scanner/identifiers/anilist.py index ee10afd3..248d0123 100644 --- a/scanner/scanner/identifiers/anilist.py +++ b/scanner/scanner/identifiers/anilist.py @@ -236,6 +236,22 @@ async def identify_anilist(_path: str, guess: Guess) -> Guess: if anime is None: return guess + new_external_id = dict(guess.external_id) + new_external_id[ProviderName.ANIDB] = aid + if anime.tvdbid: + new_external_id[ProviderName.TVDB] = anime.tvdbid + # tmdbtv is for TV series, tmdbid is for standalone movies + if anime.tmdbtv: + new_external_id[ProviderName.TMDB] = anime.tmdbtv + elif anime.tmdbid and "," not in anime.tmdbid: + new_external_id[ProviderName.TMDB] = anime.tmdbid + if anime.imdbid and "," not in anime.imdbid: + new_external_id[ProviderName.IMDB] = anime.imdbid + + # if we don't have a single external id, skip it and use the normal flow + if len(new_external_id) == 1: + return guess + logger.info( "Matched '%s' to AniDB id %s (tvdb=%s, tmdbid=%s)", guess.title, @@ -244,17 +260,18 @@ async def identify_anilist(_path: str, guess: Guess) -> Guess: anime.tmdbid, ) - new_external_id = dict(guess.external_id) - new_external_id[ProviderName.ANIDB] = aid - if anime.tvdbid: - new_external_id[ProviderName.TVDB] = anime.tvdbid - # tmdbtv is for TV series, tmdbid is for standalone movies - if anime.tmdbtv: - new_external_id[ProviderName.TMDB] = anime.tmdbtv - elif anime.tmdbid: - new_external_id[ProviderName.TMDB] = anime.tmdbid - if anime.imdbid: - new_external_id[ProviderName.IMDB] = anime.imdbid + animes = ( + [data.animes[id] for id in data.tvdb_anidb.get(anime.tvdbid, [])] + if anime.tvdbid + else [] + ) + new_title = next( + (x.name for x in animes if x.defaulttvdbseason == 1), + next( + (x.name for x in animes if x.defaulttvdbseason == "a"), + anime.name, + ), + ) new_episodes: list[Guess.Episode] = [] for ep in guess.episodes: @@ -297,7 +314,7 @@ async def identify_anilist(_path: str, guess: Guess) -> Guess: ) return Guess( - title=guess.title, + title=new_title or guess.title, kind=kind, extra_kind=guess.extra_kind, years=guess.years,