From d143632025fece6bb984be2bd933e63af9abb913 Mon Sep 17 00:00:00 2001 From: 283375 Date: Wed, 2 Oct 2024 12:56:39 +0800 Subject: [PATCH] fix: typing issues --- .../external/exporters/arcsong/json.py | 9 ++++- .../external/exporters/defv2/play_result.py | 38 ++++++++++--------- .../external/importers/arcaea/lists.py | 6 +-- 3 files changed, 31 insertions(+), 22 deletions(-) diff --git a/src/arcaea_offline/external/exporters/arcsong/json.py b/src/arcaea_offline/external/exporters/arcsong/json.py index 4ebf529..9866bd4 100644 --- a/src/arcaea_offline/external/exporters/arcsong/json.py +++ b/src/arcaea_offline/external/exporters/arcsong/json.py @@ -38,6 +38,13 @@ class ArcsongJsonExporter: else: 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 { "name_en": difficulty.title or song.title, "name_jp": name_jp, @@ -53,7 +60,7 @@ class ArcsongJsonExporter: "world_unlock": False, "remote_download": False, "bg": difficulty.bg or song.bg or "", - "date": difficulty.date or song.date or 0, + "date": date, "version": difficulty.version or song.version or "", "difficulty": difficulty.rating * 2 + int(difficulty.rating_plus), "rating": chart_info.constant or 0 if chart_info else 0, diff --git a/src/arcaea_offline/external/exporters/defv2/play_result.py b/src/arcaea_offline/external/exporters/defv2/play_result.py index 60c2f75..08e6fb8 100644 --- a/src/arcaea_offline/external/exporters/defv2/play_result.py +++ b/src/arcaea_offline/external/exporters/defv2/play_result.py @@ -12,25 +12,27 @@ class ArcaeaOfflineDEFv2PlayResultExporter: def export(self, items: List[PlayResult]) -> ArcaeaOfflineDEFv2PlayResultRoot: export_items = [] for item in items: - export_item: ArcaeaOfflineDEFv2PlayResultItem = {} + export_item: ArcaeaOfflineDEFv2PlayResultItem = { + "id": item.id, + "songId": item.song_id, + "ratingClass": item.rating_class.value, + "score": item.score, + "pure": item.pure, + "far": item.far, + "lost": item.lost, + "date": int(item.date.timestamp() * 1000) if item.date else 0, + "maxRecall": item.max_recall, + "modifier": ( + item.modifier.value if item.modifier is not None else None + ), + "clearType": ( + item.clear_type.value if item.clear_type is not None else None + ), + "source": "https://arcaeaoffline.sevive.xyz/python", + "comment": item.comment, + } - export_item["id"] = item.id - export_item["songId"] = item.song_id - export_item["ratingClass"] = item.rating_class.value - export_item["score"] = item.score - export_item["pure"] = item.pure - export_item["far"] = item.far - export_item["lost"] = item.lost - export_item["date"] = item.date - export_item["maxRecall"] = item.max_recall - export_item["modifier"] = ( - item.modifier.value if item.modifier is not None else None - ) - export_item["clearType"] = ( - item.clear_type.value if item.clear_type is not None else None - ) - export_item["source"] = "https://arcaeaoffline.sevive.xyz/python" - export_item["comment"] = item.comment + export_items.append(export_item) return { "$schema": "https://arcaeaoffline.sevive.xyz/schemas/def/v2/score.schema.json", diff --git a/src/arcaea_offline/external/importers/arcaea/lists.py b/src/arcaea_offline/external/importers/arcaea/lists.py index 1a56631..d397d23 100644 --- a/src/arcaea_offline/external/importers/arcaea/lists.py +++ b/src/arcaea_offline/external/importers/arcaea/lists.py @@ -49,7 +49,7 @@ class ArcaeaPacklistParser(ArcaeaListParser): if name_localized or description_localized: pack_localized = PackLocalized(id=pack.id) - pack_localized.lang = key.value + pack_localized.lang = ArcaeaLanguage(key.value) pack_localized.name = name_localized pack_localized.description = description_localized results.append(pack_localized) @@ -96,7 +96,7 @@ class ArcaeaSonglistParser(ArcaeaListParser): if title_localized or source_localized: song_localized = SongLocalized(id=song.id) - song_localized.lang = lang.value + song_localized.lang = ArcaeaLanguage(lang.value) song_localized.title = title_localized song_localized.source = source_localized results.append(song_localized) @@ -167,7 +167,7 @@ class ArcaeaSonglistParser(ArcaeaListParser): song_id=difficulty.song_id, rating_class=difficulty.rating_class, ) - difficulty_localized.lang = lang.value + difficulty_localized.lang = ArcaeaLanguage(lang.value) difficulty_localized.title = title_localized difficulty_localized.artist = artist_localized results.append(difficulty_localized)