65 lines
1.2 KiB
Python
Executable File
65 lines
1.2 KiB
Python
Executable File
#!/bin/python
|
|
|
|
import json
|
|
import requests
|
|
from datetime import datetime
|
|
|
|
WEATHER_CODES = {
|
|
'113': '☀️',
|
|
'116': '⛅️',
|
|
'119': '☁️',
|
|
'122': '☁️',
|
|
'143': '🌫',
|
|
'176': '🌦',
|
|
'179': '🌧',
|
|
'182': '🌧',
|
|
'185': '🌧',
|
|
'200': '⛈',
|
|
'227': '🌨',
|
|
'230': '❄️',
|
|
'248': '🌫',
|
|
'260': '🌫',
|
|
'263': '🌦',
|
|
'266': '🌦',
|
|
'281': '🌧',
|
|
'284': '🌧',
|
|
'293': '🌦',
|
|
'296': '🌦',
|
|
'299': '🌧',
|
|
'302': '🌧',
|
|
'305': '🌧',
|
|
'308': '🌧',
|
|
'311': '🌧',
|
|
'314': '🌧',
|
|
'317': '🌧',
|
|
'320': '🌨',
|
|
'323': '🌨',
|
|
'326': '🌨',
|
|
'329': '❄️',
|
|
'332': '❄️',
|
|
'335': '❄️',
|
|
'338': '❄️',
|
|
'350': '🌧',
|
|
'353': '🌦',
|
|
'356': '🌧',
|
|
'359': '🌧',
|
|
'362': '🌧',
|
|
'365': '🌧',
|
|
'368': '🌨',
|
|
'371': '❄️',
|
|
'374': '🌧',
|
|
'377': '🌧',
|
|
'386': '⛈',
|
|
'389': '🌩',
|
|
'392': '⛈',
|
|
'395': '❄️'
|
|
}
|
|
|
|
weather: json = requests.get("https://wttr.in/tomsk?format=j1").json()
|
|
|
|
# data = json.load(weather)
|
|
|
|
weather['current_condition'][0]['weatherCode'] = WEATHER_CODES[weather['current_condition'][0]['weatherCode']]
|
|
|
|
print(json.dumps(weather))
|