It is currently June 27th, 2024, 5:54 pm

⭐ Weather.com - Parsing the V3 JSON

Our most popular Tips and Tricks from the Rainmeter Team and others
User avatar
Yincognito
Rainmeter Sage
Posts: 7545
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: ⭐ Weather.com - Parsing the JSON

Post by Yincognito »

jsmorley wrote: June 5th, 2020, 1:34 pmI think I'm just going to replace all the @Include files with the new stuff. [...] I'll certainly keep it around in case we need it.
Ok then. ;-)
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
SilverAzide
Rainmeter Sage
Posts: 2676
Joined: March 23rd, 2015, 5:26 pm

Re: ⭐ Weather.com - Parsing the JSON

Post by SilverAzide »

OnyxBlack wrote: June 5th, 2020, 1:36 pm I'm not sure if this is related to that, but I did do some modifications on the @Forecast[day]DayLong/-Short measures, on my orginal post on page 23 I explained my reasoning. Just making sure.
Yep it is related to that... Also, JSMorley, you may need to adjust the "trigger" measure in your example skin that detects the Day/Night change. IIRC, you were using the day name coming back blank, but the new measures always have a value now. I just used the day temperature instead as the trigger, so it is a trivial fix.
Last edited by SilverAzide on June 5th, 2020, 1:41 pm, edited 1 time in total.
Gadgets Wiki GitHub More Gadgets...
User avatar
jsmorley
Developer
Posts: 22642
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: ⭐ Weather.com - Parsing the JSON

Post by jsmorley »

I'll just change my skin to use @ForecastTodayDayPart and @ForecastTodayNightPart as needed.
User avatar
jsmorley
Developer
Posts: 22642
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: ⭐ Weather.com - Parsing the JSON

Post by jsmorley »

SilverAzide wrote: June 5th, 2020, 1:40 pm Yep it is related to that... Also, JSMorley, you may need to adjust the "trigger" measure in your example skin that detects the Day/Night change. IIRC, you were using the day name coming back blank, but the new measures always have a value now. I just used the day temperature instead as the trigger, so it is a trivial fix.
Thanks, I'll do that.
User avatar
jsmorley
Developer
Posts: 22642
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: ⭐ Weather.com - Parsing the V3 JSON

Post by jsmorley »

Ok, I have posted a new version of the .rmskin in the first post of this thread.

If you are currently using the JSON @Include .inc files for your weather skin, and they are not working suddenly, just replace the files:

WeatherComJSONMeasures.inc
WeatherComJSONMoon.inc
WeatherComJSONAlerts.inc

In your @Resources folder with the new versions, refresh your skin, and it should start working again.
TallShultzy
Posts: 62
Joined: March 30th, 2016, 5:02 pm

Re: ⭐ Weather.com - Parsing the V3 JSON

Post by TallShultzy »

Bingo - worked first time. Thanks to all who helped.
User avatar
Yincognito
Rainmeter Sage
Posts: 7545
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: ⭐ Weather.com - Parsing the V3 JSON

Post by Yincognito »

jsmorley wrote: June 5th, 2020, 2:36 pm Ok, I have posted a new version of the .rmskin in the first post of this thread.

If you are currently using the JSON @Include .inc files for your weather skin, and they are not working suddenly, just replace the files:

WeatherComJSONMeasures.inc
WeatherComJSONMoon.inc
WeatherComJSONAlerts.inc

In your @Resources folder with the new versions, refresh your skin, and it should start working again.
Yep, it works very well - good job for all those involved. Me, I just checked and got the new page design as well (the magenta based one) for the main page, a much bigger size of the page source (the V2 was around 400 Kb, the V3 was around 1MB at the beginning but it's now around 2MB), but overall apparently no changes in the format from when I first saved the page sources.

There are some interesting (and significant, in terms of content) changes in the source when using a different language. I used to set the language to en-GB to force the metric system, but apparently this is no longer necessary (hopefully, it will last), and the unit info is right at the start of the JSON part as well, in the twc-unit field from headers (now that is the correct m for me, as in the early stages of V3 it was u - probably from 'unknown' - although the URL parameters were the same). The format and structure of the narrative field is different between en-US and en-GB (that was not necessarily expected), with the UK style more condensed, less commas, shorter phrases, etc. Thankfully, I don't use the narrative, so I won't have to deal with the missing degree sign (i.e. 16C instead of 16°C) and the overall more expansive / chaotic /informal US style compared to the UK one ... but something that I did use was the short phrase, and that is present only in the en-US version (along with the medium phrase, in the observation area) and not in the en-GB version, I guess to compensate the fact that the UK style is much more compact in the narrative area.

Lastly, I believe some fields will suffer other modifications in the future, as I noticed some are present twice (i.e. temperatureMin / temperatureMax from the base forecast vs temperature from the daypart forecast, which are the same), so they might be removed at one point or another.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
jsmorley
Developer
Posts: 22642
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: ⭐ Weather.com - Parsing the V3 JSON

Post by jsmorley »

The units fall into 3 types. "e", which is Imperial, fahrenheit, inches, all that, "m", which is purely Metric, celsius, millibars, etc. and "h", which is the "hybrid" form used in the UK (en-GB) which uses metric for everything except wind speed and visibility distance, which is in mph and mi instead of km/h and km.

OnyxBlack came up with a very nice approach for dealing with those.
User avatar
Yincognito
Rainmeter Sage
Posts: 7545
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: ⭐ Weather.com - Parsing the V3 JSON

Post by Yincognito »

jsmorley wrote: June 5th, 2020, 5:33 pm The units fall into 3 types. "e", which is Imperial, fahrenheit, miles, all that, "m", which is purely Metric, celsius, millibars, etc. and "h", which is the "hybrid" form used in the UK (en-GB) which uses metric for everything except wind speed, which is in mph instead of km/h.

OnyxBlack came up with a very nice approach for dealing with those.
I'm sure he did - he saved you some time with the whole rewriting the thing, kudos to him. ;-)
I know about the unit differences (I too posted the same info eariler in this thread, if I'm not mistaken :D ), I just noticed that now the site seems to "auto-detect" the system probably based on location, even if you don't specifically set the language. Not sure if it's permanent or just my impression, but it would be nice to be like that on a consistent basis. I mentioned the changes in the page source regarding that just for reference, because in the end, it's just 3 countries using the imperial system (US, Myanmar and Liberia) and the hybrid system doesn't seem to be used even in the case of setting the language to en-GB, so the whole unit system setting can be done entirely locally, without even bothering extracting it from the source.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
jsmorley
Developer
Posts: 22642
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: ⭐ Weather.com - Parsing the V3 JSON

Post by jsmorley »

Huh. I get "h" for the units when I set en-GB as the language.


1.jpg
You do not have the required permissions to view the files attached to this post.