mirror of https://github.com/polybar/polybar.git
Make the Weather script more easily usable by those who use fahrenheit or a different measurement.
parent
774a30af46
commit
fa10db8735
|
@ -146,15 +146,17 @@ For Gmail, you must allow less secure apps (https://myaccount.google.com/securit
|
||||||
|
|
||||||
import urllib.request, json
|
import urllib.request, json
|
||||||
|
|
||||||
city = "Kiev"
|
city = "Insert Your City"
|
||||||
api_key = "your api key"
|
api_key = "Insert Your API Key"
|
||||||
|
units = "Insert your units (Default: Kelvin, Options: Metric, Imperial"
|
||||||
|
unit_key = "Insert your Unit Key(K, C, F)"
|
||||||
|
|
||||||
weather = eval(str(urllib.request.urlopen("http://api.openweathermap.org/data/2.5/weather?q={}&APPID={}".format(city, api_key)).read())[2:-1])
|
weather = eval(str(urllib.request.urlopen("http://api.openweathermap.org/data/2.5/weather?q={}&APPID={}&units={}".format(city, api_key, units)).read())[2:-1])
|
||||||
|
|
||||||
info = weather["weather"][0]["description"].capitalize()
|
info = weather["weather"][0]["description"].capitalize()
|
||||||
temp = int(float(weather["main"]["temp"]) - 272.15)
|
temp = int(float(weather["main"]["temp"]))
|
||||||
|
|
||||||
print("%s, %i °C" % (info, temp))
|
print("%s, %i °%s" % (info, temp, unit_key))
|
||||||
```
|
```
|
||||||
|
|
||||||
## Module
|
## Module
|
||||||
|
|
Loading…
Reference in New Issue