1
0
mirror of https://github.com/fenix-soft/fmeteo.git synced 2025-01-31 06:04:47 +01:00

Add files via upload

small fix
This commit is contained in:
fenix-soft 2018-09-11 12:09:23 +02:00 committed by GitHub
parent 8c01ae6cee
commit 7a407c2cff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 40 additions and 31 deletions

View File

@ -26,10 +26,11 @@ cat
#### Some examples: #### Some examples:
for example we want to recover the weather data of a city called "**Tempio Pausania**" that openwatermap has indexed as written with the space. for example we want to recover the weather data of a city called "**Tempio Pausania**" (IT) or "**New York**" that openwatermap has indexed written with the space.
fmeteo "Tempio%20Pausania" fmeteo "Tempio%20Pausania,IT"
fmeteo "New%20York,USA"
*** ***
@ -62,8 +63,9 @@ cat
#### Alcuni esempi: #### Alcuni esempi:
ad esempio vogliamo recuperare il tempo di una citta chiamata "**Tempio Pausania**" che openwatermap ha indicizzato così come scritta con lo spazio. ad esempio vogliamo recuperare il tempo di una citta chiamata "**Tempio Pausania**"(IT), oppure "**New York**" che openwatermap ha indicizzato scritta con lo spazio.
fmeteo "Tempio%20Pausania" fmeteo "Tempio%20Pausania,IT"
fmeteo "New%20York,USA"

59
fmeteo
View File

@ -2,9 +2,9 @@
# #
# #
#################################################################################### ####################################################################################
# script meteo che usa oopenweather map per i dati e li riporta a terminale # # script meteo che usa oopenweathermap per i dati e li riporta a terminale
# #
# v:1.0 alpha # v:1.1
# #
# dipendenze: curl,jq,cat,bc # dipendenze: curl,jq,cat,bc
# #
@ -12,16 +12,22 @@
#################################################################################### ####################################################################################
# set api-key
key_meteo="1487dd8a93bfd85d278d9ac8dcfee94c"
# set global variable # set global variable
surc_city=$1 surc_city=$1
api1="http://api.openweathermap.org/data/2.5/find?q=" api1="http://api.openweathermap.org/data/2.5/find?q="
api_par="&units=metric&appid=" api_par="&units=metric&appid="
api_lang="&lang=en" api_lang="&lang=en"
api2="http://api.openweathermap.org/data/2.5/forecast/daily?id=" api2="http://api.openweathermap.org/data/2.5/forecast/daily?id="
api3="http://api.openweathermap.org/data/2.5/forecast?id=" api3="http://api.openweathermap.org/data/2.5/forecast?id="
key_meteo="1487dd8a93bfd85d278d9ac8dcfee94c"
@ -33,7 +39,7 @@ echo " "
echo "get data... " echo "get data... "
curl $api1$surc_city$api_par$key_meteo$api_lang > meteonow.txt curl $api1$surc_city$api_par$key_meteo$api_lang > meteonow.txt
echo " " echo " "
city_id=`cat meteonow.txt | jq '.list[]|.id'` city_id=`cat meteonow.txt | jq '.list[0]|.id'`
@ -58,24 +64,24 @@ echo -e '\0033\0143'
# exstract data to jason file # exstract data to jason file
city_name=`cat meteonow.txt | jq -r '.list[]|.name'` city_name=`cat meteonow.txt | jq -r '.list[0]|.name'`
L=`cat meteonow.txt | jq -r '.list[]|.sys[]'` L=`cat meteonow.txt | jq -r '.list[0]|.sys[]'`
Lat=`cat meteonow.txt | jq -r '.list[]|.coord.lat'` Lat=`cat meteonow.txt | jq -r '.list[0]|.coord.lat'`
Lon=`cat meteonow.txt | jq -r '.list[]|.coord.lon'` Lon=`cat meteonow.txt | jq -r '.list[0]|.coord.lon'`
data_X=`cat meteonow.txt | jq -r '.list[]|.dt'` data_X=`cat meteonow.txt | jq -r '.list[0]|.dt'`
data_U=`date -d @$data_X` data_U=`date -d @$data_X`
Wcond_n=`cat meteonow.txt | jq -r '.list[]|.weather[].main'` Wcond_n=`cat meteonow.txt | jq -r '.list[0]|.weather[].main'`
Wcond_nd=`cat meteonow.txt | jq -r '.list[]|.weather[].description'` Wcond_nd=`cat meteonow.txt | jq -r '.list[0]|.weather[].description'`
T=`cat meteonow.txt | jq -r '.list[]|.main.temp'` T=`cat meteonow.txt | jq -r '.list[0]|.main.temp'`
Tmax=`cat meteonow.txt | jq -r '.list[]|.main.temp_max'` Tmax=`cat meteonow.txt | jq -r '.list[0]|.main.temp_max'`
Tmin=`cat meteonow.txt | jq -r '.list[]|.main.temp_min'` Tmin=`cat meteonow.txt | jq -r '.list[0]|.main.temp_min'`
Hm=`cat meteonow.txt | jq -r '.list[]|.main.humidity'` Hm=`cat meteonow.txt | jq -r '.list[0]|.main.humidity'`
PrS=`cat meteonow.txt | jq -r '.list[]|.main.pressure'` PrS=`cat meteonow.txt | jq -r '.list[0]|.main.pressure'`
ClD=`cat meteonow.txt | jq -r '.list[]|.clouds[]'` ClD=`cat meteonow.txt | jq -r '.list[0]|.clouds[]'`
R=`cat meteonow.txt | jq -r '.list[]|.rain'` R=`cat meteonow.txt | jq -r '.list[0]|.rain'`
S=`cat meteonow.txt | jq -r '.list[]|.snow'` S=`cat meteonow.txt | jq -r '.list[0]|.snow'`
Ws=`cat meteonow.txt | jq -r '.list[]|.wind.speed'` Ws=`cat meteonow.txt | jq -r '.list[0]|.wind.speed'`
Wsd=`cat meteonow.txt | jq -r '.list[]|.wind.deg'` Wsd=`cat meteonow.txt | jq -r '.list[0]|.wind.deg'`
# convert m/s to Km/s # convert m/s to Km/s
WsKM=$(echo "3.6"*$Ws | bc) WsKM=$(echo "3.6"*$Ws | bc)
@ -83,14 +89,15 @@ WsKM=$(echo "3.6"*$Ws | bc)
# print to video all data.. # print to video all data..
echo " " echo " "
echo " " $city_name","$L " " "Lat: "$Lat "Lon: "$Lon " " "id:" $city_id echo " " $city_name","$L " " "Lat: "$Lat " " "Lon: "$Lon " " "id:" $city_id
echo " " $data_U echo " " $data_U
echo " " echo " "
echo " " "Weather: "$Wcond_n"," $Wcond_nd echo " " "Weather: "$Wcond_n"," $Wcond_nd
echo " " echo " "
echo " " "Temp C°: "$T " " "Tmax C°: "$Tmax" " "Tmin C°: "$Tmin " " "Humidity %: "$Hm echo " " "Temp (): "$T " " "Tmax (): "$Tmax" " "Tmin (): "$Tmin " " "Humidity (%): "$Hm
echo " " echo " "
echo " " "Pressure hPa: "$PrS " " "Clouds %: "$ClD " " "Rain mm: "$R " " "Snow mm: "$S echo " " "Pressure (hPa): "$PrS " " "Clouds (%): "$ClD " " "Rain (mm): "$R " " "Snow (mm): "$S
echo " "
echo " " "Wind speed (km/h): "$WsKM " " "Wind deg (°): "$Wsd
echo " " echo " "
echo " " "Wind speed Km/h: "$WsKM
echo " " echo " "