Thanks!aurumdigitus wrote:@serendipity - Having gone "Beta" for reasons stated in Bug Reports, could not resist trying this out. Is somewhere between fiendishly and nefariously clever.
When these new script commends appear in the next Official Release you have provided a nice learning tool.
Simple Weather Label
-
serendipity
- Posts: 3360
- Joined: 07 May 2007 18:14
- Location: NJ/NY
Re: Simple Weather Label
-
serendipity
- Posts: 3360
- Joined: 07 May 2007 18:14
- Location: NJ/NY
Re: Simple Weather Label
My reasons are simple: One, I am too lazy to learn RegExp and two, I tried to pick unique tokens so searching is instant unlike searching for common tokens such as " or others which are so ubiquitous.40k wrote:I did not know you could use the gettoken() function in such a way that it lets you define the prefix like that. I have always used a regEx to get data out of an XML entry of the form <type="value"/>
Either ways with my way or regexp, script will break if xml format changes (or google pulls out its weather api).
Re: Simple Weather Label
Google pulling out the api has higher probability.serendipity wrote: My reasons are simple: One, I am too lazy to learn RegExp and two, I tried to pick unique tokens so searching is instant unlike searching for common tokens such as " or others which are so ubiquitous.
Either ways with my way or regexp, script will break if xml format changes (or google pulls out its weather api).
I wondered why did you ask tooltips? and still considered it literally and posted that stupid screenshot.admin wrote: OK, I know what a tooltip is, but I did not understand your post (and still don't).
Anyways, Borut has explained it already.
-
admin
- Site Admin
- Posts: 65012
- Joined: 22 May 2004 16:48
- Location: Win8.1, Win10, Win11, all @100%
- Contact:
Re: Simple Weather Label
And this is the weather in cologne (told in buttons):
FAQ | XY News RSS | XY X
-
serendipity
- Posts: 3360
- Joined: 07 May 2007 18:14
- Location: NJ/NY
Re: Simple Weather Label
admin wrote:And this is the weather in cologne (told in buttons):
Re: Simple Weather Label
Weather in icons = hieroglyphs of the 21st century.
now create some practical joke icons:
Mother - always asks for confirmation of every action, "Do you really want to do that? Are you sure it is safe?" (smilies examples)
or
Creepy Eyes - linked to your webcam and motion sensor, two eyes follow as you move or walk past the computer.
or
NSA (U.S. National Security Agency) - the last electronic communication you sent/received (email, SMS, phone number, or video/audio media, ...)
or 
now create some practical joke icons:
Mother - always asks for confirmation of every action, "Do you really want to do that? Are you sure it is safe?" (smilies examples)
Creepy Eyes - linked to your webcam and motion sensor, two eyes follow as you move or walk past the computer.
NSA (U.S. National Security Agency) - the last electronic communication you sent/received (email, SMS, phone number, or video/audio media, ...)
-
klownboy
- Posts: 4398
- Joined: 28 Feb 2012 19:27
- Location: Windows 11, 25H2 Build 26200.7171 at 100% 2560x1440
Re: Simple Weather Label
That is too bad. I was getting used to that temperature CTB. Now all I get is a big F.
-
admin
- Site Admin
- Posts: 65012
- Joined: 22 May 2004 16:48
- Location: Win8.1, Win10, Win11, all @100%
- Contact:
Re: Simple Weather Label
Same here. Now all I get is a big C.klownboy wrote:That is too bad. I was getting used to that temperature CTB. Now all I get is a big F.
FAQ | XY News RSS | XY X
-
klownboy
- Posts: 4398
- Joined: 28 Feb 2012 19:27
- Location: Windows 11, 25H2 Build 26200.7171 at 100% 2560x1440
Re: Simple Weather Label
I wonder if Google can't be used, if we could use Yahoo. This site seems to explain what needs to be done.
http://developer.yahoo.com/weather/ You use a WOEID for your area, in Cologne it's "667931" which you can get simply by entering your city and country in Yahoo weather: http://weather.yahoo.com So in your case the URL is http://weather.yahooapis.com/forecastrss?w=667931&u=c with the &u=c for centigrade and for my town it's http://weather.yahooapis.com/forecastrss?w=2410534
Now, how to extract the info...maybe serendipity would know.
Edit: If you plug this into to the ABit's obvious the information is there, it's a matter of changing the code to extract it properly (e.g., <yweather:temp="... instead of the current <temp_c data=")
http://developer.yahoo.com/weather/ You use a WOEID for your area, in Cologne it's "667931" which you can get simply by entering your city and country in Yahoo weather: http://weather.yahoo.com So in your case the URL is http://weather.yahooapis.com/forecastrss?w=667931&u=c with the &u=c for centigrade and for my town it's http://weather.yahooapis.com/forecastrss?w=2410534
Now, how to extract the info...maybe serendipity would know.
Edit: If you plug this into to the AB
Code: Select all
::$url=readurl("http://weather.yahooapis.com/forecastrss?w=667931&u=c"); msg $url;
Last edited by klownboy on 01 Nov 2013 15:56, edited 1 time in total.
-
admin
- Site Admin
- Posts: 65012
- Joined: 22 May 2004 16:48
- Location: Win8.1, Win10, Win11, all @100%
- Contact:
Re: Simple Weather Label
Cool! I'm sure the weather man serendipity will read this... 
FAQ | XY News RSS | XY X
-
klownboy
- Posts: 4398
- Joined: 28 Feb 2012 19:27
- Location: Windows 11, 25H2 Build 26200.7171 at 100% 2560x1440
Re: Simple Weather Label
This is working, at least for Cologne, Germany and Glade Spring, VA - 2 locations I've tried. It's actually a bit simpler because you can specify the unit (C or F) up front.I'm hoping serendipity will take a look and improve it. I'm far from an expert with gettoken. Thanks serendipity.
Don, we could do some really cool things if we could use this information (e.g., wind speed, wind chill, forcast,etc) in tool tips.
I grin because I know you've been asked before and I know you have a overflowing plate. By the way, it's a little warmer here.
Ken
Code: Select all
//Weather in your city (using Yahoo API)
//Simple script that displays temperature in a user button
//You must obtain the WOEID for your location by running http://weather.yahoo.com/ Plug in your city and country and the resultant URL will have the WOEID as the last set of numbers in the URL. Change the WOEID# below to your location's WOEID and in the second line change the temperature unit.
$WOEID=667931; //Cologne, Germany
//$WOEID=2410534; //Glade Spring, VA
$unit="c"; //Set it to c for celsius and f for fahrenheit
$url=readurl("http://weather.yahooapis.com/forecastrss?w=$WOEID&u=$unit");
$TempNow=gettoken($url, 2, "temp=");
$TempNow=gettoken($TempNow, 1, " ");
$TempNow=quote($TempNow,1);
IF($unit LikeI "f"){
$TempNow=quote("""$TempNow"."F""",1);
}
ELSE{
$TempNow=quote("""$TempNow"."C""",1);
}
ctbicon("label: $TempNow >554433,ffffee");
Don, we could do some really cool things if we could use this information (e.g., wind speed, wind chill, forcast,etc) in tool tips.
Ken
-
serendipity
- Posts: 3360
- Joined: 07 May 2007 18:14
- Location: NJ/NY
Re: Simple Weather Label
Cool thanks Klownboy!
But I am going with OpenWeatherMap API because I don't want to deal with another service hanging up.
Updated first post.
But I am going with OpenWeatherMap API because I don't want to deal with another service hanging up.
Updated first post.
-
serendipity
- Posts: 3360
- Joined: 07 May 2007 18:14
- Location: NJ/NY
Re: Simple Weather Label
Haha, New York is quite warm today, 20Cadmin wrote:Cool, works!(only 9C
)
XYplorer Beta Club