aRTy42 / POE-ItemInfo

Item Info Script for Path of Exile
167 stars 225 forks source link

Use fetched currency ratios instead of hard coded ones #42

Closed Eruyome closed 7 years ago

Eruyome commented 7 years ago

It was brought to my attention that the currency ratios used by ItemInfo are different than those used by TradeMacro and that it would be nice to use Trademacro's rates instead. https://github.com/PoE-TradeMacro/POE-TradeMacro/issues/188

So if I wanted to implement this I could add some global array for these values to ItemInfo and overwrite that by TradeMacro, but wouldn't it be nice to have those correct values for the standalone ItemInfo, too?

The simplest way would be to get those values from poe.ninjas API (I asked the developer /u/rasmuskl for permission for TradeMacro):
http://poe.ninja/api/Data/GetCurrencyOverview?league=Breach

This would introduce the problem that ItemInfo doesn't know the current league names, we could use TradeMacros code for this but that would only overcomplicate things. Adding the same dropdown list to the settings that I use for TradeMacro (standard|hardcore|tmpstandard|tmphardcore) and asking the poe.ninja dev if he could make this data available using those strings in addition to the actual names could work.

Then it's simply a matter of downloading this json data to variable with winhttp or to file with UrlDownloadToFile and to parse it so that it has the format ItemInfo is using:

Scroll of Wisdom|250:1
Portal Scroll|200:1
Armourer's Scrap|40:1

Currencyrates.txt should still be used as fallback. The download can be done once on script start or every 30min (or some other value), that's what I do for TradeMacro, too.

This functionality is probably not used by many but it would be greatly improved.

aRTy42 commented 7 years ago

Sounds nice. I'm currently not spending much time on the script, but that method sounds comparibly easy to handle.

I think instead of using a dropdown list in the settings I'd rather display all 4 leagues. The pop up is rather short for currency, so increasing the size there should still be fine, and for people that switch leagues often it would probably be quite annoying to change settings all the time. Also, people might get a better feeling for the different rates in other leagues, which might be helpful.

Would you ask the poe.ninja dev or should I contact him?

Furthermore, since I don't have experience with auto-updating yet: What would you recommend? Download the data to the file, so that the script always has a rather recent version if the update fails? Anything else that you ran into and can warn me about?

Eruyome commented 7 years ago

I already asked him, no answer yet.

Still haven't had the time to write a "real" auto updater, but for specific files there would be a few approaches.

Case 1 - You need some scrapers/scripts to generate them and can't do it with AHK

Generate them client-side and commit them from time to time to github.

  1. Hardcode the github raw urls to download and overwrite those files at script start (I'm doing this for about 6 files, poe.trade mods, uniques, enchantments, corruptions etc). Even with making backups of the old files and checking if the new files exist and contain something this is easy. pastebin
  2. Use the github API to get the file tree and fetch the urls of your project/subfolder. This would probably be the right way to update the entire \data folder for example.
  3. Download the entire master branch as zip, extract it somewhere and copy the folders you need.

Case 2 - You can download and parse those files with AHK (currency data json for example)

  1. Do this on every scripstart overwriting the old files. Use some file as backup if something fails.
  2. Do it on script start and then from time to time again, I'm doing this for the poe.ninja currency data. I remember the timestamp of the last currency search and download the fle again if the last search was at least 30mins ago. By doing this you have a compromise of speed, latest data and less requests to the server where you get this from.

My "entire-script" auto updater would download the release zip, remove the old folder and extract the zip, while saving the .ini files to an user folder and checking if they have to be overwritten (save file hash at installation and compare with the new zips file hashes to see if there were any changes to that file or use the github API somehow).

rasmuskl commented 7 years ago

poe.ninja dev here.

I can make a special value like tmpstandard for the challenge leagues, but wouldn't it be better to use GGG's league api to get the correct values, so it could also be displayed? Too much work?

Also, my default disclaimer when people ask for api access is that I can't promise that the way the data is structured will be 100% stable. I still have no official api and I reserve the right to change how it works :-)

Eruyome commented 7 years ago

Of course that's possible, that's what I do with TradeMacro. But downloading web-content can lead to issues for some people, no matter what method you use, this minority of people could be ignored but it's less of a hassle if you don't have to do it. Aside from that, you have no idea how often people complain because they get the error message that GGGs API is not available, since I can't parse the leagues in that case TradeMacro will not work. You can explain to them that they simply should wait a moment because GGGs servers are probably down for maintentance, they still complain and ask for a solution. Parsing those league names is nice, but it's even better if not mandatory.

aRTy42 commented 7 years ago

I consider if manually adjusting the current league name every 3 months might actually be the easiest option. Having things run automated sounds nice, but if making sure the automation actually runs as intended is practically as least as complicated or prone to errors as a manual update, then I guess it is not worth the hassle.

As for the disclaimer: Thanks for pointing that out, but as the script is also nothing official and does not come with a promise to be perfect, it is perfectly fine if it might fail.

rasmuskl commented 7 years ago

I have pushed a new version to poe.ninja that allows the api to be used with tmpstandard and tmphardcore to refer to those leagues.

aRTy42 commented 7 years ago

Ok, thank you.

Eruyome commented 7 years ago

@rasmuskl Is it intended that you don't have currency data for Mirror of Kalandra or is this a result of too little information available (there are not many listed of course, for temp-leagues none at all at times).

Implemented fetching the currency rates https://github.com/aRTy42/POE-ItemInfo/pull/44.

EDIT: @rasmuskl I just noticed there are currencies with "Not enough data", Splinter of Uul-Netol in Standard for example, so is Mirror of Kalandra just missing completely? Btw have you considered making a Github repo or something like it for poe.ninja just for the issue tracking system? I believe it's a bit complicated to give you feedback/bug reports if you only use reddit.

rasmuskl commented 7 years ago

I removed mirrors because there wasn't enough information. Mainly due to the fact that noone lists mirror prices as chaos orbs, which is what the currency page is based on.

I've been thinking about ways to include the expensive currencies like mirror and blessing of chayula based on their exalted rates.. But haven't done it yet.

Eruyome commented 7 years ago

I think we can close this, right?

aRTy42 commented 7 years ago

Yes, I'm currently still testing and debugging, but the currency fetching seems to work perfectly fine.

rasmuskl commented 7 years ago

Great! :)

4GForce commented 7 years ago

Looking for the league name ? I know this is far fetched and probably a lot of work for such a basic task but the current player / current league name could be parsed out from the poe chat console. Well that would require to find the Client.txt depending on the user client ( steam or standalone ) Send a dummy string to chat, parse the text file to find the %playername% then send a /whois %playername% command to chat and parse the text file some more.

2017/01/27 04:14:36 74489432 951 [INFO Client 2484] ToxicTheAvenger: boobies
2017/01/27 04:14:49 74502707 951 [INFO Client 2484] : ToxicTheAvenger is a level 61 Juggernaut in the Breach league and is currently playing in Lioneye's Watch.

A lot more infos could be obtained that way, so even if its not optimal for this case I tought I'd share the idea for future cases. Maybe I'll implement a prototype and see how good/bad it could be.

Eruyome commented 7 years ago

That's not feasible at all, it's easy to find PoE installations and the client.txt but you could only get the leagues listed in that file. This parsing should be done only once at script start not every now and then. So you could only play Standard, start the macro, create some temp-league character and it doesn't work. Or you deleted client.txt because it grew too big and it's not available or doesn't have those lines at script start. There are a lot of cases where this simply fails. It's not impossible to implement but way too complicated and unneccessary since we have the API access via "tmpstandard" and "tmphardcore"

Btw I already have all the neccessary code from a different project to find installations from the registry, use the last modified clíent.txt and parse some lines. https://github.com/poeqic/qic

aRTy42 commented 7 years ago

I'm also quite happy with displaying all 4 league ratio's together. It's pretty fail-safe, people don't have to manually adjust any setting and it's giving a nice insight in how the ratios differ.