It is currently April 25th, 2024, 2:15 am

WebParsers only work on first load, not refresh - multiple connected

Get help with creating, editing & fixing problems with skins
User avatar
poisonborz
Posts: 10
Joined: November 25th, 2009, 6:52 pm

WebParsers only work on first load, not refresh - multiple connected

Post by poisonborz »

I built 3 connected queries for a weather widget. IP Location, city -> Weather.com code for city -> Weather.com query.
The problem is that this setup works only on the first load. Eg. when I right click/refresh there is no value, and I can't debug where it gets stuck. I sometimes managed to consistently crash Rainmeter with this.
Is there some error? Is there a better pattern for this setup?

Code: Select all

[MeasureLocation]
Measure=Plugin
Plugin=WebParser
URL=http://mylocation.org
RegExp=(?siU)City.*<td>(.*)</td>
UpdateRate=3300
FinishAction=[!CommandMeasure WeatherCode "Update"]

[MeasureCity]
Measure=Plugin
Plugin=WebParser
URL=[MeasureLocation]
StringIndex=1

[WeatherCode]
Measure=Plugin
Plugin=WebParser
DynamicVariables=1
URL=https://weather.codes/search/?q=[&MeasureCity]
RegExp=(?siU)<dt>(.*)</dt>
UpdateRate=-1
FinishAction=[!CommandMeasure MeasureWeatherNow "Update"][!CommandMeasure MeasureWeatherForecast "Update"]

[MeasureWeatherCode]
Measure=Plugin
Plugin=WebParser
DynamicVariables=1
URL=[WeatherCode]
StringIndex=1

[MeasureWeatherNow]
Measure=Plugin
Plugin=Plugins\WebParser.dll
UpdateRate=-1
DynamicVariables=1
Url=http://wxdata.weather.com/wxdata/weather/local/[&MeasureWeatherCode]?cc=*&unit=m&dayf=0
RegExp="(?siU).*<locale>(.*)</locale>.*<ut>(.*)</ut>.*<ud>(.*)</ud>.*<us>(.*)</us>.*<up>(.*)</up>.*<ur>(.*)</ur>.*<loc id="(.*)">.*<dnam>(.*)</dnam>.*<tm>(.*)</tm>.*<lat>(.*)</lat>.*<lon>(.*)</lon>.*<sunr>(.*)</sunr>.*<suns>(.*)</suns>.*<zone>(.*)</zone>.*<cc>.*<lsup>(.*)</lsup>.*<obst>(.*)</obst>.*<tmp>(.*)</tmp>.*<flik>(.*)</flik>.*<t>(.*)</t>.*<icon>(.*)</icon>.*<bar>.*<r>(.*)</r>.*<d>(.*)</d>.*<wind>.*<s>(.*)</s>.*<gust>(.*)</gust>.*<d>(.*)</d>.*<t>(.*)</t>.*<hmid>(.*)</hmid>.*<vis>(.*)</vis>.*<uv>.*<i>(.*)</i>.*<t>(.*)</t>.*<dewp>(.*)</dewp>.*<moon>.*<icon>(.*)</icon>.*<t>(.*)</t>.*"

[MeasureWeatherForecast]
Measure=Plugin
Plugin=Plugins\WebParser.dll
UpdateRate=-1
DynamicVariables=1
Url=http://wxdata.weather.com/wxdata/weather/local/[&MeasureWeatherCode]?cc=*&unit=m&dayf=6
RegExp=(?siU).*<day d="1" t="(.*)".*<hi>(.*)</hi>.*<low>(.*)</low>.*<icon>(.*)</icon>.* d="2" t="(.*)".*<hi>(.*)</hi>.*<low>(.*)</low>.*<icon>(.*)</icon>.* d="3" t="(.*)".*<hi>(.*)</hi>.*<low>(.*)</low>.*<icon>(.*)</icon>.* d="4" t="(.*)".*<hi>(.*)</hi>.*<low>(.*)</low>.*<icon>(.*)</icon>.* d="5" t="(.*)".*<hi>(.*)</hi>.*<low>(.*)</low>.*<icon>(.*)</icon>.*
User avatar
balala
Rainmeter Sage
Posts: 16168
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: WebParsers only work on first load, not refresh - multiple connected

Post by balala »

poisonborz wrote: October 28th, 2018, 1:01 pm I built 3 connected queries for a weather widget. IP Location, city -> Weather.com code for city -> Weather.com query.
The problem is that this setup works only on the first load. Eg. when I right click/refresh there is no value, and I can't debug where it gets stuck. I sometimes managed to consistently crash Rainmeter with this.
Is there some error? Is there a better pattern for this setup?
Instead of setting an UpdateRate=-1 option on parent WebParser measures ([WeatherCode], [MeasureWeatherNow] and [MeasureWeatherForecast]) better disable them adding a Disabled=1 option to each of them, then enable and update each of them when the previous measure gets the values.
So:
  • Add a Disabled=1 option to [WeatherCode], [MeasureWeatherNow] and [MeasureWeatherForecast] measures.
  • Remove all UpdateRate=-1 options.
  • Add the following FinishAction options to the appropriate measures:

    Code: Select all

    [MeasureLocation]
    ...
    FinishAction=[!EnableMeasure "WeatherCode"][!CommandMeasure "WeatherCode" "Update"]
    ...
    
    [WeatherCode]
    ...
    FinishAction=[!EnableMeasure "MeasureWeatherNow"][!EnableMeasure "MeasureWeatherForecast"][!CommandMeasure MeasureWeatherNow "Update"][!CommandMeasure MeasureWeatherForecast "Update"]
    ...
    Take care to not remove the existing options, just replace / add the above ones.
User avatar
poisonborz
Posts: 10
Joined: November 25th, 2009, 6:52 pm

Re: WebParsers only work on first load, not refresh - multiple connected

Post by poisonborz »

balala wrote: October 28th, 2018, 2:26 pm Instead of setting an UpdateRate=-1 option on parent WebParser measures ([WeatherCode], [MeasureWeatherNow] and [MeasureWeatherForecast]) better disable them adding a Disabled=1 option to each of them, then enable and update each of them when the previous measure gets the values.
Yeah, it now works also on forced refreshes - and is also more efficient! Thanks a lot for looking through the code!
(As for Rainmeter, it's still a bit unsettling that it crashes when 2-3 webparsers start at the same time)
User avatar
balala
Rainmeter Sage
Posts: 16168
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: WebParsers only work on first load, not refresh - multiple connected

Post by balala »

poisonborz wrote: October 28th, 2018, 6:48 pm (As for Rainmeter, it's still a bit unsettling that it crashes when 2-3 webparsers start at the same time)
Not exactly the same question, but there is a known issue of WebParser measures: https://forum.rainmeter.net/viewtopic.php?f=5&t=26117&p=136507&hilit=webparser+hang#p136507
I'm glad if you got it working better.