stuff and character update

This commit is contained in:
2026-05-23 21:43:16 +02:00
parent a04c052388
commit 067ca89f48
2 changed files with 122 additions and 17 deletions
+27 -14
View File
@@ -230,11 +230,14 @@ class MALResolver:
# ------------------------------------------------------------------
def get_staff_detailed(self, mal_id: "int | None") -> list[dict]:
"""
Returns detailed staff entries for a manga:
Returns detailed staff (author) entries for a manga:
[{mal_id, name, image_url, positions, about=None}, ...]
`about` is not populated here; call get_person_details(person_mal_id)
to fetch it lazily when needed.
Jikan has no `/manga/{id}/staff` endpoint — that route only exists for
anime. For manga the authors are listed on `/manga/{id}` under
`data.authors`, but each entry only has {mal_id, name, url}; the image
URL is fetched lazily via get_person_details (cached, so the later
description fetch is free).
"""
if mal_id is None:
return []
@@ -242,28 +245,29 @@ class MALResolver:
return self._staff_detailed_cache[mal_id]
try:
data = self._get(f"{self.JIKAN_BASE}/manga/{mal_id}/staff")
entries = data.get("data") or []
data = self._get(f"{self.JIKAN_BASE}/manga/{mal_id}")
entry = data.get("data") or {}
except requests.RequestException:
return []
results = []
for entry in entries:
person = entry.get("person") or {}
raw_name = person.get("name") or ""
if not raw_name:
for author in (entry.get("authors") or []):
raw_name = author.get("name") or ""
person_mal_id = author.get("mal_id")
if not raw_name or person_mal_id is None:
continue
jpg = (person.get("images") or {}).get("jpg") or {}
details = self.get_person_details(person_mal_id) or {}
results.append({
"mal_id": person.get("mal_id"),
"mal_id": person_mal_id,
"name": _clean_mal_name(raw_name),
"raw_name": raw_name,
"image_url": jpg.get("image_url") or jpg.get("small_image_url"),
"positions": entry.get("positions") or [],
"image_url": details.get("image_url"),
"positions": [],
"about": None,
})
self._staff_detailed_cache[mal_id] = results
if results:
self._staff_detailed_cache[mal_id] = results
return results
# ------------------------------------------------------------------
@@ -291,6 +295,9 @@ class MALResolver:
"name": entry.get("name") or "",
"image_url": jpg.get("image_url") or jpg.get("small_image_url"),
"about": entry.get("about"),
"favorites": entry.get("favorites"),
"url": (entry.get("url")
or f"https://myanimelist.net/character/{char_mal_id}"),
}
self._char_info_cache[char_mal_id] = result
return result
@@ -315,9 +322,15 @@ class MALResolver:
result = {
"mal_id": entry.get("mal_id"),
"name": entry.get("name") or "",
"given_name": entry.get("given_name"),
"family_name": entry.get("family_name"),
"birthday": entry.get("birthday"),
"image_url": jpg.get("image_url") or jpg.get("small_image_url"),
"about": entry.get("about"),
"favorites": entry.get("favorites"),
"website_url": entry.get("website_url"),
"url": (entry.get("url")
or f"https://myanimelist.net/people/{person_mal_id}"),
}
self._person_info_cache[person_mal_id] = result
return result