You've already forked QWeatherReporter
feat: fixed a bug
This commit is contained in:
@@ -10,17 +10,23 @@
|
|||||||
启用等级: DEV
|
启用等级: DEV
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from core.read_config import read_config
|
||||||
import requests
|
import requests
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
|
||||||
def hourly_weather(location: int, key: str, lang: str = 'zh', unit: str = 'm'):
|
def hourly_weather():
|
||||||
|
settings = read_config()
|
||||||
|
location = settings[1]['location']
|
||||||
|
key = settings[1]['key']
|
||||||
|
lang = settings[1]['lang']
|
||||||
|
unit = settings[1]['unit']
|
||||||
r = requests.get(
|
r = requests.get(
|
||||||
f'https://devapi.qweather.com/v7/weather/24h?location={location}&key={key}&lang={lang}&unit={unit}')
|
f'https://devapi.qweather.com/v7/weather/24h?location={location}&key={key}&lang={lang}&unit={unit}')
|
||||||
data = json.loads(r.text)
|
data = json.loads(r.text)
|
||||||
|
|
||||||
status_code = data['code']
|
status_code = data['code']
|
||||||
updateTime = str(data['updateTime'][:-6]).replace('T', '')
|
updateTime = str(data['updateTime'][:-6])[10:].replace('T', '')
|
||||||
main_data = data['hourly'] # 24
|
main_data = data['hourly'] # 24
|
||||||
return status_code, updateTime, main_data
|
return status_code, updateTime, main_data
|
||||||
|
|
||||||
|
|||||||
@@ -11,11 +11,17 @@
|
|||||||
启用等级: DEV
|
启用等级: DEV
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from core.read_config import read_config
|
||||||
import requests
|
import requests
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
|
||||||
def indices(location: int, key: str, lang: str = 'zh', unit: str = 'm'):
|
def indices():
|
||||||
|
settings = read_config()
|
||||||
|
location = settings[1]['location']
|
||||||
|
key = settings[1]['key']
|
||||||
|
lang = settings[1]['lang']
|
||||||
|
unit = settings[1]['unit']
|
||||||
r = requests.get(
|
r = requests.get(
|
||||||
f'https://devapi.qweather.com/v7/indices/1d?type=0&location={location}&key={key}&lang={lang}&unit={unit}')
|
f'https://devapi.qweather.com/v7/indices/1d?type=0&location={location}&key={key}&lang={lang}&unit={unit}')
|
||||||
data = json.loads(r.text)
|
data = json.loads(r.text)
|
||||||
|
|||||||
@@ -10,29 +10,20 @@
|
|||||||
启用等级: DEV
|
启用等级: DEV
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from core.read_config import read_config
|
||||||
import requests
|
import requests
|
||||||
import json
|
import json
|
||||||
import sys
|
|
||||||
from ruamel.yaml import YAML
|
|
||||||
|
|
||||||
|
|
||||||
def real_time_air_quality():
|
def real_time_air_quality():
|
||||||
yaml = YAML()
|
settings = read_config()
|
||||||
with open(sys.path[1] + '/config.yml', 'r', encoding='utf-8') as f:
|
location = settings[1]['location']
|
||||||
config = yaml.load(f.read())
|
key = settings[1]['key']
|
||||||
|
lang = settings[1]['lang']
|
||||||
|
unit = settings[1]['unit']
|
||||||
|
|
||||||
mode = config['request-settings']['mode']
|
r = requests.get(f'https://devapi.qweather.com/v7/air/now?'
|
||||||
key = config['request-settings']['key']
|
f'location={location}&key={key}&lang={lang}&unit={unit}&gzip=y')
|
||||||
location = config['request-settings']['location']
|
|
||||||
unit = config['request-settings']['unit']
|
|
||||||
lang = config['request-settings']['lang']
|
|
||||||
|
|
||||||
if mode != 'dev':
|
|
||||||
return False, print('Only Dev-mode')
|
|
||||||
session = requests.Session()
|
|
||||||
session.trust_env = False
|
|
||||||
r = session.get(f'https://devapi.qweather.com/v7/air/now?'
|
|
||||||
f'location={location}config.yml&key={key}&lang={lang}&unit={unit}&gzip=y')
|
|
||||||
_data = json.loads(r.text)
|
_data = json.loads(r.text)
|
||||||
|
|
||||||
return _data['code'], _data['now']
|
return _data['now']
|
||||||
|
|||||||
@@ -10,18 +10,14 @@
|
|||||||
启用等级: DEV
|
启用等级: DEV
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from core.read_config import read_config
|
||||||
import requests
|
import requests
|
||||||
import json
|
import json
|
||||||
from ruamel.yaml import YAML
|
|
||||||
|
|
||||||
|
|
||||||
def get_warning_list(_range='cn'):
|
def get_warning_list(_range='cn'):
|
||||||
yaml = YAML()
|
settings = read_config()
|
||||||
with open('./config.yml', 'r', encoding='utf-8') as f:
|
key = settings[1]['key']
|
||||||
config = yaml.load(f.read())
|
r = requests.get(f'https://devapi.qweather.com/v7/warning/list?range={_range}&key={key}')
|
||||||
key = config['request-settings']['key']
|
|
||||||
session = requests.Session()
|
|
||||||
session.trust_env = False
|
|
||||||
r = session.get(f'https://devapi.qweather.com/v7/warning/list?range={_range}&key={key}')
|
|
||||||
_data = json.loads(r.text)
|
_data = json.loads(r.text)
|
||||||
return _data['code'], _data['warningLocList'][0]['locationId']
|
return _data['code'], _data['warningLocList'][0]['locationId']
|
||||||
|
|||||||
Reference in New Issue
Block a user