HonkaiStarRailWikiDataParser/main.py

91 lines
3.1 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-04-23 15:18:42 +00:00
from func.fetch_avatars import fetch_avatars, fetch_avatars_infos, 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 12:50:37 +00:00
from func.fetch_monsters import fetch_monsters, fetch_monsters_infos, dump_monsters, read_monsters
2023-04-24 13:03:11 +00:00
from func.fetch_relics import fetch_relics, fetch_relics_infos, dump_relics, read_relics
2023-04-24 14:30:16 +00:00
from func.fetch_raiders import get_raiders
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 12:50:37 +00:00
override_monsters: 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-04-23 15:31:19 +00:00
await fetch_materials(main_data[5], "消耗品")
await fetch_materials(main_data[8], "任务道具")
await fetch_materials(main_data[9], "贵重物")
await fetch_materials(main_data[10])
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 fetch_avatars_infos()
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 12:50:37 +00:00
if override_monsters:
await fetch_monsters(main_data[2])
await fetch_monsters_infos()
await dump_monsters(data_path / "monsters.json")
else:
await read_monsters(data_path / "monsters.json")
2023-04-24 13:03:11 +00:00
if override_relics:
await fetch_relics(main_data[3])
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():
await get_raiders()
async def main(
override_materials: bool = True,
override_avatars: bool = True,
override_light_cones: bool = True,
override_monsters: bool = True,
override_relics: bool = True,
override_bbs_photos: bool = True,
):
await wiki(override_materials, override_avatars, override_light_cones, override_monsters, override_relics)
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_monster_ = 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_monster_,
override_relic_,
override_bbs_photo_,
2023-04-24 12:50:37 +00:00
))