It is currently April 23rd, 2024, 8:32 pm

Retrieve the last data from an XML file

Get help with creating, editing & fixing problems with skins
User avatar
Yincognito
Rainmeter Sage
Posts: 7151
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Retrieve the last data from an XML file

Post by Yincognito »

dvo wrote: September 2nd, 2020, 12:41 pm nicely done Yincognito,
but what does he have for those prices? :D :oops: banana's? stones? hick ups? ;-)
Ah, yes, good point. :lol: Should have assigned the query parameters to some variables, so I can display EUR, kg and GOLD somewhere in the skin. It wouldn't be a problem to do it, I just thought it was too trivial and frankly my focus was to make the skin work with all that format changing, not adding 3 lines that even my grandmother could add... :confused:

That being said, just let me know and I'll add them if you like. ;-)
It's neither bananas, nor stones, nor hick ups ... but counting sticks. :sly:
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
Yincognito
Rainmeter Sage
Posts: 7151
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Retrieve the last data from an XML file

Post by Yincognito »

dvo wrote: September 2nd, 2020, 2:50 pm yes you could do that in a few lines ......
Yep, turns out that if you want it to look pretty, you need more than just a few lines. Oh, well... :confused:
I'll let you do the regex and the code for the change in values from the previous day though - if you're up to it, that is. No pressure... :D

Code:

Code: Select all

[Variables]
CommonSubstitute='(?:^"|"$)':""
AddDecimals="(?i)(?:^$|^N\/A$|^null$)":"0.00","^([^\.]*)$":"\1.","^(.*)$":"\100","^(.*\..{2}).*$":"\1"
Metal=XAU
Currency=EUR
WeightUnit=kg
ColW=70

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
BackgroundMode=2
SolidColor=0,0,0,64

---Measures---

[MeasureMetal]
Measure=String
String=#Metal#
RegExpSubstitute=1
Substitute="^XAU$":"Gold","^XAG$":"Silver","^XPD$":"Palladium","^XPT$":"Platinum"

[MeasureCurrency]
Measure=String
String=#Currency#
RegExpSubstitute=1
Substitute="^USD$":"$","^EUR$":"€","^GBP$":"£","^JPY$":"¥"

[MeasureWeightUnit]
Measure=String
String=#WeightUnit#
RegExpSubstitute=1
Substitute="^kg$":"kg","^gr$":"gr","^oz$":"oz"

[MeasureSite]
Measure=WebParser
Url=https://or.fr/api/spot-prices?metal=XAU&currency=EUR&weight_unit=kg
RegExp=(?siU).*?\{"date":(.*),"weight_unit":(.*),"ask":(.*),"mid":(.*),"bid":(.*),"value":(.*),"performance":(.*)\}
UpdateRate=600

[MeasureDate]
Group=SiteGroup
Measure=WebParser
Url=[MeasureSite]
StringIndex=1
RegExpSubstitute=1
Substitute=#CommonSubstitute#,"T":", ","[+-]\d{2}:\d{2}$":""

[MeasureUnit]
Group=SiteGroup
Measure=WebParser
Url=[MeasureSite]
StringIndex=2
RegExpSubstitute=1
Substitute=#CommonSubstitute#

[MeasureAsk]
Group=SiteGroup
Measure=WebParser
Url=[MeasureSite]
StringIndex=3
RegExpSubstitute=1
Substitute=#CommonSubstitute#,"#AddDecimals#"

[MeasureMid]
Group=SiteGroup
Measure=WebParser
Url=[MeasureSite]
StringIndex=4
RegExpSubstitute=1
Substitute=#CommonSubstitute#,"#AddDecimals#"

[MeasureBid]
Group=SiteGroup
Measure=WebParser
Url=[MeasureSite]
StringIndex=5
RegExpSubstitute=1
Substitute=#CommonSubstitute#,"#AddDecimals#"

[MeasureValue]
Group=SiteGroup
Measure=WebParser
Url=[MeasureSite]
StringIndex=6
RegExpSubstitute=1
Substitute=#CommonSubstitute#,"#AddDecimals#"

[MeasurePerf]
Group=SiteGroup
Measure=WebParser
Url=[MeasureSite]
StringIndex=7
RegExpSubstitute=1
Substitute=#CommonSubstitute#,"#AddDecimals#"

---Styles---

[BaseStyle]
X=#ColW#r
Y=0r
W=#ColW#
FontFace=Tahoma
FontColor=255,255,255,255
StringEffect=Shadow
FontEffectColor=0,0,0,255
FontSize=10
AntiAlias=1

---Meters---

[MeterMetal]
X=(#ColW#/2)
Meter=String
MeterStyle=BaseStyle
StringAlign=Center
Text="Metal"
DynamicVariables=1

[MeterValue]
Meter=String
MeterStyle=BaseStyle
StringAlign=Center
Text="Value"
DynamicVariables=1

[MeterAsk]
Meter=String
MeterStyle=BaseStyle
StringAlign=Center
Text="Ask"
DynamicVariables=1

[MeterMid]
Meter=String
MeterStyle=BaseStyle
StringAlign=Center
Text="Mid"
DynamicVariables=1

[MeterBid]
Meter=String
MeterStyle=BaseStyle
StringAlign=Center
Text="Bid"
DynamicVariables=1

[MeterPerf]
Meter=String
MeterStyle=BaseStyle
StringAlign=Center
Text="Perf."
DynamicVariables=1

[MeterUnit]
Meter=String
MeterStyle=BaseStyle
StringAlign=Center
Text="Unit"
DynamicVariables=1

[MeterDate]
Meter=String
MeterStyle=BaseStyle
X=(#ColW#*3/2)r
StringAlign=Center
Text="Date"
DynamicVariables=1

[MeterGoldMetal]
Meter=String
MeterStyle=BaseStyle
X=(#ColW#/2)
Y=0R
StringAlign=Center
MeasureName=MeasureMetal
Text="%1"
DynamicVariables=1

[MeterGoldValue]
Meter=String
MeterStyle=BaseStyle
X=(#ColW#*3/2)r
StringAlign=Right
MeasureName=MeasureValue
MeasureName2=MeasureCurrency
NumOfDecimals=2
Text="%2%1"
DynamicVariables=1

[MeterGoldAsk]
Meter=String
MeterStyle=BaseStyle
StringAlign=Right
MeasureName=MeasureAsk
MeasureName2=MeasureCurrency
NumOfDecimals=2
Text="%2%1"
DynamicVariables=1

[MeterGoldMid]
Meter=String
MeterStyle=BaseStyle
StringAlign=Right
MeasureName=MeasureMid
MeasureName2=MeasureCurrency
NumOfDecimals=2
Text="%2%1"
DynamicVariables=1

[MeterGoldBid]
Meter=String
MeterStyle=BaseStyle
StringAlign=Right
MeasureName=MeasureBid
MeasureName2=MeasureCurrency
NumOfDecimals=2
Text="%2%1"
DynamicVariables=1

[MeterGoldPerf]
Meter=String
MeterStyle=BaseStyle
StringAlign=Right
MeasureName=MeasurePerf
MeasureName2=MeasureCurrency
NumOfDecimals=2
Text="%2%1"
DynamicVariables=1

[MeterGoldUnit]
Meter=String
MeterStyle=BaseStyle
X=(#ColW#/2)r
StringAlign=Center
MeasureName=MeasureUnit
Text="%1"
DynamicVariables=1

[MeterGoldDate]
Meter=String
MeterStyle=BaseStyle
X=(#ColW#*3/2)r
W=(#ColW#*2)
StringAlign=Center
MeasureName=MeasureDate
Text="%1"
DynamicVariables=1
Preview:
Precious - Pretty.jpg
dvo wrote: September 2nd, 2020, 2:50 pm
but i will ask you grandma maybe she has coffee with cookies :rolmfao:
Well, she might have some, if she ended up in heaven instead of ... the other place. :???: She was an intelligent woman though, and tough as a person, which is why I mentioned her here. :thumbup:
You do not have the required permissions to view the files attached to this post.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
PtitChat107
Posts: 126
Joined: December 31st, 2015, 6:40 pm

Re: Retrieve the last data from an XML file

Post by PtitChat107 »

mak_kawa wrote: September 2nd, 2020, 8:39 amI have accessed the API site as you wrote with some query parameters. But I could get nothing with a "Bad Request" error. What is wrong ?
Greetings and sorry for the late reply, in fact for "grams" it is "g" and not "gr" that must be used for the link to work.

I just read your exchanges and I am damn impressed by the quality and speed of your answers, thank you for your help and that indeed seems to be what I was looking for as results so thank you all ! :rosegift:
User avatar
Yincognito
Rainmeter Sage
Posts: 7151
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Retrieve the last data from an XML file

Post by Yincognito »

dvo wrote: September 2nd, 2020, 7:58 pm Yincognito, nice that she was a nice intelligent woman with a hart,
my regexp skills will not match yours i'm just a rookie and more a repair guy with pc's aka trouble shooter in many ways.
if i was a programmer i could i'm more a early days script kiddy ... turned old :P :D
Not to worry, that's how I started too. :sly:
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
Yincognito
Rainmeter Sage
Posts: 7151
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Retrieve the last data from an XML file

Post by Yincognito »

dvo wrote: September 3rd, 2020, 2:10 pm your more equal to balala and me more like mak kawa :D
Yeah, but mak_kawa is keep pushing to be better - why not do the same? ;-) You don't want to be lagging behing, now do you?
Or, maybe you like to keep your talents hidden, is that it? :D
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
Yincognito
Rainmeter Sage
Posts: 7151
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Retrieve the last data from an XML file

Post by Yincognito »

dvo wrote: September 3rd, 2020, 2:37 pm no i'm all round a bit now on linux and rpi 4 and volumio so i'm expanding but not with only one thing... :D
and i was a windows only guy :P creating my media player with a 7inch touch screen that plays my music and youtube and online radio :) in hires :P
Then, it's like I said, you keep your talents hidden...
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
Yincognito
Rainmeter Sage
Posts: 7151
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Retrieve the last data from an XML file

Post by Yincognito »

dvo wrote: September 3rd, 2020, 4:22 pm no my talent isn't hidden... nobody asks...
A+ I+ N+ web dev and all kinds of grafix work some video editing was learning for electrician went to computers started with c-64, amiga, then came pc from win 3.11 till now win 10 and i'm handy ....that are some of my skills
Nice set of skills indeed. :thumbup:
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth