thesadru / genshinstats

PLEASE USE GENSHIN.PY A python library that can get the stats of Genshin Impact players using Mihoyo's API. PLEASE USE GENSHIN.PY
https://thesadru.github.io/pdoc/genshinstats/
MIT License
265 stars 38 forks source link

KeyError: 101 #22

Closed rushkii closed 3 years ago

rushkii commented 3 years ago

Hello, sorry to open the issue, I have some error while trying to fetch profile stats, I've no idea to solve it.

Traceback (most recent call last):
  File "main.py", line 369, in get_self_profile
    data = await genshin.get_full_profile(user)
  File "/app/core/genshin.py", line 76, in get_full_profile
    return await self.get_data(user)
  File "/app/core/pool.py", line 30, in wrapper
    return await loop.run_in_executor(_EXECUTOR, partial(func, *args, kwargs))
  File "/app/.heroku/python/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, self.kwargs)
  File "/app/core/genshin.py", line 33, in get_data
    characters = gs.get_characters(d['gi_guid'])
  File "/app/.heroku/python/lib/python3.7/site-packages/genshinstats/genshinstats.py", line 197, in get_characters
    return prettify_characters(data)
  File "/app/.heroku/python/lib/python3.7/site-packages/genshinstats/pretty.py", line 128, in prettify_characters
    } for i in data]
  File "/app/.heroku/python/lib/python3.7/site-packages/genshinstats/pretty.py", line 128, in 
    } for i in data]
KeyError: 101

Please let me know if you need any detail

thesadru commented 3 years ago

The traceback seems to be both unreadable and also incorrect, it's giving a keyerror where there shouldn't be one, there's probably some line you cut off or something. My guess is that the library is unable to determine the element of the electro traveler.

rushkii commented 3 years ago

The traceback seems to be both unreadable and also incorrect, it's giving a keyerror where there shouldn't be one, there's probably some line you cut off or something. My guess is that the library is unable to determine the element of the electro traveler.

My apology, I was using 1 backtick instead of 3 so the traceback looks messy. I've same guess too, can you update the lib to determine the element of the electro traveler?

rushkii commented 3 years ago

I think it because of element ID of the Electro Traveler doesn't exist on prettify_user_stats function, I've add it to pull request. and I've tested it.

  1. Screenshot
  2. Screenshot
thesadru commented 3 years ago

Ah sorry, I pushed a quick fix before I noticed you wanted to make a pr.

rushkii commented 3 years ago

Ah sorry, I pushed a quick fix before I noticed you wanted to make a pr.

It's alright, glad you fixed it so my bot doesn't get error when someone trying to get their profile.