genshin-wishes-api icon indicating copy to clipboard operation
genshin-wishes-api copied to clipboard

Problem in fetching/saving wishes (2.3+)

Open awe777 opened this issue 3 years ago • 4 comments

The usual link copy from feedback does not work on fetching/saving wishes.

/api/wishes/importState/ does provide factual information from Mihoyo's server (pulled 1 pull and 11 pulls on standard banner and weapon banner, respectively), shown in the JSON below:

{

"PERMANENT":{"bannerType":"PERMANENT","count":1,"finished":false,"saved":false,"error":"ERROR"},

"CHARACTER_EVENT":{"bannerType":"CHARACTER_EVENT","count":0,"finished":false,"saved":false,"error":"ERROR"},

"NOVICE":{"bannerType":"NOVICE","count":0,"finished":true,"saved":false,"error":"ERROR"},

"WEAPON_EVENT":{"bannerType":"WEAPON_EVENT","count":11,"finished":true,"saved":false,"error":"ERROR"}

}

awe777 avatar Nov 25 '21 01:11 awe777

Is there anything we can do to help? I know nothing about how Mihoyo's APIs work, but if you could explain the issue a little I could try investigating a bit.

armisael avatar Dec 23 '21 07:12 armisael

So, I investigated a bit, and the only issue I could find is that sometimes the call to /event/gacha_info/api/getGachaLog returns -110: visit too frequently.

I added a Thread.sleep and it seems to be working, something along this inside MihoyoRestClient.getWishes:

        if (ret.getRetcode() == -110) {
            Thread.sleep(4000);
            return getWishes(authkey, gameBiz, banner, lastWishId, page);
        }

I'm not creating a PR as my local code is a mess right now (I'm not a Java dev, and I've never used Spring, so I had to be "creative" to make it run); moreover, I'm not sure this is a proper fix, as the solution seems too simple to me 😅 the only thing I can say is that, after this change, I can see all my wishes in the database.

armisael avatar Jan 03 '22 17:01 armisael

Hi, sorry for my lack of availability lately, the thing is that this would work for one user but not many We need to add a queue system to avoid having too many imports at the same time

Ishou avatar Jan 04 '22 09:01 Ishou

It depends on whether they rate limit on the IP or on the user, but yeah, a queue would for be the safest route...

Thank you for looking into it!

armisael avatar Jan 04 '22 12:01 armisael