Simple Weather Label

Discuss and share scripts and script files...
serendipity
Posts: 3360
Joined: 07 May 2007 18:14
Location: NJ/NY

Re: Simple Weather Label

Post by serendipity »

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. :appl:
Thanks! :mrgreen:

serendipity
Posts: 3360
Joined: 07 May 2007 18:14
Location: NJ/NY

Re: Simple Weather Label

Post by serendipity »

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"/>
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).

nerdweed
Posts: 648
Joined: 25 Feb 2012 07:47

Re: Simple Weather Label

Post by nerdweed »

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).
Google pulling out the api has higher probability.
admin wrote: OK, I know what a tooltip is, but I did not understand your post (and still don't). :|
I wondered why did you ask tooltips? and still considered it literally and posted that stupid screenshot.

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

Post by admin »

And this is the weather in cologne (told in buttons):
weathercologne.png
weathercologne.png (1.65 KiB) Viewed 3138 times

serendipity
Posts: 3360
Joined: 07 May 2007 18:14
Location: NJ/NY

Re: Simple Weather Label

Post by serendipity »

admin wrote:And this is the weather in cologne (told in buttons):
weathercologne.png
:lol:

ggonline
Posts: 8
Joined: 10 Aug 2013 07:49

Re: Simple Weather Label

Post by ggonline »

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) :naughty: or :cry:

Creepy Eyes - linked to your webcam and motion sensor, two eyes follow as you move or walk past the computer. :roll: or :evil:

NSA (U.S. National Security Agency) - the last electronic communication you sent/received (email, SMS, phone number, or video/audio media, ...) 8) or :ugeek:

admin
Site Admin
Posts: 65012
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Simple Weather Label

Post by admin »

Google broke the Weather Label. :(

see https://support.google.com/websearch/answer/2664197

klownboy
Posts: 4398
Joined: 28 Feb 2012 19:27
Location: Windows 11, 25H2 Build 26200.7171 at 100% 2560x1440

Re: Simple Weather Label

Post by klownboy »

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

Post by admin »

klownboy wrote:That is too bad. I was getting used to that temperature CTB. Now all I get is a big F.
Same here. Now all I get is a big C. :|

klownboy
Posts: 4398
Joined: 28 Feb 2012 19:27
Location: Windows 11, 25H2 Build 26200.7171 at 100% 2560x1440

Re: Simple Weather Label

Post by klownboy »

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 AB

Code: Select all

::$url=readurl("http://weather.yahooapis.com/forecastrss?w=667931&u=c"); msg $url;
it'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=")
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

Post by admin »

Cool! I'm sure the weather man serendipity will read this... :whistle:

klownboy
Posts: 4398
Joined: 28 Feb 2012 19:27
Location: Windows 11, 25H2 Build 26200.7171 at 100% 2560x1440

Re: Simple Weather Label

Post by klownboy »

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.

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");
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. :biggrin: 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

admin
Site Admin
Posts: 65012
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Simple Weather Label

Post by admin »

Cool, works! :appl: (only 9C :()

serendipity
Posts: 3360
Joined: 07 May 2007 18:14
Location: NJ/NY

Re: Simple Weather Label

Post by serendipity »

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. :)

serendipity
Posts: 3360
Joined: 07 May 2007 18:14
Location: NJ/NY

Re: Simple Weather Label

Post by serendipity »

admin wrote:Cool, works! :appl: (only 9C :()
Haha, New York is quite warm today, 20C :P

Post Reply