added Weather Underground/Weather.com API script to sources
This commit is contained in:
parent
26e671051b
commit
19487f4901
@ -8,7 +8,7 @@ pop @path;
|
|||||||
my $p = join("/", @path);
|
my $p = join("/", @path);
|
||||||
|
|
||||||
sub checksources {
|
sub checksources {
|
||||||
my $weather = (`$p/wttrin.sh` || `$p/weatherbug.sh` || `$p/weathergov.sh`) or print "Not Available\n\n#FF0000" and exit 33;
|
my $weather = (`$p/wttrin.sh` || `$p/weatherunder.sh` || `$p/weatherbug.sh` || `$p/weathergov.sh`) or print "Not Available\n\n#FF0000" and exit 33;
|
||||||
return $weather;
|
return $weather;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
20
weatherunder.sh
Executable file
20
weatherunder.sh
Executable file
@ -0,0 +1,20 @@
|
|||||||
|
#!/usr/bin/perl -w
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use JSON;
|
||||||
|
|
||||||
|
my $APIKEY = "6532d6454b8aa370768e63d6ba5a832e";
|
||||||
|
my $StationID = "KUTRIVER63";
|
||||||
|
my $Units = "m"; # e = imperial, m = metric
|
||||||
|
|
||||||
|
my $info = `curl -sm "https://api.weather.com/v2/pws/observations/current?apiKey=$APIKEY&stationId=$StationID&numericPrecision=decimal&format=json&units=$Units"` or die "Error";
|
||||||
|
|
||||||
|
my $json = decode_json $info or die "Error";
|
||||||
|
|
||||||
|
my $loc = %{$json}{"observations"}->[0]->{"stationID"};
|
||||||
|
my $temp = %{$json}{"observations"}->[0]->{"metric"}->{"temp"};
|
||||||
|
my $windS = %{$json}{"observations"}->[0]->{"metric"}->{"windSpeed"};
|
||||||
|
my $windD = %{$json}{"observations"}->[0]->{"winddir"};
|
||||||
|
|
||||||
|
print "?:".$temp.":".$windS.":".$windD.":".$loc;
|
Loading…
x
Reference in New Issue
Block a user