fix: typing issues

This commit is contained in:
283375 2024-10-02 12:56:39 +08:00
parent 6e8ac3dee7
commit d143632025
Signed by: 283375
SSH Key Fingerprint: SHA256:UcX0qg6ZOSDOeieKPGokA5h7soykG61nz2uxuQgVLSk
3 changed files with 31 additions and 22 deletions

View File

@ -38,6 +38,13 @@ class ArcsongJsonExporter:
else: else:
name_jp = "" name_jp = ""
if difficulty.date is not None:
date = int(difficulty.date.timestamp())
elif song.date is not None:
date = int(song.date.timestamp())
else:
date = 0
return { return {
"name_en": difficulty.title or song.title, "name_en": difficulty.title or song.title,
"name_jp": name_jp, "name_jp": name_jp,
@ -53,7 +60,7 @@ class ArcsongJsonExporter:
"world_unlock": False, "world_unlock": False,
"remote_download": False, "remote_download": False,
"bg": difficulty.bg or song.bg or "", "bg": difficulty.bg or song.bg or "",
"date": difficulty.date or song.date or 0, "date": date,
"version": difficulty.version or song.version or "", "version": difficulty.version or song.version or "",
"difficulty": difficulty.rating * 2 + int(difficulty.rating_plus), "difficulty": difficulty.rating * 2 + int(difficulty.rating_plus),
"rating": chart_info.constant or 0 if chart_info else 0, "rating": chart_info.constant or 0 if chart_info else 0,

View File

@ -12,25 +12,27 @@ class ArcaeaOfflineDEFv2PlayResultExporter:
def export(self, items: List[PlayResult]) -> ArcaeaOfflineDEFv2PlayResultRoot: def export(self, items: List[PlayResult]) -> ArcaeaOfflineDEFv2PlayResultRoot:
export_items = [] export_items = []
for item in items: for item in items:
export_item: ArcaeaOfflineDEFv2PlayResultItem = {} export_item: ArcaeaOfflineDEFv2PlayResultItem = {
"id": item.id,
export_item["id"] = item.id "songId": item.song_id,
export_item["songId"] = item.song_id "ratingClass": item.rating_class.value,
export_item["ratingClass"] = item.rating_class.value "score": item.score,
export_item["score"] = item.score "pure": item.pure,
export_item["pure"] = item.pure "far": item.far,
export_item["far"] = item.far "lost": item.lost,
export_item["lost"] = item.lost "date": int(item.date.timestamp() * 1000) if item.date else 0,
export_item["date"] = item.date "maxRecall": item.max_recall,
export_item["maxRecall"] = item.max_recall "modifier": (
export_item["modifier"] = (
item.modifier.value if item.modifier is not None else None item.modifier.value if item.modifier is not None else None
) ),
export_item["clearType"] = ( "clearType": (
item.clear_type.value if item.clear_type is not None else None item.clear_type.value if item.clear_type is not None else None
) ),
export_item["source"] = "https://arcaeaoffline.sevive.xyz/python" "source": "https://arcaeaoffline.sevive.xyz/python",
export_item["comment"] = item.comment "comment": item.comment,
}
export_items.append(export_item)
return { return {
"$schema": "https://arcaeaoffline.sevive.xyz/schemas/def/v2/score.schema.json", "$schema": "https://arcaeaoffline.sevive.xyz/schemas/def/v2/score.schema.json",

View File

@ -49,7 +49,7 @@ class ArcaeaPacklistParser(ArcaeaListParser):
if name_localized or description_localized: if name_localized or description_localized:
pack_localized = PackLocalized(id=pack.id) pack_localized = PackLocalized(id=pack.id)
pack_localized.lang = key.value pack_localized.lang = ArcaeaLanguage(key.value)
pack_localized.name = name_localized pack_localized.name = name_localized
pack_localized.description = description_localized pack_localized.description = description_localized
results.append(pack_localized) results.append(pack_localized)
@ -96,7 +96,7 @@ class ArcaeaSonglistParser(ArcaeaListParser):
if title_localized or source_localized: if title_localized or source_localized:
song_localized = SongLocalized(id=song.id) song_localized = SongLocalized(id=song.id)
song_localized.lang = lang.value song_localized.lang = ArcaeaLanguage(lang.value)
song_localized.title = title_localized song_localized.title = title_localized
song_localized.source = source_localized song_localized.source = source_localized
results.append(song_localized) results.append(song_localized)
@ -167,7 +167,7 @@ class ArcaeaSonglistParser(ArcaeaListParser):
song_id=difficulty.song_id, song_id=difficulty.song_id,
rating_class=difficulty.rating_class, rating_class=difficulty.rating_class,
) )
difficulty_localized.lang = lang.value difficulty_localized.lang = ArcaeaLanguage(lang.value)
difficulty_localized.title = title_localized difficulty_localized.title = title_localized
difficulty_localized.artist = artist_localized difficulty_localized.artist = artist_localized
results.append(difficulty_localized) results.append(difficulty_localized)