HonkaiStarRailWikiDataParser/main.py

79 lines
2.5 KiB
Python
Raw Normal View History

2023-04-23 14:06:11 +00:00
import asyncio
from pathlib import Path
from func.fetch_all import get_list
2023-07-20 05:07:56 +00:00
from func.fetch_avatars import fetch_avatars, dump_avatars, read_avatars
2023-04-24 12:29:14 +00:00
from func.fetch_light_cones import fetch_light_cones, fetch_light_cones_infos, dump_light_cones, read_light_cones
2023-04-23 15:18:42 +00:00
from func.fetch_materials import fetch_materials, fetch_materials_infos, dump_materials, read_materials
2023-04-24 13:03:11 +00:00
from func.fetch_relics import fetch_relics, fetch_relics_infos, dump_relics, read_relics
2023-04-25 14:40:19 +00:00
from func.fetch_src import move_files
2023-04-23 14:06:11 +00:00
data_path = Path("data")
data_path.mkdir(exist_ok=True)
2023-04-24 14:30:16 +00:00
async def wiki(
2023-04-24 12:29:14 +00:00
override_materials: bool = True,
override_avatars: bool = True,
override_light_cones: bool = True,
2023-04-24 13:03:11 +00:00
override_relics: bool = True,
2023-04-24 12:29:14 +00:00
):
2023-04-23 14:06:11 +00:00
main_data = await get_list()
2023-04-24 12:29:14 +00:00
if override_materials:
2023-04-23 15:18:42 +00:00
await fetch_materials(main_data[4])
2023-08-09 05:19:39 +00:00
await fetch_materials(main_data[5])
await fetch_materials(main_data[12], "消耗品")
await fetch_materials(main_data[10], "任务道具")
await fetch_materials(main_data[13], "贵重物")
2023-04-23 15:18:42 +00:00
await fetch_materials_infos()
await dump_materials(data_path / "materials.json")
else:
await read_materials(data_path / "materials.json")
2023-04-24 12:29:14 +00:00
if override_avatars:
await fetch_avatars(main_data[0])
await dump_avatars(data_path / "avatars.json")
else:
await read_avatars(data_path / "avatars.json")
if override_light_cones:
await fetch_light_cones(main_data[1])
await fetch_light_cones_infos()
await dump_light_cones(data_path / "light_cones.json")
else:
await read_light_cones(data_path / "light_cones.json")
2023-04-24 13:03:11 +00:00
if override_relics:
2023-08-09 05:19:39 +00:00
await fetch_relics(main_data[2])
2023-04-24 13:03:11 +00:00
await fetch_relics_infos()
await dump_relics(data_path / "relics.json")
else:
await read_relics(data_path / "relics.json")
2023-04-23 14:06:11 +00:00
2023-04-24 14:30:16 +00:00
async def bbs_photos():
2023-04-25 14:40:19 +00:00
await move_files()
2023-04-24 14:30:16 +00:00
async def main(
override_materials: bool = True,
override_avatars: bool = True,
override_light_cones: bool = True,
override_relics: bool = True,
override_bbs_photos: bool = True,
):
2023-08-29 02:47:44 +00:00
await wiki(override_materials, override_avatars, override_light_cones, override_relics)
2023-04-24 14:30:16 +00:00
if override_bbs_photos:
await bbs_photos()
2023-04-23 14:06:11 +00:00
if __name__ == '__main__':
2023-04-24 14:30:16 +00:00
override_material_ = True
override_avatar_ = True
override_light_cone_ = True
override_relic_ = True
override_bbs_photo_ = True
2023-04-24 12:50:37 +00:00
asyncio.run(main(
2023-04-24 14:30:16 +00:00
override_material_,
override_avatar_,
override_light_cone_,
override_relic_,
override_bbs_photo_,
2023-04-24 12:50:37 +00:00
))