I'm trying to create a basic weather skin using data from the Open-Meteo API, which returns data in JSON format. I’ve managed to get the JSON downloaded using WebParser, but I’m struggling with parsing out the temperature value.
Here’s a snippet of what I have so far:And in the meter:Code:
[MeasureWeather]Measure=PluginPlugin=WebParserURL=https://api.open-meteo.com/v1/forecast?latitude=52.52&longitude=13.41¤t_weather=trueRegExp=(?siU)"temperature":(.*?),"UpdateRate=600
But all I’m getting is either nothing or just the whole string after "temperature":. I'm not sure if my regex is wrong or if I should be using lookaheads/lookbehinds?Code:
[MeterTemp]Meter=StringMeasureName=MeasureWeather
Does anyone have experience parsing Open-Meteo’s output or know a cleaner way to extract just the current temperature?
https://docs.rainmeter.net/tips/webparser-debugging-regexp/#RainRegExp
Code:
[Rainmeter]Update=1000DynamicWindowSize=1AccurateText=1[MeasureWeather]Measure=WebParserURL=https://api.open-meteo.com/v1/forecast?latitude=52.52&longitude=13.41¤t_weather=trueRegExp=(?siU).*"current_weather_units".*"temperature":"(.*)".*"temperature":(.*),[MeasureUnits]Measure=WebParserURL=[MeasureWeather]StringIndex=1[MeasureTemperature]Measure=WebParserURL=[MeasureWeather]StringIndex=2[MeterTemperature]Meter=StringMeasureName=MeasureTemperatureMeasureName2=MeasureUnitsFontColor=255,255,255,255FontSize=15SolidColor=0,0,0,1Text=%1 %2AntiAlias=1
There is no need for any lookaheads / lookbehinds, as the U in (?siU) makes the expression "ungreedy", so you can just march through the returned text in order, looking first for "temperature" as it is returned in the units values, then "temperature" returning the number of degrees.
Statistics: Posted by jsmorley — Today, 10:19 am