more fix for goodreads and bamgumi

This commit is contained in:
Your Name 2024-07-16 22:55:29 -04:00 committed by Henri Dickson
parent a89aef2538
commit f52ff02023
2 changed files with 20 additions and 10 deletions

View file

@ -75,7 +75,11 @@ class Bangumi(AbstractSite):
v = i["value"]
match k:
case "别名":
other_title = [d["v"] for d in v] if type(v) == list else v
other_title = (
[d["v"] for d in v]
if type(v) == list
else ([v] if isinstance(v, str) else [])
)
case "imdb_id":
imdb_code = v
case "isbn":
@ -87,12 +91,20 @@ class Bangumi(AbstractSite):
case "导演":
director = v
case "作者":
authors = [d["v"] for d in v] if type(v) == list else v
authors = (
[d["v"] for d in v]
if type(v) == list
else ([v] if isinstance(v, str) else [])
)
case "平台":
platform = [d["v"] for d in v] if type(v) == list else v
platform = (
[d["v"] for d in v]
if type(v) == list
else ([v] if isinstance(v, str) else [])
)
case "游戏类型":
genre = (
[i["v"] for i in v]
[d["v"] for d in v]
if isinstance(v, list)
else ([v] if isinstance(v, str) else [])
)

View file

@ -74,14 +74,12 @@ class Goodreads(AbstractSite):
lang = detect_language(b["title"] + " " + data["brief"])
data["localized_title"] = [{"lang": lang, "text": b["title"]}]
data["localized_subtitle"] = [] # Goodreads does not support subtitle
if data["brief"]:
data["brief"] = html_to_text(data["brief"])
data["localized_description"] = (
[{"lang": lang, "text": data["brief"]}] if data["brief"] else []
)
if data["brief"]:
data["brief"] = re.sub(
r"<[^>]*>", "", data["brief"].replace("<br />", "\n")
)
data["author"] = [c["name"] for c in o["Contributor"] if c.get("name")]
ids = {}
t, n = detect_isbn_asin(b["details"].get("asin"))
if t:
@ -159,7 +157,7 @@ class Goodreads_Work(AbstractSite):
metadata={
"title": title,
"localized_title": [{"lang": "en", "text": title}],
"author": author,
"author": [author] if author else [],
"first_published": first_published,
}
)