mtchannel wrote: ↑March 12th, 2024, 11:37 pm
I managed to get it working after long efforts. I managed to get "balance" in the cmd prompt using "phyton".
As you said, it happened with the "user api key". However, the only problem is that I cannot reflect it on the "rainmeter" screen. Let me give the example code;
"python nicehash.py -b
https://api2.nicehash.com -o KEY1 -k KEY2 -s KEY3 -m GET -p /main/api/v2/accounting/account2/BTC"
.. When I write my user API information in the KEY sections, the following screen appears. quite successful. I congratulate myself
rainmeter command;
Code: Select all
---TEST APi---
[TEST]
Measure=WebParser
URL=python nicehash.py -b https://api2.nicehash.com -o KEY1 -k KEY2 -s KEY3 -m GET -p /main/api/v2/accounting/account2/BTC
RegExp=(?siU)"totalBalance":(.*)[,}]
UpdateRate=600
---TEST APi---
---------------------------------------APi---
---------------------------------------APi CONNECT---
---TEST APi CONNECT---
[TESTApi]
Measure=WebParser
URL=[TEST]
StringIndex=1
RegExpSubstitute=1
Substitute="(?:^\s+|\s+$)":"",'(?:^"|"$)':""
---------------------------------------APi CONNECT---
---TEST TEXT---
[TESTApiText]
Meter=String
X=20
Y=38
FontFace=Consolas
FontColor=255,255,255,255
StringStyle=BOLD
StringEffect=SHADOW
FontEffectColor=0,0,0,50
FontSize=15
AntiAlias=1
MeasureName=TESTApi
Text=NiCEHASH : %1 $
DynamicVariables=1
---TEST TEXT---
I don't know why you needed long efforts to make it work, since the address style I mentioned above should have worked directly in the WebParser's URL, once you adapted it for your case (which only you know and can test).
Anyway, if you insist in using python for this, you will have to replace your WebParser measures with a RunCommand one, which is specifically designed to run external programs (with or without parameters) and yield the STDOUT result (i.e. what you get in the cmd window) back to the skin, once the program terminates successfully (see the example and the explanation at the bottom of the page to get the idea, and also make sure you check and use the FinishAction properly, if needed):
https://docs.rainmeter.net/manual/plugins/runcommand/
The difference compared to WebParser is that, unless you use the optional OutputFile of the RunCommand measure as a
local URL in a subsequent WebParser measure (just like you'd do for an online source, but via
commanding the WebParser to update from the FinishAction of the RunCommand measure), the RunCommand measure would need some regex Substitute to capture and "extract" the value(s) you're after (or remove the unneeded parts if the desired pattern has not been found), e.g.:
Code: Select all
RegExpSubstitute=1
Substitute='(?siU)^(?:.*"totalBalance":(.*)[,}].*|.*)$':"\1","^\\\d+$":""
So, basically, it's somewhat similar to the WebParser approach, but in a suited measure for your current method.
P.S. Feel free to swap the " and the ' in the part before the :"\1" if the output uses ' as field name delimiters, and add the substitution parts that remove spaces and quotes from the value, like mentioned earlier. For the record, the RunCommand approach will be slightly slower than the WebParser one, since it involves running external programs, so I'm not sure how suited it would be for near real-time monitoring of those values. Commanding the RunCommand to run should be done at a reasonable frequency.