thesadru / genshin.py

API wrapper for HoYoLAB/Miyoushe API built on asyncio and pydantic.
https://thesadru.github.io/genshin.py
MIT License
405 stars 74 forks source link

Is get_user with all_characters flag broken? #9

Closed nano-shino closed 2 years ago

nano-shino commented 2 years ago

I ran the example code below and just got a list of the same character over and over.

import asyncio
import genshin

async def main():
    cookies = {"ltuid": 119480035, "ltoken": "cnF7TiZqHAAvYqgCBoSPx5EjwezOh1ZHoqSHf7dT"}
    client = genshin.GenshinClient(cookies)

    data = await client.get_user(710785423, all_characters=True)
    print(f"Characters: {', '.join(c.name for c in data.characters)}")

    await client.close()

asyncio.run(main())
Characters: Beidou, Beidou, Beidou, Beidou, Beidou, Beidou, Beidou, Beidou, Beidou, Beidou, Beidou, Beidou, Beidou, Beidou, Beidou, Beidou, Beidou, Beidou, Beidou, Beidou, Beidou, Beidou, Beidou, Beidou, Beidou, Beidou, Beidou, Beidou, Beidou, Beidou, Beidou, Beidou, Beidou, Beidou, Beidou, Beidou, Beidou, Beidou, Beidou, Beidou, Beidou, Beidou, Beidou, Beidou, Beidou
thesadru commented 2 years ago

It appears that mihoyo completely removed the option to fetch a specific character. This means you may only get the 8 characters mihoyo's API decides to give you at that time. In the next release, I think I'll be removing all_characters=True and deprecating get_characters.