mirror of
https://github.com/zoriya/Kyoo.git
synced 2026-03-23 01:47:50 -04:00
Last anilist cleanups
This commit is contained in:
parent
d3ca4da166
commit
6d9bccef13
@ -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<typeof MovieEntry>;
|
||||
|
||||
|
||||
@ -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";
|
||||
|
||||
@ -10,7 +10,6 @@ import { z } from "zod/v4";
|
||||
import { ScanRequest, Video } from "~/models";
|
||||
import {
|
||||
Button,
|
||||
Container,
|
||||
DottedSeparator,
|
||||
HR,
|
||||
IconButton,
|
||||
|
||||
@ -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,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user