Weather reports with curl
theptrk.com
theptrk.com
For newbies who might be misled, cURL is available on a ridiculous number of platforms[1]
If you use emacs, I've made this [1][2] which gets its data from DarkSky.net.
[1] https://github.com/cadadr/elisp/blob/master/forecast.el
[2] https://raw.githubusercontent.com/cadadr/elisp/master/foreca...
If you read it long enough, you'll start to pick up some of the 'why' in the weather.
Here's an example:
https://forecast.weather.gov/product.php?site=NWS&issuedby=M...
I suppose you could curl it...
If it's stable, then it might be fun to write a cli client to query/display this..
#!/usr/bin/python
import requests
import re
SHOW_GROUPS = ['SYNOPSIS', 'DISCUSSION', 'MTR WATCHES/WARNINGS/ADVISORIES']
CITY = 'MTR'
txt = requests.get('https://forecast.weather.gov/product.php?site=NWS&issuedby='+CITY+'&product=AFD&format=txt&version=1&glossary=0', timeout=30).text
m = re.search(r'(?mis)<pre class="glossaryProduct">(.*)</pre>', txt)
groups = m.group(1).split('&&\n')
for g in groups:
m = re.search(r'\.(.*?)\.\.\.', g)
if m and m.group(1) in SHOW_GROUPS:
print(g.strip()+'\n')https://media.ccc.de/v/gpn18-164-using-and-creating-console-...
As a particularly disasterous example, the Yahoo Weather API was unchanged for the longest time. Integrators worldwide deployed thousands - no probably millions - of systems using an unofficial "Yahoo Weather Module". It was the canonical solution.
Then they made a breaking change to the API and everyone cried.
The geolocation is off (as usual) because it uses the same DB as ipleak.net and others which is wrong for my (semi static) cable IPv4. I don't mind though, I just add some city.
It doesn't show well in a standard 80x25 terminal either, and that I do mind. That's my main issue with it.
So I ended up with:
n=0 ; while (( $n <= 72 )) ; date ; do curl wttr.in/~Amsterdam?0 ; sleep 1200 ; n=$(( n+1 )) ; done
Which grabs the weather every 20 min for 24 hours straight after which it has to be restarted. Not sure how it deals with laptop's suspend though.
watch -cn 1200 didn't work for me because while it does parse the ascii colors, it doesn't show them.
Since that hammers the servers though I'd write an alias for wttr.in/~Amsterdam?0 such as 'gcw' ("get current weather") or something like that.
Anyway, instead of having a dedicated terminal for this open (e.g. in Tmux) its probably better to queue for this every X minutes in Tmux statusbar as someone else suggested.
For now though I just use the KNMI application on Android though which gives a notification in the morning and evening about the weather (the evening one also describing the forecast for next day). Its basically as if watching the weather forecast on TV. I get the notification on my smartwatch as well (Pebble 2).
Also, this doesn't beat Android's Buienalarm push notification service which alerts you right before it is going to rain on current location plus locations you specified (home, work, family, etc)
> We were unable to find your location so we have brought you to Oymyakon, one of the coldest permanently inhabited locales on the planet.
The weather report is nice but doesn't work too well with rxvt-unicode or with a light-coloured background.
docs: https://github.com/chubin/wttr.in/blob/master/README.md
The wind arrows are not ASCII. Not that I have any trouble with that.
Well done Windows, well done. ;)
(Yes, I know why it looks crap)