* [9front] weather: rewrite with a new api
@ 2021-04-03 20:33 kemal
2021-04-05 11:26 ` Sigrid Solveig Haflínudóttir
0 siblings, 1 reply; 4+ messages in thread
From: kemal @ 2021-04-03 20:33 UTC (permalink / raw)
To: 9front
hello,
i have written a new "weather" script using a different api.
old version was using telnet and stopped receiving updates,
this one uses http with hget instead and has recent weather.
diff -r cc26fdf57bb2 rc/bin/weather
--- a/rc/bin/weather Sat Mar 13 14:57:53 2021 +0100
+++ b/rc/bin/weather Sat Apr 03 23:31:49 2021 +0300
@@ -1,46 +1,9 @@
#!/bin/rc
-
-rfork e
-
-DEFAULT=ewr
-
-fn usage{
- echo 'usage: weather 3-letter-city-code' >[1=2]
- echo 'for a list of cities in new york, say' >[1=2]
- echo ' weather ny' >[1=2]
- exit usage
-}
-
-switch($#*){
-case 0
- arg=$DEFAULT
- if(~ $#weather 1)
- arg=$weather
-case 1
- arg=$1
-case *
- usage
-}
-
-switch($arg){
-case [a-zA-Z][a-zA-Z][a-zA-Z]
- script=('' '' 'C' '4' '1' '1' $arg '' '' '' '' 'X')
-case [a-zA-Z][a-zA-Z]
- script=('' '' 'C' '4' '1' '3' $arg '' '' '' '' 'X')
-case *
- usage
-}
-
-{
- for(i in $script)
- echo $i
-} |
-con -nrl tcp!rainmaker.wunderground.com!telnet |
-sed -n '/Enter .-letter .* code:/,/CITY FORECAST MENU/p' |
-sed 's/Enter .-letter .* code: //' |
-sed 's/ Press Return to continue, M to return to menu, X to exit: //' |
-grep -v 'CITY FORECAST MENU' |
-tr -d '
' |
-sed 's/ *$//' |
-uniq |
-sed -n '/^VTEC/q; p'
+loc=''
+if (! ~ $#* 0)
+ loc=`{echo $* | sed 's/ +/+/g'}
+if not
+ if (! ~ $#weather 0)
+ loc=$weather
+hget https://wttr.in/$loc?TA0
+echo
diff -r cc26fdf57bb2 sys/man/1/weather
--- a/sys/man/1/weather Sat Mar 13 14:57:53 2021 +0100
+++ b/sys/man/1/weather Sat Apr 03 23:31:49 2021 +0300
@@ -4,37 +4,24 @@
.SH SYNOPSIS
.B weather
[
-.I air
-] [
-.I st
+.I location
]
.SH DESCRIPTION
.I Weather
-prints the local conditions and seven-day forecast most recently reported at the
-.SM US
-airport with the three-letter location identifier
-.IR air .
-Given a two-letter
-.SM US
-state abbreviation
-.I st
-instead,
-.I weather
-prints a table of
-.I air
-location identifiers known for
-.IR st .
-.PP
-The arguments are mutually exclusive and case-insensitive.
-If neither is given,
-.I air
-defaults to the value of the environment variable
-.BR $weather ,
-or if it is unset,
-to the location identifier
-.BR ewr ,
-designating the Newark, NJ, airport near Bell Labs, Murray Hill.
+by using wttr.in prints the local conditions most recently reported at the given
+.IR location ,
+the enviroment variable
+.B $weather
+or at detected location if neither are given.
+Any location (area codes, airport codes, any location names) usually works.
+Some special places might require putting a tilde
+.RB ( ~ )
+at the beginning. Weather of IP adresses or domain names can be found by typing an at sign
+.RB ( @ )
+the beginning. Location format can change, see https://wttr.in/:help for more info.
.SH SOURCE
.B /rc/bin/weather
.SH BUGS
Weather is hopelessly provincial.
+
+Redesigns of the wttr.in API might break this program.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [9front] weather: rewrite with a new api
2021-04-03 20:33 [9front] weather: rewrite with a new api kemal
@ 2021-04-05 11:26 ` Sigrid Solveig Haflínudóttir
2021-04-05 11:50 ` kemal
0 siblings, 1 reply; 4+ messages in thread
From: Sigrid Solveig HaflÃnudóttir @ 2021-04-05 11:26 UTC (permalink / raw)
To: 9front
How was this patch generated?
patching file rc/bin/weather
abort: bad hunk #1 @@ -1,46 +1,9 @@
(47 46 9 9)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [9front] weather: rewrite with a new api
2021-04-05 11:26 ` Sigrid Solveig Haflínudóttir
@ 2021-04-05 11:50 ` kemal
2021-04-05 12:13 ` hiro
0 siblings, 1 reply; 4+ messages in thread
From: kemal @ 2021-04-05 11:50 UTC (permalink / raw)
To: 9front
‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Monday, April 5, 2021 11:26 AM, Sigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com> wrote:
> How was this patch generated?
>
> patching file rc/bin/weather
> abort: bad hunk #1 @@ -1,46 +1,9 @@
> (47 46 9 9)
i did 'hg diff /rc/bin/weather /sys/man/1/weather'.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [9front] weather: rewrite with a new api
2021-04-05 11:50 ` kemal
@ 2021-04-05 12:13 ` hiro
0 siblings, 0 replies; 4+ messages in thread
From: hiro @ 2021-04-05 12:13 UTC (permalink / raw)
To: 9front
can you please stop whatever you're doing. i really didn't need it to
start snowing again in fucking april.
On 4/5/21, kemal <kemali13@protonmail.com> wrote:
> ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
> On Monday, April 5, 2021 11:26 AM, Sigrid Solveig Haflínudóttir
> <ftrvxmtrx@gmail.com> wrote:
>
>> How was this patch generated?
>>
>> patching file rc/bin/weather
>> abort: bad hunk #1 @@ -1,46 +1,9 @@
>> (47 46 9 9)
>
> i did 'hg diff /rc/bin/weather /sys/man/1/weather'.
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-04-05 12:21 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-03 20:33 [9front] weather: rewrite with a new api kemal
2021-04-05 11:26 ` Sigrid Solveig Haflínudóttir
2021-04-05 11:50 ` kemal
2021-04-05 12:13 ` hiro
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).