It is currently January 26th, 2021, 9:50 pm

Weatherbox

Weather skins
User avatar
Yincognito
Posts: 2980
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Weatherbox

Post by Yincognito »

QuakeGuy wrote: August 21st, 2020, 3:50 pm What the heck? :? Today my skin stopped working again. After a investigation of the situation i realized, they only changed the part getSunV3DailyForecastUrlConfig to getSunV3DailyForecastWithHeadersUrlConfig.

I get the feeling they do this small changes on purpose. Anyways, if this is still the case tomorrow i will release a tiny update/fix.
And added a responseHeaders subsection at the end of the forecast section, yes. The changes are minor and it can be that they do such things on purpose, but it is what it is. I keep telling people to make their weather skin regex patterns as flexible as possible, at least for the main site JSON, but apparently folks never learn and believe it's too complicated, prefering to rebuild their skins over and over each time such a change occurs. :confused: For example, in my skin, the pattern getting the forecast is stored in a variable which then gets used in the parsing, and was like:

DailyForecast=#Q#(?=[^"]*daily)(?=[^"]*forecast)[^"]*#Q#:(?:(?=.*15day).*15day|)[^\}]*([\{\[]{1}.*[\]\}]{4}+)

where #Q# is just another variable used to store either the unescaped (") or escaped (\") quote, so that I can parse both the main site JSON and the API one using the same regexes. Given the way the patterns are built, no name modification was needed for the change in the forecast section name (it works with both getSunV3DailyForecastUrlConfig and getSunV3DailyForecastWithHeadersUrlConfig) and the only change that was needed to make it work again for the main site JSON was making the number or curly brackets at the end flexible as well (since as I mentioned, they added a new subsection inside the forecast one, which means either less or more brackets here are there), like:

DailyForecast=#Q#(?=[^"]*daily)(?=[^"]*forecast)[^"]*#Q#:(?:(?=.*15day).*15day|)[^\}]*([\{\[]{1}.*[\]\}]{3,4}+)

and that was it. But then, I have to admit, my way doesn't suit everyone, of course, first because it requires a bit more advanced knowledge of regex nd secondly because it's tailored to my skin's approach on things.
User avatar
QuakeGuy
Posts: 30
Joined: February 3rd, 2020, 11:15 pm
Location: Germany

Re: Weatherbox

Post by QuakeGuy »

Yincognito your dynamic approach accessing the JSON sounds interesting. For now i made my regex a bit less static, leaving UrlConfig at the end of each section. We will see how weather.com changes in the near future. Maybe i will rework the JSON access if it needs updates too often.

Btw the fix with version 2.01 is uploaded.
User avatar
Yincognito
Posts: 2980
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Weatherbox

Post by Yincognito »

QuakeGuy wrote: August 23rd, 2020, 2:26 pm Yincognito your dynamic approach accessing the JSON sounds interesting. For now i made my regex a bit less static, leaving UrlConfig at the end of each section. We will see how weather.com changes in the near future. Maybe i will rework the JSON access if it needs updates too often.

Btw the fix with version 2.01 is uploaded.
Yeah, it's a bit of a trade off: while the dynamic code offers great flexibility and easier adaptation to changes, the patterns are a bit harder to understand compared to hardcoded ones. It works for me though - I promised myself that I won't rebuild my skin from scratch again on weather.com changes and so far this approach made it possible (along with being able to parse the V2 site JSON, the V3 site JSON and the V3 API JSON using the same regex patterns, so I can easily switch from getting the data from the main page or the API response).