It is currently March 28th, 2024, 9:25 am

Parsing/Downloading Weather Icons...

Get help with creating, editing & fixing problems with skins
User avatar
kyriakos876
Posts: 919
Joined: January 30th, 2017, 2:01 am
Location: Greece

Parsing/Downloading Weather Icons...

Post by kyriakos876 »

Hello, I want to use weather icons that are uploaded on the internet. How can I do that?
The link is : https://ssl.gstatic.com/onebox/weather/48/sunny.png
The icons are named after each weather condition (or at least I think... I found the link by inspecting google weather icon's and I think it works that way), so I have a measure that holds the name of the condition that goes like:

Code: Select all

[CurrentConditionsChild]
Measure=Plugin
Group=Weather
Plugin=WebParser
URL=[CurrentConditionsParent]
StringIndex=5
and then I would need a meter that goes like:

Code: Select all

[MeterCurrentIcon]
Meter=Image
MeasureName=CurrentConditionsChild
ImageName="https://ssl.gstatic.com/onebox/weather/%1.png"
DynamicVariables=1
this obviously doesn't work because that's not an Image name but a URL, so how could I download it and use it?

-Thanks in advance!
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Parsing/Downloading Weather Icons...

Post by jsmorley »

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[MeasureCondition]
Measure=String
String=sunny

[MeasureGetIcon]
Measure=WebParser
URL=https://ssl.gstatic.com/onebox/weather/48/[&MeasureCondition].png
DynamicVariables=1
Download=1

[MeterIcon]
Meter=Image
MeasureName=MeasureGetIcon
1.jpg
I am skeptical in the extreme that the .jpg name of the icon is going to consistently match the condition name you are getting, generally a weather feed returns the icon as a number, as in the "48" above, and you would use that to match to an image.
User avatar
kyriakos876
Posts: 919
Joined: January 30th, 2017, 2:01 am
Location: Greece

Re: Parsing/Downloading Weather Icons...

Post by kyriakos876 »

jsmorley wrote:

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[MeasureCondition]
Measure=String
String=sunny

[MeasureGetIcon]
Measure=WebParser
URL=https://ssl.gstatic.com/onebox/weather/48/[&MeasureCondition].png
DynamicVariables=1
Download=1

[MeterIcon]
Meter=Image
MeasureName=MeasureGetIcon
1.jpg

I am skeptical in the extreme that the .jpg name of the icon is going to consistently match the condition name you are getting, generally a weather feed returns the icon as a number, as in the "48" above, and you would use that to match to an image.
jpg? I'm not sure I follow.. ins't that a png image? but yea, I'm not sure about the consistency of the link either.... I only found out about this by playing around today, maybe tomorrow that 48 becomes 49 or 29... who knows... I'll check on it to see how it works in a span of a week/

I tried playing the "48" parameter in the link but putting other numbers resulted in a non-working link, whereas putting weather conditions, returned the corresponding image.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Parsing/Downloading Weather Icons...

Post by jsmorley »

kyriakos876 wrote:jpg? I'm not sure I follow.. ins't that a png image? but yea, I'm not sure about the consistency of the link either.... I only found out about this by playing around today, maybe tomorrow that 48 becomes 49 or 29... who knows... I'll check on it to see how it works in a span of a week/

I tried playing the "48" parameter in the link but putting other numbers resulted in a non-working link, whereas putting weather conditions, returned the corresponding image.
Yeah, sorry, I meant .png.

A link must be exact, so yeah, if you are going to link to those images directly, you will need both the "48" or whatever number it is on any given day, and the "sunny", or whatever condition name it is using. I don't hold out a lot of hope for this working over time.
User avatar
kyriakos876
Posts: 919
Joined: January 30th, 2017, 2:01 am
Location: Greece

Re: Parsing/Downloading Weather Icons...

Post by kyriakos876 »

jsmorley wrote:Yeah, sorry, I meant .png.

A link must be exact, so yeah, if you are going to link to those images directly, you will need both the "48" or whatever number it is on any given day, and the "sunny", or whatever condition name it is using. I don't hold out a lot of hope for this working over time.
Neither do I but only experimenting will let us know... Also, for some reason the code your sent above works on a test as a code alone, but when I try to implement it into my own code, I don't see the icon, what am I doing?

Code: Select all

[CurrentConditionsChild]
Measure=Plugin
Group=Weather
Plugin=WebParser
URL=[CurrentConditionsParent]
StringIndex=5

[MeasureCondition]
Measure=String
String=[CurrentConditionsChild]
DynamicVariables=1

[MeasureGetIcon]
Measure=WebParser
URL=https://ssl.gstatic.com/onebox/weather/48/[&MeasureCondition].png
DynamicVariables=1
Download=1

[MeterIcon]
Meter=Image
MeasureName=MeasureGetIcon
DynamicVariables=1
I even used another measure to make sure it's a string... maybe stupid but I tried it as seen above.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Parsing/Downloading Weather Icons...

Post by jsmorley »

kyriakos876 wrote:Neither do I but only experimenting will let us know... Also, for some reason the code your sent above works on a test as a code alone, but when I try to implement it into my own code, I don't see the icon, what am I doing?

Code: Select all

[CurrentConditionsChild]
Measure=Plugin
Group=Weather
Plugin=WebParser
URL=[CurrentConditionsParent]
StringIndex=5

[MeasureCondition]
Measure=String
String=[CurrentConditionsChild]
DynamicVariables=1

[MeasureGetIcon]
Measure=WebParser
URL=https://ssl.gstatic.com/onebox/weather/48/[&MeasureCondition].png
DynamicVariables=1
Download=1

[MeterIcon]
Meter=Image
MeasureName=MeasureGetIcon
DynamicVariables=1
I even used another measure to make sure it's a string... maybe stupid but I tried it as seen above.
I just used a String measure as a shortcut, since don't have any part of your skin that lets me get the condition name with WebParser. I would think you could just directly use the value of [CurrentConditionsChild] to download the icon.

As to why what you have isn't working, not sure, what are the measures values in About / Skins?
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Parsing/Downloading Weather Icons...

Post by balala »

What would be the URL for all those images? Because there should have to be a lot of such URLs, I suppose.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Parsing/Downloading Weather Icons...

Post by jsmorley »

You are likely going to need a FinishAction on [CurrentConditionsParent] that updates [MeasureGetIcon] when it is done getting stuff. This is because both will be updated when the skin refreshes, but when [MeasureGetIcon] first fires, there won't yet be any values returned by [CurrentConditionsParent], and it won't try again for 10 minutes.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Parsing/Downloading Weather Icons...

Post by jsmorley »

balala wrote:What would be the URL for all those images? Because there should have to be a lot of such URLs, I suppose.
I may be missing something, but I see no hope in this working. You are going to have to know and use both the number, like "48", and the name, like "sunny" to build the URL for the download measure. I am very, very skeptical that the name, like "sunny" is going to consistently match the text used for "conditions". There are hundreds of condition descriptions, and they are not going to create hundreds of different icons, when "partly sunny" and "partly cloudy" more or less mean the same thing.
User avatar
kyriakos876
Posts: 919
Joined: January 30th, 2017, 2:01 am
Location: Greece

Re: Parsing/Downloading Weather Icons...

Post by kyriakos876 »

jsmorley wrote:I just used a String measure as a shortcut, since don't have any part of your skin that lets me get the condition name with WebParser. I would think you could just directly use the value of [CurrentConditionsChild] to download the icon.

As to why what you have isn't working, not sure, what are the measures values in About / Skins?
Ah nevermind... My weather link changed to "Fair" and google changed to "http://ssl.gstatic.com/onebox/weather/64/sunny_s_cloudy.png"
I guess that's not how it works then. Kinda expected, but also disappointed... I'd like downloading the icons temporary rather than having them in the #@# folder.
Post Reply