It is currently September 19th, 2024, 1:19 am
Can't pass measure value to web parser
-
- Posts: 158
- Joined: March 15th, 2024, 7:30 pm
Re: Can't pass measure value to web parser
Thanks, I'll take some time to try this option. There are also new difficulties, in some places hourly forecasts were discovered not at 00:00 03:00 06:00, etc., but at 02:00 05:00 08:00 and so on, before that I looked at many places at random and this didn’t happen it was, but people found such places. We'll have to think about how to deal with this.
-
- Rainmeter Sage
- Posts: 8171
- Joined: February 27th, 2015, 2:38 pm
- Location: Terra Yincognita
Re: Can't pass measure value to web parser
Both 03:00 and 02:00 are still \d+:\d+ or \d{2}:\d{2} from a regex point of view, while there should be an equal number of 3 hour incremented times in the day, if you don't mind different times in the forecast - just saying...Kotofanchik wrote: ↑June 27th, 2024, 5:20 pmThere are also new difficulties, in some places hourly forecasts were discovered not at 00:00 03:00 06:00, etc., but at 02:00 05:00 08:00 and so on, before that I looked at many places at random and this didn’t happen it was, but people found such places. We'll have to think about how to deal with this.
-
- Posts: 158
- Joined: March 15th, 2024, 7:30 pm
Re: Can't pass measure value to web parser
I now have such a calculation of the initial hour that I no longer understand how it works. But it seems to work. There are also doubts about the optimality of how I did it.
You do not have the required permissions to view the files attached to this post.
-
- Rainmeter Sage
- Posts: 8171
- Joined: February 27th, 2015, 2:38 pm
- Location: Terra Yincognita
Re: Can't pass measure value to web parser
Well, if you tested it and it works, then it's all good, at least until you notice possible inconsistencies. Regarding how you did it, using the [HOD], the [mStartHour0CalcN] and the [MeasurecalcHOD] measures is not bad at all.Kotofanchik wrote: ↑June 27th, 2024, 6:42 pm I now have such a calculation of the initial hour that I no longer understand how it works. But it seems to work. There are also doubts about the optimality of how I did it.
-
- Posts: 158
- Joined: March 15th, 2024, 7:30 pm
Re: Can't pass measure value to web parser
I did it and it didn’t work, or it doesn’t work, or the same errors. I tried two options in the skin. The first one gives the same errorsYincognito wrote: ↑June 27th, 2024, 4:24 pm Simple example, based on the DOW code earlier - it's up to you to get the idea and implement the approach in your actual skin:Now, as you can see in the Rainmeter log, the above code will throw 2 TimeStampFormat errors on load / refresh, since the TimeStamp option of the [DOW] measure doesn't yet have a valid value until the [Date] measure retrieves it from the site and the [DOW] measure updates to reflect the change. However, if you do TimeStamp=#DummyDate# in the [DOW] measure and add FinishAction=[!SetOption DOW TimeStamp "[Date]"][!UpdateMeasure DOW][!UpdateMeter DOWText][!Redraw] to the [Date] measure, there will be no more such errors on load / refresh, because the value of the timestamp be a valid dummy date right from the start, being replaced with the actual date once the webparser retrieves it.Code: Select all
[Variables] DummyDate=June 15, 2024 [Rainmeter] Update=1000 AccurateText=1 DynamicWindowSize=1 BackgroundMode=2 SolidColor=0,255,0,255 [Date] Measure=WebParser URL=https://time.is/en/UTC RegExp=(?siU)<div id="dd" .*>.*, (.*)</div> StringIndex=1 UserAgent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36 DynamicVariables=1 [DOW] Measure=Time TimeStampFormat=%B %d, %Y TimeStamp=[Date] Format=%A DynamicVariables=1 ---Meters--- [DOWText] Meter=String MeasureName=DOW Text=DOW: %1
So basically, you need to correct the TimeStamp option not having a valid value before it's set from the site. How to do it, is your choice, the above is just one way of approaching this. You could even write it directly as TimeStamp=June 15, 2024 (or whatever other valid value, according to whatever timestamp format you use) and not use a variable at all, as long as you set it to the actual value afterwards, from the FinishAction of the webparser parent (or whatever other measure is retrieving the actual date).
Code: Select all
[DOW]
Measure=Time
TimeStampFormat=%Y-%m-%dT%H:%M:%S
TimeStamp=[mfullDate]
FormatLocale=#LangLoc#
Format=%a
DynamicVariables=1
TimeStamp=#DummyDate#
FinishAction=[!SetOption DOW TimeStamp "[mfullDate]"][!UpdateMeasure DOW][!Redraw]
Code: Select all
[DOW]
Measure=Time
TimeStampFormat=%Y-%m-%dT%H:%M:%S
;TimeStamp=[mfullDate]
FormatLocale=#LangLoc#
Format=%a
DynamicVariables=1
TimeStamp=#DummyDate#
FinishAction=[!SetOption DOW TimeStamp "[mfullDate]"][!UpdateMeasure DOW][!Redraw]
Code: Select all
[Variables]
DummyDate=June 10, 2024
[Rainmeter]
Update=1000
AccurateText=1
DynamicWindowSize=1
BackgroundMode=2
SolidColor=0,255,0,255
[Date]
Measure=WebParser
URL=https://time.is/en/UTC
RegExp=(?siU)<div id="dd" .*>.*, (.*)</div>
StringIndex=1
UserAgent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36
DynamicVariables=1
[DOW]
Measure=Time
TimeStampFormat=%B %d, %Y
TimeStamp=[Date]
Format=%A
DynamicVariables=1
TimeStamp=#DummyDate#
FinishAction=[!SetOption DOW TimeStamp "[Date]"][!UpdateMeasure DOW][!UpdateMeter DOWText][!Redraw]
---Meters---
[DOWText]
Meter=String
MeasureName=DOW
Text=DOW: %1
-
- Posts: 158
- Joined: March 15th, 2024, 7:30 pm
Re: Can't pass measure value to web parser
This is how the design worked.
All that remains is to defeat the web parser errors. But I already had experience dealing with them. We just need to remember.
Code: Select all
[mfullDate]
Measure =Plugin
Plugin =WebParser
Url =[mTotal]
RegExp ="(?siU)#fullDate#"
StringIndex =1
StringIndex2=1
IfCondition=(mfullDate > 0)
IfTrueAction=[!CommandMeasure mTotal Update][!SetOption MeasureDayMMW_1 TimeStamp "[mfullDate]"][!UpdateMeasure MeasureDayMMW_1][!SetOption DOW TimeStamp "[mfullDate]"][!UpdateMeasure DOW][!SetOption Y TimeStamp "[mfullDate]"][!UpdateMeasure Y][!SetOption MOY TimeStamp "[mfullDate]"][!UpdateMeasure MOY][!SetOption DOM TimeStamp "[mfullDate]"][!UpdateMeasure DOM][!SetOption HOD TimeStamp "[mfullDate]"][!UpdateMeasure HOD][!SetOption MOD TimeStamp "[mfullDate]"][!UpdateMeasure MOD][!Redraw]
DynamicVariables=1
You do not have the required permissions to view the files attached to this post.
-
- Rainmeter Sage
- Posts: 8171
- Joined: February 27th, 2015, 2:38 pm
- Location: Terra Yincognita
Re: Can't pass measure value to web parser
I'm afraid that the correct way is in the FinishAction of [mTotal], like I explained in my example. It's merely a coincidence that putting those bangs in the IfTrueAction seems to work, because everything after [!CommandMeasure mTotal Update] will happen before it (instead of right after it), since retrieving data from the web resource is, once again, not immediate.
But then again, besides the otherwise fine code you have in the skin, I still believe that requesting data twice from the site is redundant and overcomplicates things a lot, and don't understand yet why you need to do it. In any case, it's your skin, so your decision / choice.
P.S. A web resource like such as this unformatted xml:
Code: Select all
<?xml version="1.0" encoding="utf-8"?><weather><location id="74819" name="Баренцбург" name_r="в Баренцбурге" tzone="120" cur_time="2024-06-26T09:51:00"><fact valid="2024-06-27T23:00:00" tod="0" risem="102" setm="39" durm="1440" sunrise="1713404520" sunset="1724459940"><values t="5" p="752" ws="5" wd="6" hum="84" hi="0" cl="3" pt="1" pr="1" ts="0" water_t="6" icon="d.sun.c4.r1" descr="Пасмурно, небольшой дождь" grade="2" ph="61"/></fact><day date="2024-06-28" risem="102" setm="39" durm="1440" tmin="4" tmax="4" pmin="749" pmax="754" wsmin="2" wsmax="6"
hummin="76" hummax="88" cl="3" pt="1" pr="2" ts="0" icon="d.sun.c4.r2" descr="Пасмурно, дождь" p="751" ws="6" wd="6" hum="82"
grademax="4" prflt="11.3" dit="0" phase="54.9"><forecast valid="2024-06-28T02:00:00" tod="0"><values t="4" p="749" ws="6" wd="6" hum="85" hi="0" cl="3" pt="1" pr="2" ts="0" water_t="6" icon="d.sun.c4.r2" code="Array"
descr="Пасмурно, дождь" grade="2" prflt="8.3"/></forecast><forecast valid="2024-06-28T08:00:00" tod="1"><values t="4" p="750" ws="4" wd="7" hum="85" hi="0" cl="3" pt="1" pr="2" ts="0" water_t="6" icon="d.sun.c4.r2" code="Array"
descr="Пасмурно, дождь" grade="1" prflt="3"/></forecast><forecast valid="2024-06-28T14:00:00" tod="2"><values t="4" p="752" ws="5" wd="8" hum="80" hi="0" cl="3" pt="1" pr="0" ts="0" water_t="6" icon="d.sun.c4" code="Array"
descr="Пасмурно" grade="1" prflt="0"/></forecast><forecast valid="2024-06-28T20:00:00" tod="3"><values t="4" p="754" ws="5" wd="8" hum="77" hi="0" cl="2" pt="0" pr="0" ts="0" water_t="6" icon="d.sun.c3" code="Array"
descr="Облачно" grade="3" prflt="0"/></forecast></day><day date="2024-06-29" risem="102" setm="39" durm="1440" tmin="4" tmax="7" pmin="754" pmax="755" wsmin="1" wsmax="2"
hummin="73" hummax="83" cl="1" pt="0" pr="0" ts="0" icon="d.sun.c2" descr="Малооблачно" p="755" ws="2" wd="7" hum="79"
grademax="4" prflt="0" dit="0" phase="43.4"><forecast valid="2024-06-29T02:00:00" tod="0"><values t="4" p="755" ws="1" wd="7" hum="82" hi="4" cl="1" pt="0" pr="0" ts="0" water_t="6" icon="d.sun.c2" code="Array"
descr="Малооблачно" grade="4" prflt="0"/></forecast><forecast valid="2024-06-29T08:00:00" tod="1"><values t="5" p="755" ws="1" wd="7" hum="81" hi="4" cl="1" pt="0" pr="0" ts="0" water_t="6" icon="d.sun.c2" code="Array"
descr="Малооблачно" grade="2" prflt="0"/></forecast><forecast valid="2024-06-29T14:00:00" tod="2"><values t="6" p="755" ws="2" wd="7" hum="76" hi="6" cl="1" pt="0" pr="0" ts="0" water_t="6" icon="d.sun.c2" code="Array"
descr="Малооблачно" grade="2" prflt="0"/></forecast><forecast valid="2024-06-29T20:00:00" tod="3"><values t="7" p="754" ws="2" wd="6" hum="75" hi="6" cl="1" pt="0" pr="0" ts="0" water_t="6" icon="d.sun.c2" code="Array"
descr="Малооблачно" grade="1" prflt="0"/></forecast></day><day date="2024-06-30" risem="102" setm="39" durm="1440" tmin="5" tmax="7" pmin="754" pmax="756" wsmin="1" wsmax="2"
hummin="73" hummax="81" cl="0" pt="0" pr="0" ts="0" icon="d.sun" descr="Ясно" p="755" ws="2" wd="7" hum="77"
grademax="2" prflt="0" dit="0" phase="32.4"></day><day date="2024-07-01" risem="102" setm="39" durm="1440" tmin="5" tmax="7" pmin="756" pmax="756" wsmin="1" wsmax="2"
hummin="73" hummax="86" cl="2" pt="0" pr="0" ts="0" icon="d.sun.c3" descr="Облачно" p="756" ws="2" wd="7" hum="79"
grademax="2" prflt="0" dit="0" phase="22.3"></day><day date="2024-07-02" risem="102" setm="39" durm="1440" tmin="6" tmax="8" pmin="755" pmax="756" wsmin="1" wsmax="2"
hummin="73" hummax="82" cl="3" pt="1" pr="0" ts="0" icon="d.sun.c4" descr="Пасмурно" p="756" ws="2" wd="4" hum="78"
grademax="2" prflt="0" dit="0" phase="13.7"></day><day date="2024-07-03" risem="102" setm="39" durm="1440" tmin="6" tmax="10" pmin="756" pmax="756" wsmin="0" wsmax="1"
hummin="71" hummax="84" cl="3" pt="0" pr="0" ts="0" icon="d.sun.c4" descr="Пасмурно" p="756" ws="1" wd="2" hum="77"
grademax="2" prflt="0" dit="0" phase="7.1"></day><day date="2024-07-04" risem="102" setm="39" durm="1440" tmin="8" tmax="12" pmin="755" pmax="756" wsmin="1" wsmax="2"
hummin="53" hummax="80" cl="2" pt="0" pr="0" ts="0" icon="d.sun.c3" descr="Облачно" p="756" ws="2" wd="3" hum="63"
grademax="2" prflt="0" dit="0" phase="2.6"></day></location></weather>
Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<weather>
<location id="74819" name="Баренцбург" name_r="в Баренцбурге" tzone="120" cur_time="2024-06-26T09:51:00">
<fact valid="2024-06-27T23:00:00" tod="0" risem="102" setm="39" durm="1440" sunrise="1713404520" sunset="1724459940">
<values t="5" p="752" ws="5" wd="6" hum="84" hi="0" cl="3" pt="1" pr="1" ts="0" water_t="6" icon="d.sun.c4.r1" descr="Пасмурно, небольшой дождь" grade="2" ph="61" />
</fact>
<day
date="2024-06-28"
risem="102"
setm="39"
durm="1440"
tmin="4"
tmax="4"
pmin="749"
pmax="754"
wsmin="2"
wsmax="6"
hummin="76"
hummax="88"
cl="3"
pt="1"
pr="2"
ts="0"
icon="d.sun.c4.r2"
descr="Пасмурно, дождь"
p="751"
ws="6"
wd="6"
hum="82"
grademax="4"
prflt="11.3"
dit="0"
phase="54.9"
>
<forecast valid="2024-06-28T02:00:00" tod="0">
<values t="4" p="749" ws="6" wd="6" hum="85" hi="0" cl="3" pt="1" pr="2" ts="0" water_t="6" icon="d.sun.c4.r2" code="Array" descr="Пасмурно, дождь" grade="2" prflt="8.3" />
</forecast>
<forecast valid="2024-06-28T08:00:00" tod="1"><values t="4" p="750" ws="4" wd="7" hum="85" hi="0" cl="3" pt="1" pr="2" ts="0" water_t="6" icon="d.sun.c4.r2" code="Array" descr="Пасмурно, дождь" grade="1" prflt="3" /></forecast>
<forecast valid="2024-06-28T14:00:00" tod="2"><values t="4" p="752" ws="5" wd="8" hum="80" hi="0" cl="3" pt="1" pr="0" ts="0" water_t="6" icon="d.sun.c4" code="Array" descr="Пасмурно" grade="1" prflt="0" /></forecast>
<forecast valid="2024-06-28T20:00:00" tod="3"><values t="4" p="754" ws="5" wd="8" hum="77" hi="0" cl="2" pt="0" pr="0" ts="0" water_t="6" icon="d.sun.c3" code="Array" descr="Облачно" grade="3" prflt="0" /></forecast>
</day>
<day
date="2024-06-29"
risem="102"
setm="39"
durm="1440"
tmin="4"
tmax="7"
pmin="754"
pmax="755"
wsmin="1"
wsmax="2"
hummin="73"
hummax="83"
cl="1"
pt="0"
pr="0"
ts="0"
icon="d.sun.c2"
descr="Малооблачно"
p="755"
ws="2"
wd="7"
hum="79"
grademax="4"
prflt="0"
dit="0"
phase="43.4"
>
<forecast valid="2024-06-29T02:00:00" tod="0"><values t="4" p="755" ws="1" wd="7" hum="82" hi="4" cl="1" pt="0" pr="0" ts="0" water_t="6" icon="d.sun.c2" code="Array" descr="Малооблачно" grade="4" prflt="0" /></forecast>
<forecast valid="2024-06-29T08:00:00" tod="1"><values t="5" p="755" ws="1" wd="7" hum="81" hi="4" cl="1" pt="0" pr="0" ts="0" water_t="6" icon="d.sun.c2" code="Array" descr="Малооблачно" grade="2" prflt="0" /></forecast>
<forecast valid="2024-06-29T14:00:00" tod="2"><values t="6" p="755" ws="2" wd="7" hum="76" hi="6" cl="1" pt="0" pr="0" ts="0" water_t="6" icon="d.sun.c2" code="Array" descr="Малооблачно" grade="2" prflt="0" /></forecast>
<forecast valid="2024-06-29T20:00:00" tod="3"><values t="7" p="754" ws="2" wd="6" hum="75" hi="6" cl="1" pt="0" pr="0" ts="0" water_t="6" icon="d.sun.c2" code="Array" descr="Малооблачно" grade="1" prflt="0" /></forecast>
</day>
<day
date="2024-06-30"
risem="102"
setm="39"
durm="1440"
tmin="5"
tmax="7"
pmin="754"
pmax="756"
wsmin="1"
wsmax="2"
hummin="73"
hummax="81"
cl="0"
pt="0"
pr="0"
ts="0"
icon="d.sun"
descr="Ясно"
p="755"
ws="2"
wd="7"
hum="77"
grademax="2"
prflt="0"
dit="0"
phase="32.4"
></day>
<day
date="2024-07-01"
risem="102"
setm="39"
durm="1440"
tmin="5"
tmax="7"
pmin="756"
pmax="756"
wsmin="1"
wsmax="2"
hummin="73"
hummax="86"
cl="2"
pt="0"
pr="0"
ts="0"
icon="d.sun.c3"
descr="Облачно"
p="756"
ws="2"
wd="7"
hum="79"
grademax="2"
prflt="0"
dit="0"
phase="22.3"
></day>
<day
date="2024-07-02"
risem="102"
setm="39"
durm="1440"
tmin="6"
tmax="8"
pmin="755"
pmax="756"
wsmin="1"
wsmax="2"
hummin="73"
hummax="82"
cl="3"
pt="1"
pr="0"
ts="0"
icon="d.sun.c4"
descr="Пасмурно"
p="756"
ws="2"
wd="4"
hum="78"
grademax="2"
prflt="0"
dit="0"
phase="13.7"
></day>
<day
date="2024-07-03"
risem="102"
setm="39"
durm="1440"
tmin="6"
tmax="10"
pmin="756"
pmax="756"
wsmin="0"
wsmax="1"
hummin="71"
hummax="84"
cl="3"
pt="0"
pr="0"
ts="0"
icon="d.sun.c4"
descr="Пасмурно"
p="756"
ws="1"
wd="2"
hum="77"
grademax="2"
prflt="0"
dit="0"
phase="7.1"
></day>
<day
date="2024-07-04"
risem="102"
setm="39"
durm="1440"
tmin="8"
tmax="12"
pmin="755"
pmax="756"
wsmin="1"
wsmax="2"
hummin="53"
hummax="80"
cl="2"
pt="0"
pr="0"
ts="0"
icon="d.sun.c3"
descr="Облачно"
p="756"
ws="2"
wd="3"
hum="63"
grademax="2"
prflt="0"
dit="0"
phase="2.6"
></day>
</location>
</weather>
-
- Posts: 158
- Joined: March 15th, 2024, 7:30 pm
Re: Can't pass measure value to web parser
I initially chose what to do, capture everything and then discard the excess or capture only what is needed. And I didn’t know how to discard this unnecessary thing, hide the meter? I couldn't fully imagine it. So I chose a way to capture only what is needed. At first it seemed easier to me.Yincognito wrote: ↑June 27th, 2024, 11:57 pm should be parsed easily in a single request, grabbing all the forecast (even then one you don't need it), and filter it afterwards without requesting data again or bothering with all those checks or corrections. By the way, if you look closely, it appears that you can have even 6 hours between forecasts.
-
- Rainmeter Sage
- Posts: 8171
- Joined: February 27th, 2015, 2:38 pm
- Location: Terra Yincognita
Re: Can't pass measure value to web parser
Hiding meters is one way to discard unneeded stuff if the meter layout is suited for a variable number of meters and the gaps between them, which can affect their arrangement. Another is substituting the measures or setting the meters to some default images and text while keeping their positions. Another is drawing the meters with an alpha (opacity) of 0, also while keeping their positioning, though this can create undesirable blank areas in the skin. Another is leave all meters and just modify their positions / offsets (or the position of the first, if they use relative positioning) and use a container meter to hide the ones outside it. And so on, it depends on the layout in the skin and your imagination / creativity.Kotofanchik wrote: ↑June 28th, 2024, 12:13 am I initially chose what to do, capture everything and then discard the excess or capture only what is needed. And I didn’t know how to discard this unnecessary thing, hide the meter? I couldn't fully imagine it. So I chose a way to capture only what is needed. At first it seemed easier to me.
But yeah, you're right, capturing only what's needed should be better and easier - I'm just saying that it could have been done in a single request and without complicating things with setting all kinds of options to suit this multiple request approach. In any case, what's done is done, in the end, based on your feedback, it mostly works, so it was just an afterthought, by no means mandatory. No point in reworking it again, though it's worth considering a more efficient plan for similar cases that might happen in the future.
-
- Posts: 158
- Joined: March 15th, 2024, 7:30 pm
Re: Can't pass measure value to web parser
Is it possible to enter the value obtained by measure into a file? [!WriteKeyValue Variables DummyDate [fullDate] "Settings.inc"] writes the characters themselves [fullDate] but not the value
I figured it out myself and lost the letter. Measure is mfullDate, but I was too lazy to write and copied the name, losing part of it. That's how it works. [!WriteKeyValue Variables DummyDate [mfullDate] "Settings.inc"] And the error in the log in the skin was removed
Oh, no, it doesn’t always work, not for all places. We still have to rack our brains.
I figured it out myself and lost the letter. Measure is mfullDate, but I was too lazy to write and copied the name, losing part of it. That's how it works. [!WriteKeyValue Variables DummyDate [mfullDate] "Settings.inc"] And the error in the log in the skin was removed
Oh, no, it doesn’t always work, not for all places. We still have to rack our brains.
You do not have the required permissions to view the files attached to this post.