arturino009 / POEcluster

Make insane profits with this one simple trick! Just indexes all possible combinations for medium cluster jewels and their prices.
GNU General Public License v3.0
20 stars 13 forks source link

Stuck at updating (3.19) #11

Closed Bonaf1de closed 2 years ago

Bonaf1de commented 2 years ago

To my great regret the tool is stuk at updating:

py poecluster.py
Didn't find data for current league. Updating...
'option'

And then:

Traceback (most recent call last):
File "C:\Downloads\PoeCluster1.1\poecluster.py", line 119, in
updateClusterData()
File "C:\Downloads\PoeCluster1.1\updateClusterData.py", line 98, in updateClusterData
json.dump(get_data_poedb("Small"), outfile)
File "C:\Downloads\PoeCluster1.1\updateClusterData.py", line 58, in get_data_poedb
for i in allStats['result'][4]['entries'][1]['option']['options']:
KeyError: 'option'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Downloads\PoeCluster1.1\poecluster.py", line 226, in
stop = int(input())
ValueError: invalid literal for int() with base 10: ''
ErebusEtherie commented 2 years ago

I checked the code at work (can't run it in here, corporation policies), but problem is probably with parsing response using JSONPath.

Code: for i in allStats['result'][4]['entries'][1]['option']['options']: After fix: for i in allStats['result'][4]['entries'][0]['option']['options']:

On paper it should fix the problem.


Longer explanation: We send request to poe asking about possible affixes, etc... for items. Then we parse the result (named here allStats) using JSONpath with bracket notation. We need to go down the tree until we get to possible clusters enchantments (for example: "12% increased Attack Damage while Dual Wielding"). In original code we go to branch "1" of entries - before update it existed, now they changed a little response structure. Now we need to target "0" branch.

Different approach (but I would need to check it): allStats['result'][?(@.label=='Enchant')][..]['options'] -> will work only if [..] operator can be used or allStats['result'][?(@.label=='Enchant')][['options']]

That way we can be more flexible - if GGG changes the order of nodes we will be good because we don't target n-th node, but node with a specific label.

ErebusEtherie commented 2 years ago

For more: https://requests.readthedocs.io/en/latest/user/quickstart/#json-response-content https://realpython.com/python-json/ https://blogboard.io/blog/knowledge/jsonpath-python/

responseStats = requests.get(
    "https://www.pathofexile.com/api/trade/data/stats", headers=headers)
global allStats
allStats = responseStats.json()

allStats is a json, so we can use JSONPath syntax to traverse the tree and filter the content we are interested in.

By default we don't need to use .parse(jsonPath) - it can be simplified to allStats[][][][][]

Bonaf1de commented 2 years ago

Code: for i in allStats['result'][4]['entries'][1]['option']['options']: After fix: for i in allStats['result'][4]['entries'][0]['option']['options']:

This fixed it!!

ErebusEtherie commented 2 years ago

I will fork repo, fix it and make a merge request.

Can you check if allStats['result'][?(@.label=='Enchant')][['options']] also works? I will check it in 3h if you don't have time :).

Bonaf1de commented 2 years ago

If I change:

for i in allStats['result'][4]['entries'][0]['option']['options']:

In:

for i in allStats['result'][?(@.label=='Enchant')][..]['options']:

Or:

for i in allStats['result'][?(@.label=='Enchant')][['options']]:

The python-script won't even start. But tbh I do not have faintest idea what I'm doing..

ErebusEtherie commented 2 years ago

Thank you! I will work on it after work :). Enjoy!

śr., 5 paź 2022 o 15:18 Bonaf1de @.***> napisał(a):

If I change:

for i in allStats['result'][4]['entries'][0]['option']['options']:

In:

for i in @.***=='Enchant')][..]['options']:

Or:

for i in @.***=='Enchant')][['options']]:

The python-script won't even start. But tbh I do not have faintest idea what I'm doing..

— Reply to this email directly, view it on GitHub https://github.com/arturino009/POEcluster/issues/11#issuecomment-1268424060, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIMM7BLHE7PV2KCL5WU7XP3WBV537ANCNFSM6AAAAAAQKSQJRY . You are receiving this because you commented.Message ID: @.***>

arturino009 commented 2 years ago

Its just so stupid from GGG. I have to change this shit almost every month. Why can't they just be consistent with the way they are sorting their stats

ErebusEtherie commented 2 years ago

I don't have experience with Python, right now I work more with Java and .Net, but I think that we can make path to the nodes of interest more generic. I will try to work on it this weekend. Thank you for your work!

czw., 6 paź 2022 o 16:07 arturino009 @.***> napisał(a):

Its just so stupid from GGG. I have to change this shit almost every month. Why can't they just be consistent with the way they are sorting their stats

— Reply to this email directly, view it on GitHub https://github.com/arturino009/POEcluster/issues/11#issuecomment-1270118898, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIMM7BPIG3HDGUBMDUB6SQTWB3ML7ANCNFSM6AAAAAAQKSQJRY . You are receiving this because you commented.Message ID: @.***>

arturino009 commented 2 years ago

I made a fix. It can probably be better, but its good enough. Hopefully this will be enough for this specific issue