fix: Normalized some titles

This commit is contained in:
axtrat
2025-08-25 17:25:12 +02:00
parent eae31420f9
commit 354ba6256a
2 changed files with 18 additions and 8 deletions

View File

@@ -13,5 +13,12 @@
"Azumanga Daiou The Animation": "Azumanga Daioh",
"Mairimashita! Iruma-kun 2nd Season": "Mairimashita! Iruma-kun 2",
"Mairimashita! Iruma-kun 3rd Season": "Mairimashita! Iruma-kun 3"
},
"animeunity": {
"Kaiju No. 8": "Kaiju No.8",
"Naruto Shippuden": "Naruto: Shippuden",
"Psycho-Pass: Sinners of the System Case.1 - Crime and Punishment": "PSYCHO-PASS Sinners of the System: Case.1 Crime and Punishment",
"Psycho-Pass: Sinners of the System Case.2 - First Guardian": "PSYCHO-PASS Sinners of the System: Case.2 First Guardian",
"Psycho-Pass: Sinners of the System Case.3 - On the Other Side of Love and Hate": "PSYCHO-PASS Sinners of the System: Case.3 Beyond the Pale of Vengeance"
}
}

View File

@@ -36,7 +36,7 @@ def map_to_search_result(
return None
return SearchResult(
id=str(data["id"]),
title=get_real_title(data),
title=get_titles(data)[0] if get_titles(data) else "Unknown",
episodes=AnimeEpisodes(
sub=(
list(map(str, range(1, get_episodes_count(data) + 1)))
@@ -49,6 +49,7 @@ def map_to_search_result(
else []
),
),
other_titles=get_titles(data),
score=data["score"],
poster=data["imageurl"],
year=data["date"],
@@ -105,16 +106,18 @@ def map_to_server(
)
def get_real_title(record: dict) -> str:
def get_titles(data: dict) -> list[str]:
"""
Return the most appropriate title from the record.
"""
if record.get("title_eng"):
return record["title_eng"]
elif record.get("title"):
return record["title"]
else:
return record.get("title_it", "")
titles = []
if data.get("title_eng"):
titles.append(data["title_eng"])
if data.get("title"):
titles.append(data["title"])
if data.get("title_it"):
titles.append(data["title_it"])
return titles
def get_episodes_count(record: dict) -> int: