It is currently October 12th, 2024, 2:45 am

Yahoo.com - weather.com alternative

Our most popular Tips and Tricks from the Rainmeter Team and others
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5540
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Yahoo.com - weather.com alternative

Post by eclectic-tech »

This may look familiar... I completely 'stole' JSMorley's 'weather.com' to present this 'yahoo.com' version...

With the passing of the wxdata weather feed, several of us thought we might be able to simply parse the information directly from the https://www.yahoo.com/news/weather/ site.

NOTE: Due to changes in the Yahoo Weather Site in December 2022, this skin is no longer functional. It is unlikely I will be making any updates in the near future.


Yahoo.com_1.2020.04.07.rmskin

1 to 10 day display via scrolling
{Click to view animation...}
yahoo10.gif

Much as the other example did, this uses a series of @Include .inc files to eliminate having to figure out regular expression or even create any measures for your skin. It does all the hard work for you!

Then you can just concentrate on the Meters in your skin. All the measures you will need are already there! Just create the meters, and use the MeasureName= options you can easily get by looking at About/Skins to see what the measure names are that are populated. I tried to make the measure names as descriptive as possible, and if you look in the include files, I have done as much commenting as I can.

If you want to "overload" an included measure, for instance to use Substitute or put an IfCondition or IfMatch on the measure, just create a copy of the measure as a Measure=String or Measure=Calc in the skin, and dynamically use the value of the original measure as a [SectionVariable].

I strongly recommend that you DON'T alter YahooComMeasures.inc.
That just reduces its usefulness as something you can just plug into another new skin, and makes is very difficult indeed for you if I update it.


YahooComVariables.inc
This is where you set your Location and Language. Read it for help.
Always @Include this file.

YahooComMeasures.inc
This parses all the JSON code and creates the measures you will need.
Always @Include this file.


YahooComLanguage.inc
This will allow you to translate the "labels" I use in my skin to any other language you want.
This is specific to this skin, and you may not need it for yours.

GeneralVariables.inc
This is where I set all the general font and color variables.
This is specific to this skin, and you may not need it for yours.



Once you @Include YahooComVariables.inc AND YahooComMeasures.inc in your skin, the following measures will be created. You can use About / Skins to see them AND the values they currently have, but here is a list for reference:
; =============================================
; Location Information
; =============================================

[.LocationCity]

[.LocationCountry] United States

[.LocationLatitude]

[.LocationLongitude]

[.LocationTimeZone] This is in minutes from GMT

[.LocationTimeZoneAbbreviation] Substitution is editable

; =============================================
; Current Conditions as of the Observation Time
; =============================================

[.CurrentPressureF] Yahoo returns Imperial values
All conversions to Metric are done in the skin for temperature, pressure, distance, & speed
'TemperatureUnit' variable ('F' or 'C') control which values are displayed
Toggle desired system in the skin context menu

[.CurrentPressureC]

[.CurrentIcon]

[.CurrentObservationDate] Date formatting can be done in the variables

[.CurrentObservationTime] Time formatting can be done in the variables

[.CurrentConditions]

[.CurrentNightNarrative] Night weather forecast

[.CurrentDayNarrative] Day weather forecast

[.CurrentTemperatureF]

[.CurrentTemperatureC]

[.CurrentTemperatureHighF]

[.CurrentTemperatureHighC]

[.CurrentTemperatureLowF]

[.CurrentTemperatureLowC]

[.CurrentFeelsLikeF]

[.CurrentFeelsLikeC]

[.CurrentObservationTimeStamp]

[.CurrentHumidity]

[.CurrentPrecipitationLast24Hours]

[.CurrentUVIndex]

[.CurrentUVDescription]

[.CurrentVisibilityDistanceF]

[.CurrentVisibilityDistanceC]

[.CurrentWindSpeedF]

[.CurrentWindSpeedC]

[.CurrentWindDirectionCompass] Full ex; North West

[.CurrentWindDirectionDegrees] 0~360

[.CurrentSunriseTimeStamp]

[.CurrentSunriseTime]

[.CurrentSunSetTimeStamp]

[.CurrentSunsetTime]

[.CurrentMoonPhase] This is a number value that can reference for images and a string value of the current phase

[.CurrentDayNight] Set 'CurrentTime' variable to 'Day' or 'Night' based on time >= sunset

; ========================================
; Forecasts for today and following 10 days
; ========================================

[.ForecastTodayDayIcon]

[.ForecastTodayDayConditions]

[.ForecastTodayDayNarrative]

[.ForecastTodayNightNarrative]

[.ForecastTodayDayHighTemperatureF]

[.ForecastTodayDayHighTemperatureC]

[.ForecastTodayDayLowTemperatureF]

[.ForecastTodayDayLowTemperatureC]

[.ForecastTodayTimeStamp]

[.ForecastTodayObservationTime]

[.ForecastTodayObservationDate] Full date: Friday, April 3, 2020

[.ForecastTodayObservationDayName] Full day name: Friday

[.ForecastTodayObservationDayNameShort] Short day name: Fri

[.ForecastTodayObservationMonthName] Full month name: April

[.ForecastTodayObservationMonthNameShort] Short month name:Apr

[.ForecastTodayObservationDayOfMonth] month day: 3

[.ForecastTodayDayHumidity]

[.ForecastTodayDayPrecipitationPercent]

; ========================================
; Forecasts for Day 2
; ========================================

[.ForecastDay2Icon]

[.ForecastDay2Conditions]

[.ForecastDay2DayNarrative]

[.ForecastDay2NightNarrative]

[.ForecastDay2HighTemperatureF]

[.ForecastDay2HighTemperatureC]

[.ForecastDay2LowTemperatureF]

[.ForecastDay2LowTemperatureC]

[.ForecastDay2TimeStamp]

[.ForecastDay2ObservationTime]

[.ForecastDay2ObservationDate] Full date: Friday, April 3, 2020

[.ForecastDay2ObservationDayName] Full day name: Friday

[.ForecastDay2ObservationDayNameShort] Short day name: Fri

[.ForecastDay2ObservationMonthName] Full month name: April

[.ForecastDay2ObservationMonthNameShort] Short month name:Apr

[.ForecastDay2ObservationDayOfMonth] month day: 3

[.ForecastDay2Humidity]

[.ForecastDay2PrecipitationPercent]

...

This will follow the same pattern for Day3 through Day10
ADDENDUM
I use a period '.' to define the included measures simply because using '@' does not let the sections show in my Notepad++'s function list.

As far as I can test, Yahoo always returns Imperial values (I did not see a way to force Metric in the parse) so all conversions are done in the skin based on Imperial values being returned by the measures. The context menu offers a toggle of the values. If I missed a way to force metric values, or you are only getting Metric values returned based on your location, please let me know.

The site will automatically determine your location based on your ISP location. If you want a more precise location, go to the site, change to your location, then copy the address bar as 'URLSite={yourAddressBar}' in 'YahooComVariables.inc'.

V 1.2020.04.07
Added a variant Yahoo10.com that can show 1 to 10 days of weather (via mouse Scroll)
Added moon phase substitution as string value; still has a number value related to included images

V 1.2020.04.04c
Reverted to previous parsing scheme (thanks SilverAzide). Tested with multiple locations. Date details (long/short names of month/day, and dayofmonth) added.

My sincere apology to JSMorley for plagiarizing his post format, but it inspired me to look at parsing Yahoo the same way. :oops: :Whistle
You do not have the required permissions to view the files attached to this post.
User avatar
jsmorley
Developer
Posts: 22850
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: yahoo.com - Parsing the JSON

Post by jsmorley »

Nice, always good to have alternatives, given that these weather sites change and even come and go from time to time.
User avatar
SilverAzide
Rainmeter Sage
Posts: 2746
Joined: March 23rd, 2015, 5:26 pm

Re: yahoo.com - Parsing the JSON

Post by SilverAzide »

This is great! Thanks, ET! :thumbup:

The example skin is working, but I am having an issue with the location data. When I use the "auto" location URL, it puts me in the center of the US in Kansas a thousand miles away from me, but the location data parsing works OK even though there is some missing. When I use a specific location, like Fort Hunt, VA, the location data changes its structure and as a result the whole block of location measures fail.

When I use the "auto-location" URL, the regexp works but I get this (revised and formatted for simplicity):

Code: Select all

{
  "weathers": {
    "23424977": {
      "woeid": 23424977,
      "unit": "imperial",
      "location": {
        "woeid": 23424977,
        "photoWoeid": 23424977,
        "displayName": "United States",
        "latitude": 37.167931,
        "longitude": -95.845016,
        "offsetSecs": 0
      }
    }
  },
  "preference": {
    "unit": "imperial"
  }
},
"WeatherLocationStore": {
  "currentLocation": {
    "city": "",
    "country": "United States",
    "lat": "37.16793",
    "lon": "-95.845017",
    "qualifiedName": "United States",
    "state": "",
    "statecode": "",
    "woeid": 23424977
  },
  "favoriteLocations": [],
  "searchLocations": []
}
When I use the sample Fort Hunt URL, the regexp fails because I get this:

Code: Select all

{
  "weathers": {
    "23418210": {
      "woeid": 23418210,
      "unit": "imperial",
      "location": {
        "woeid": 23418210,
        "photoWoeid": 23418210,
        "countryName": "United States",
        "displayName": "Fort Hunt",
        "latitude": 38.736118,
        "longitude": -77.058929,
        "offsetSecs": -14400
      }
    }
  },
  "preference": {
    "unit": "imperial"
  }
},
"WeatherLocationStore": {
  "currentLocation": {
    "woeid": 23418210
  },
  "favoriteLocations": [],
  "searchLocations": []
}
Any ideas?
Gadgets Wiki GitHub More Gadgets...
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5540
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: yahoo.com - Parsing the JSON

Post by eclectic-tech »

Thanks, I will take a look. I may need to revert to my original parser scheme which did not use the "preferences": section.

Just so I understand, when first loaded it places you in Kansas; are you using a Tails or VPN to mod your IP?

If you go to Yahoo, set your location on the site, then copy the Address as your URLSite value, what happens on refresh?

Thanks for the info. I was wonder how the site responds from different locations, and thought the first problems would be from other countries and not the USA...

I will do more testing and see if I can find a solution.
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5540
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: yahoo.com - Parsing the JSON

Post by eclectic-tech »

SilverAzide wrote: April 4th, 2020, 6:17 pm This is great! Thanks, ET! :thumbup:

The example skin is working, but I am having an issue with the location data.
...
Any ideas?
I updated the package in the first post to use my original parsing scheme. V 1.2020.04.04c

Tested it with locations around the world and is working for me.

I expanded the Date details returned by the measures and corrected some duplicate !UpdateMeasureGroup bangs.

I would be curious if you are still having location problems.

Thanks for the feedback :thumbup:
User avatar
SilverAzide
Rainmeter Sage
Posts: 2746
Joined: March 23rd, 2015, 5:26 pm

Re: yahoo.com - Parsing the JSON

Post by SilverAzide »

eclectic-tech wrote: April 5th, 2020, 12:05 am I updated the package in the first post to use my original parsing scheme. V 1.2020.04.04c

Tested it with locations around the world and is working for me.

I expanded the Date details returned by the measures and corrected some duplicate !UpdateMeasureGroup bangs.

I would be curious if you are still having location problems.

Thanks for the feedback :thumbup:
Hi, ET! 04c is working perfectly now, thanks! One caveat is when I try the "auto-location" URL it dies due to missing data, which causes the regex to fail. I'm not using a VPN, but I am using a cellular hotspot. I live in a remote third-world country called "Maryland", and some folks can't get wired internet. I think the service provider isn't associating location data with the IP address or something. But no biggie, the important part is that it works when you give it a proper location.

P.S.: When I navigate to the Yahoo website, it gives me the weather in "United States" (i.e., it can't figure out my location either).
Gadgets Wiki GitHub More Gadgets...
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5540
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: yahoo.com - Parsing the JSON

Post by eclectic-tech »

SilverAzide wrote: April 5th, 2020, 5:34 pm Hi, ET! 04c is working perfectly now, thanks! One caveat is when I try the "auto-location" URL it dies due to missing data, which causes the regex to fail. I'm not using a VPN, but I am using a cellular hotspot. I live in a remote third-world country called "Maryland", and some folks can't get wired internet. I think the service provider isn't associating location data with the IP address or something. But no biggie, the important part is that it works when you give it a proper location.

P.S.: When I navigate to the Yahoo website, it gives me the weather in "United States" (i.e., it can't figure out my location either).
Glad to hear you were able to get it working using the 'manual method' even if you live 'off-the-grid' in Maryland! ;-)

Yeah, that's why the google site also placed you in Kansas when the latitude and longitude can not be obtained; they knew you were in the USA, but couldn't tell where...

I'm still seeing what other JSON information might be obtainable (translations, moon data, etc.) but for now it's good to know you have it working.

Thanks for testing! :rosegift:
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5540
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: yahoo.com - Parsing the JSON

Post by eclectic-tech »

Yahoo.com ~ V 1.2020.04.07

Added a variant Yahoo10.com that can show 1 to 10 days of weather (via mouse Scroll)
Added moon phase substitution as string value; still has a number value related to included images

Updated package in first post...
Raidian
Posts: 2
Joined: June 4th, 2020, 5:41 pm

Re: ⭐ Yahoo.com - weather.com alternative

Post by Raidian »

eclectic-tech wrote: April 4th, 2020, 5:05 am This may look familiar... I completely 'stole' JSMorley's 'weather.com' to present this 'yahoo.com' version...

With the passing of the wxdata weather feed, several of us thought we might be able to simply parse the information directly from the https://www.yahoo.com/news/weather/ site.
Is there anyway to get this borderless? Thanks!
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5540
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: ⭐ Yahoo.com - weather.com alternative

Post by eclectic-tech »

Raidian wrote: June 4th, 2020, 5:43 pm Is there anyway to get this borderless? Thanks!
Set 'StrokeWidth' in [MeterAllBackground] to zero.

Code: Select all

[MeterAllBackground]
Meter=Shape
Shape=Rectangle 0.5,0.5,169,334,12 | Fill Color #BackgroundColor# | StrokeWidth 0 | Stroke Color #FrameColor#
X=0
W=170
H=335
Refresh the skin.