It is currently April 20th, 2024, 4:37 am

⭐ Weather.com - Parsing the V3 JSON

Our most popular Tips and Tricks from the Rainmeter Team and others
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: ⭐ Weather.com - Parsing the V3 JSON

Post by jsmorley »

pbutler6 wrote: June 14th, 2020, 5:59 pm Thanks for all your arduous work. I was almost finished with a new skin to replace the one from last year when Weather.com suddenly stopped working. After all your speedy effort I fixed things in a couple of weeks instead of the 4 months from last time.

I don't know if you plan to update the JSON measures, but if you do, I suggest that you include sunrise and sunset data for future days. In the evening I am no longer interested in when the sun rose this morning, what I want to know is when is the sun coming up tomorrow. I don't know what data is available on Weather.com, but right now sunrise and sunset are only available in your parsing of the Current section. There are no sunrise and sunset variables for the Forecast section, so I can't retrieve tomorrow's sunrise.
I'll look into adding that, although honestly, how much does it really change from one day to the next? The more the merrier though...
TallShultzy
Posts: 62
Joined: March 30th, 2016, 5:02 pm

Re: ⭐ Weather.com - Parsing the V3 JSON

Post by TallShultzy »

jsmorley, I've altered your Weather.com skin (only the Weather.com.ini) to include the 7 day forecasts and the location name and country.

I've comment all the changes and additions.

Do you want to have a look at it?
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: ⭐ Weather.com - Parsing the V3 JSON

Post by jsmorley »

TallShultzy wrote: June 14th, 2020, 6:18 pm jsmorley, I've altered your Weather.com skin (only the Weather.com.ini) to include the 7 day forecasts and the location name and country.

I've comment all the changes and additions.

Do you want to have a look at it?
Best thing is to start a new thread in "Share Your Creations" and post it there. I'm sure everyone would like to see it, maybe use it.

I wouldn't name the folder "Weather.com" though. You don't want to have folks accidentally replace the one here with your version.
TallShultzy
Posts: 62
Joined: March 30th, 2016, 5:02 pm

Re: ⭐ Weather.com - Parsing the V3 JSON

Post by TallShultzy »

Thanks, I've already renamed it as I use your skin to compare it.
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: ⭐ Weather.com - Parsing the V3 JSON

Post by jsmorley »

pbutler6 wrote: June 14th, 2020, 5:59 pm Thanks for all your arduous work. I was almost finished with a new skin to replace the one from last year when Weather.com suddenly stopped working. After all your speedy effort I fixed things in a couple of weeks instead of the 4 months from last time.

I don't know if you plan to update the JSON measures, but if you do, I suggest that you include sunrise and sunset data for future days. In the evening I am no longer interested in when the sun rose this morning, what I want to know is when is the sun coming up tomorrow. I don't know what data is available on Weather.com, but right now sunrise and sunset are only available in your parsing of the Current section. There are no sunrise and sunset variables for the Forecast section, so I can't retrieve tomorrow's sunrise.
Ok. Here is the Sunrise / Sunset stuff:


WeatherComJSONSun.zip


So just unzip this, put WeatherComJSONSun.inc in your @Resources folder, and @Include it in your skin.

Values for 15 days of Sunrise and Sunset times will be populated in measures in your skin.

I made this a separate file so I could have it be for 15 days, rather than the 7 days the other include files cover. I decided to go with 15 days for this, since there is like literally no change in Sunrise and Sunset in the course of a few days. In the course of 15 days, you might get 2-3 minutes of difference. For what it is worth, Sunrise tomorrow will be pretty much the same time it was today.
You do not have the required permissions to view the files attached to this post.
User avatar
SilverAzide
Rainmeter Sage
Posts: 2604
Joined: March 23rd, 2015, 5:26 pm

Re: ⭐ Weather.com - Parsing the V3 JSON

Post by SilverAzide »

jsmorley wrote: June 14th, 2020, 8:30 pm I made this a separate file so I could have it be for 15 days, rather than the 7 days the other include files cover. I decided to go with 15 days for this, since there is like literally no change in Sunrise and Sunset in the course of a few days. In the course of 15 days, you might get 2-3 minutes of difference. For what it is worth, Sunrise tomorrow will be pretty much the same time it was today.
I think the small daily change is only because we're almost at the summer solstice (June 20). At the spring/fall equinox, the daily change is much greater. I think latitudes figure in there too.
Gadgets Wiki GitHub More Gadgets...
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: ⭐ Weather.com - Parsing the V3 JSON

Post by jsmorley »

SilverAzide wrote: June 15th, 2020, 12:15 am I think the small daily change is only because we're almost at the summer solstice (June 20). At the spring/fall equinox, the daily change is much greater. I think latitudes figure in there too.
Yeah, I expect you are right. I shouldn't trivialize it, I just looked through the next 15 days and said, "And so?"... ;-)
pbutler6
Posts: 100
Joined: April 27th, 2020, 8:10 pm

Re: ⭐ Weather.com - Parsing the V3 JSON

Post by pbutler6 »

Thanks for the new file.

You are right that right now the sunrises and sunsets don't change much. (Here in Massachusetts tomorrow will be 20 seconds longer.) But this is because we are close to the solstice.

Three months from now when we are close to the equinox the length will vary by a couple of minutes a day or 15 minutes a week - not much, but at that time of year I get up to exercise when there is enough light.
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: ⭐ Weather.com - Parsing the V3 JSON

Post by jsmorley »

I have done a major update to the WeatherComJSONMeasures.inc file that creates the measures for your skins.

- Added information for all 15 days in the JSON, instead of the previous limit of 7 days.
- Reworked the order of the measures so it makes it easier to follow in About / Skins.
- Integrated daily Sunrise and Sunset into the main .inc file, and eliminated the now redundant WeatherComJSONSun.inc file.
- Added some additional fields of information to the measures. See the updated MeasureNamesReference.txt for details.

Just drop the new .inc file(s) in your @Resources folder, and refresh your skin. The new .inc file is fully backwards compatible with your existing skins that use it.

The WeatherComJSONVariables.inc file has not changed in format, so you might want to save yours, to avoid having to reset your Language and LocationCode variables.

Get the new .rmskin in the first post of this thread.


Please let me know if you spot 👀 anything wrong, that inc file is a 7,000+ line, 965 measures beast now, and goodness knows I could have botched something with the tons of copy/paste and search/replace I did, don't even get me started on the RegExp involved for each "day"
RegExp=(?siU)"getSunV3DailyForecastUrlConfig":.*"duration:15day;.*"dayOfWeek":\s*\[(?:".*",\s*){0}(".*").*"narrative":\s*\[(?:".*",\s*){0}(".*").*"qpf":\s*\[(?:.*,\s*){0}(.*),.*"qpfSnow":\s*\[(?:.*,\s*){0}(.*),.*"sunriseTimeLocal":\s*\[(?:".*",\s*){0}(".*").*"sunsetTimeLocal":\s*\[(?:".*",\s*){0}(".*").*"temperatureMax":\s*\[(?:null,\s*|.*,\s*){0}(null|.*),.*"temperatureMin":\s*\[(?:null,\s*|.*,\s*){0}(null|.*),.*"cloudCover":\s*\[(?:.*,\s*){0}(.*),\s*(.*)(?:,|\]).*"dayOrNight":\s*\[(?:null,\s*|".*",\s*){0}(null|".*"),\s*(null|".*")(?:,|\]).*"daypartName":\s*\[(?:null,\s*|".*",\s*){0}(null|".*"),\s*(null|".*")(?:,|\]).*"iconCode":\s*\[(?:null,\s*|.*,\s*){0}(null|.*),\s*(null|.*)(?:,|\]).*"narrative":\s*\[(?:null,\s*|".*",\s*){0}(null|".*"),\s*(null|".*")(?:,|\]).*"precipChance":\s*\[(?:null,\s*|.*,\s*){0}(null|.*),\s*(null|.*)(?:,|\]).*"precipType":\s*\[(?:null,\s*|".*",\s*){0}(null|".*"),\s*(null|".*")(?:,|\]).*"qpf":\s*\[(?:null,\s*|.*,\s*){0}(null|.*),\s*(null|.*)(?:,|\]).*"qpfSnow":\s*\[(?:null,\s*|.*,\s*){0}(null|.*),\s*(null|.*)(?:,|\]).*"relativeHumidity":\s*\[(?:null,\s*|.*,\s*){0}(null|.*),\s*(null|.*)(?:,|\]).*"snowRange":\s*\[(?:null,\s*|".*",\s*){0}(null|".*"),\s*(null|".*")(?:,|\]).*"temperature":\s*\[(?:null,\s*|.*,\s*){0}(null|.*),\s*(null|.*)(?:,|\]).*"temperatureHeatIndex":\s*\[(?:null,\s*|.*,\s*){0}(null|.*),\s*(null|.*)(?:,|\]).*"temperatureWindChill":\s*\[(?:null,\s*|.*,\s*){0}(null|.*),\s*(null|.*)(?:,|\]).*"thunderCategory":\s*\[(?:null,\s*|".*",\s*){0}(null|".*"),\s*(null|".*")(?:,|\]).*"thunderIndex":\s*\[(?:null,\s*|.*,\s*){0}(null|.*),\s*(null|.*)(?:,|\]).*"uvDescription":\s*\[(?:null,\s*|".*",\s*){0}(null|".*"),\s*(null|".*")(?:,|\]).*"uvIndex":\s*\[(?:null,\s*|.*,\s*){0}(null|.*),\s*(null|.*)(?:,|\]).*"windDirection":\s*\[(?:null,\s*|.*,\s*){0}(null|.*),\s*(null|.*)(?:,|\]).*"windDirectionCardinal":\s*\[(?:null,\s*|".*",\s*){0}(null|".*"),\s*(null|".*")(?:,|\]).*"windPhrase":\s*\[(?:null,\s*|".*",\s*){0}(null|".*"),\s*(null|".*")(?:,|\]).*"windSpeed":\s*\[(?:null,\s*|.*,\s*){0}(null|.*),\s*(null|.*)(?:,|\]).*"wxPhraseLong":\s*\[(?:null,\s*|".*",\s*){0}(null|".*"),\s*(null|".*")(?:,|\]).*"wxPhraseShort":\s*\[(?:null,\s*|".*",\s*){0}(null|".*"),\s*(null|".*")(?:,|\])
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: ⭐ Weather.com - Parsing the V3 JSON

Post by jsmorley »

Edit June 16, 2020 - Created different versions of WeatherComJSONMeasures.inc based on the number of days you want to forecast.

If you use the full WeatherComJSONMeasures.inc file, that is going to create north of 900 measures in your skin, to support the entire 15 days included in the JSON. I have created versions parsing fewer days, so you don't have to wade through as many measures in About /Skins, many of which you may never use.

WeatherComJSONMeasures.inc
This parses all 15 days of the JSON code and creates the measures you will need.
WeatherComJSONMeasures3Day.inc
This parses 3 days of the JSON code and creates the measures you will need.
WeatherComJSONMeasures5Day.inc
This parses 5 days of the JSON code and creates the measures you will need.
WeatherComJSONMeasures7Day.inc
This parses 7 days of the JSON code and creates the measures you will need.
WeatherComJSONMeasures10Day.inc
This parses 10 days of the JSON code and creates the measures you will need.

Always @Include one and only one of these files.


Get the .rmskin in the first post of this thread.