upload via files
10
.gitignore
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
*.yml
|
||||
!config.yml
|
||||
*.token
|
||||
*.zip
|
||||
**/__pycache__
|
||||
/.idea/
|
||||
venv/
|
||||
|
||||
|
||||
|
||||
26
module/API_24hour_weathers.py
Normal file
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env python
|
||||
# -- coding:utf-8 --
|
||||
# @Author: markushammered@gmail.com
|
||||
# @Development Tool: PyCharm
|
||||
# @Create Time: 2021/10/31
|
||||
# @File Name: API_24hour_weathers.py
|
||||
|
||||
"""
|
||||
获取未来24小时时级天气预报 (24)
|
||||
启用等级: DEV
|
||||
"""
|
||||
|
||||
import requests
|
||||
import json
|
||||
|
||||
|
||||
def hourly_weather(location: int, key: str, lang: str = 'zh', unit: str = 'm'):
|
||||
r = requests.get(
|
||||
f'https://devapi.qweather.com/v7/weather/24h?location={location}&key={key}&lang={lang}&unit={unit}')
|
||||
data = json.loads(r.text)
|
||||
|
||||
status_code = data['code']
|
||||
updateTime = str(data['updateTime'][:-6]).replace('T', '')
|
||||
main_data = data['hourly'] # 24
|
||||
return status_code, updateTime, main_data
|
||||
|
||||
26
module/API_Indices.py
Normal file
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env python
|
||||
# -- coding:utf-8 --
|
||||
# @Author: markushammered@gmail.com
|
||||
# @Development Tool: PyCharm
|
||||
# @Create Time: 2021/10/31
|
||||
# @File Name: API_indices.py
|
||||
|
||||
"""
|
||||
获取生活建议的API
|
||||
获取所有生活建议 (15+)
|
||||
启用等级: DEV
|
||||
"""
|
||||
|
||||
import requests
|
||||
import json
|
||||
|
||||
|
||||
def indices(location: int, key: str, lang: str = 'zh', unit: str = 'm'):
|
||||
r = requests.get(
|
||||
f'https://devapi.qweather.com/v7/indices/1d?type=0&location={location}&key={key}&lang={lang}&unit={unit}')
|
||||
data = json.loads(r.text)
|
||||
status_code = data['code']
|
||||
updateTime = str(data['updateTime'][:-6]).replace('T', '')
|
||||
main_data = data['daily'] # 1-15(+)
|
||||
return status_code, updateTime, main_data
|
||||
|
||||
27
module/API_get_warning_list.py
Normal file
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
# @Author: markushammered@gmail.com
|
||||
# @Development Tool: PyCharm
|
||||
# @Create Time: 2021/9/29
|
||||
# @File Name: API_get_warning_list.py:
|
||||
|
||||
"""
|
||||
开发版key使用此API可以快速返回正在预警的城市id
|
||||
Only Dev-mode
|
||||
"""
|
||||
|
||||
import requests
|
||||
import json
|
||||
from ruamel.yaml import YAML
|
||||
|
||||
|
||||
def get_warning_list(_range='cn'):
|
||||
yaml = YAML()
|
||||
with open('./config.yml', 'r', encoding='utf-8') as f:
|
||||
config = yaml.load(f.read())
|
||||
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)
|
||||
return _data['code'], _data['warningLocList'][0]['locationId']
|
||||
38
module/API_real_time_air_quality.py
Normal file
@@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
# @Author: markushammered@gmail.com
|
||||
# @Development Tool: PyCharm
|
||||
# @Create Time: 2021/9/29
|
||||
# @File Name: API_real_time_air_quality.py
|
||||
|
||||
"""
|
||||
开发版key获取实时空气质量
|
||||
only: Dev-mode
|
||||
"""
|
||||
|
||||
import requests
|
||||
import json
|
||||
import sys
|
||||
from ruamel.yaml import YAML
|
||||
|
||||
|
||||
def real_time_air_quality():
|
||||
yaml = YAML()
|
||||
with open(sys.path[1] + '/config.yml', 'r', encoding='utf-8') as f:
|
||||
config = yaml.load(f.read())
|
||||
|
||||
mode = config['request-settings']['mode']
|
||||
key = config['request-settings']['key']
|
||||
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)
|
||||
|
||||
return _data['code'], _data['now']
|
||||
6
module/__init__.py
Normal file
@@ -0,0 +1,6 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
# @Author: markushammered@gmail.com
|
||||
# @Development Tool: PyCharm
|
||||
# @Create Time: 2021/10/16
|
||||
# @File Name: __init__.py
|
||||
BIN
resource/China-City-List.xlsx
Normal file
BIN
resource/extra-icon/sunrise.png
Normal file
|
After Width: | Height: | Size: 993 B |
BIN
resource/extra-icon/sunset.png
Normal file
|
After Width: | Height: | Size: 1005 B |
39
resource/lang/en_us.json
Normal file
@@ -0,0 +1,39 @@
|
||||
{
|
||||
"request_result_weather": "Weather API request result",
|
||||
"request_result_indices": "Indices request result",
|
||||
"request_result_warning": "Warning API request result",
|
||||
"indices_tip": "No indices",
|
||||
"mail_error": "Mail sending error Error reason",
|
||||
"running": "Running Send mode",
|
||||
"send_time": "Send time",
|
||||
"mail_succeed": "Mail sending succeed.",
|
||||
"config_not_filled": "Config file has no filled item(s).",
|
||||
"statement_1": "Do not modify the configuration file at will.",
|
||||
"statement_2": "All requests for this project are made using the local network.",
|
||||
"statement_3": "If you used a VPN or PROXY, it will doesn't work.",
|
||||
"statement_4": "If you have seen this message, the program runs normally.",
|
||||
"debug_done": "Execution completed.",
|
||||
"new_warning": "Get new disaster warning",
|
||||
"warning_updated": "Disaster warning has been updated",
|
||||
"area": "Area",
|
||||
"weather": "Weather",
|
||||
"sender": "Sender Account",
|
||||
"date": "Date",
|
||||
"lowestTemp": "LowestTemp",
|
||||
"highestTemp": "HighestTemp",
|
||||
"wind_info": "WindSpeed/Level/Dir",
|
||||
"humidity": "Humidity",
|
||||
"uv_info": "UV",
|
||||
"vis": "Visibility",
|
||||
"pressure": "Pressure",
|
||||
"cloud": "Cloud",
|
||||
"subject_7": "7 Day's weather report",
|
||||
"subject_3": "3 Day's weather report",
|
||||
"subject_war": "Natural disaster warning",
|
||||
"release_time": "Release time",
|
||||
"early_warning": "Early warning",
|
||||
"warning_status": "Warning status",
|
||||
"warning_type": "Warning type",
|
||||
"warning_duration": "Duration",
|
||||
"wait_seconds": "Wait 61 seconds..."
|
||||
}
|
||||
39
resource/lang/zh_cn.json
Normal file
@@ -0,0 +1,39 @@
|
||||
{
|
||||
"request_result_weather": "天气信息请求结果",
|
||||
"request_result_indices": "生活建议请求结果",
|
||||
"request_result_warning": "自然灾害API请求结果",
|
||||
"indices_tip": "无具体描述",
|
||||
"mail_error": "邮件发送错误 错误原因",
|
||||
"running": "运行中 发送模式",
|
||||
"send_time": "发送时间",
|
||||
"mail_succeed": "邮件发送成功",
|
||||
"config_not_filled": "配置文件填写错误",
|
||||
"statement_1": "配置文件请不要随意修改",
|
||||
"statement_2": "本项目所有程序均使用本地网络进行请求",
|
||||
"statement_3": "如果使用了VPN或代理将不会生效",
|
||||
"statement_4": "如果你看到这段话就说明程序在正常运行",
|
||||
"debug_done": "执行完成",
|
||||
"new_warning": "获取到新的灾害预警",
|
||||
"warning_updated": "灾害预警信息已更新",
|
||||
"area": "地区",
|
||||
"weather": "天气",
|
||||
"sender": "发送者账号",
|
||||
"date": "日期",
|
||||
"lowestTemp": "最低气温",
|
||||
"highestTemp": "最高气温",
|
||||
"wind_info": "风速/级/向",
|
||||
"humidity": "空气湿度",
|
||||
"uv_info": "紫外线强度",
|
||||
"vis": "能见度",
|
||||
"pressure": "气压",
|
||||
"cloud": "云量",
|
||||
"subject_7": "7天天气预报",
|
||||
"subject_3": "3天天气预报",
|
||||
"subject_war": "自然灾害预报",
|
||||
"release_time": "发布时间",
|
||||
"early_warning": "预警",
|
||||
"warning_status": "灾害状态",
|
||||
"warning_type": "灾害类型",
|
||||
"warning_duration": "持续时间",
|
||||
"wait_seconds": "等待61秒..."
|
||||
}
|
||||
BIN
resource/style1/100.png
Normal file
|
After Width: | Height: | Size: 4.6 KiB |
BIN
resource/style1/101.png
Normal file
|
After Width: | Height: | Size: 4.9 KiB |
BIN
resource/style1/102.png
Normal file
|
After Width: | Height: | Size: 3.9 KiB |
BIN
resource/style1/103.png
Normal file
|
After Width: | Height: | Size: 6.0 KiB |
BIN
resource/style1/104.png
Normal file
|
After Width: | Height: | Size: 5.2 KiB |
BIN
resource/style1/150.png
Normal file
|
After Width: | Height: | Size: 3.9 KiB |
BIN
resource/style1/153.png
Normal file
|
After Width: | Height: | Size: 5.6 KiB |
BIN
resource/style1/154.png
Normal file
|
After Width: | Height: | Size: 5.0 KiB |
BIN
resource/style1/300.png
Normal file
|
After Width: | Height: | Size: 5.4 KiB |
BIN
resource/style1/301.png
Normal file
|
After Width: | Height: | Size: 6.7 KiB |
BIN
resource/style1/302.png
Normal file
|
After Width: | Height: | Size: 4.9 KiB |
BIN
resource/style1/303.png
Normal file
|
After Width: | Height: | Size: 5.5 KiB |
BIN
resource/style1/304.png
Normal file
|
After Width: | Height: | Size: 4.9 KiB |
BIN
resource/style1/305.png
Normal file
|
After Width: | Height: | Size: 4.2 KiB |
BIN
resource/style1/306.png
Normal file
|
After Width: | Height: | Size: 4.9 KiB |
BIN
resource/style1/307.png
Normal file
|
After Width: | Height: | Size: 5.4 KiB |
BIN
resource/style1/308.png
Normal file
|
After Width: | Height: | Size: 3.4 KiB |
BIN
resource/style1/309.png
Normal file
|
After Width: | Height: | Size: 4.4 KiB |
BIN
resource/style1/310.png
Normal file
|
After Width: | Height: | Size: 5.9 KiB |
BIN
resource/style1/311.png
Normal file
|
After Width: | Height: | Size: 5.4 KiB |
BIN
resource/style1/312.png
Normal file
|
After Width: | Height: | Size: 4.8 KiB |
BIN
resource/style1/313.png
Normal file
|
After Width: | Height: | Size: 5.3 KiB |
BIN
resource/style1/314.png
Normal file
|
After Width: | Height: | Size: 4.8 KiB |
BIN
resource/style1/315.png
Normal file
|
After Width: | Height: | Size: 5.1 KiB |
BIN
resource/style1/316.png
Normal file
|
After Width: | Height: | Size: 5.2 KiB |
BIN
resource/style1/317.png
Normal file
|
After Width: | Height: | Size: 5.3 KiB |
BIN
resource/style1/318.png
Normal file
|
After Width: | Height: | Size: 5.8 KiB |
BIN
resource/style1/350.png
Normal file
|
After Width: | Height: | Size: 4.6 KiB |
BIN
resource/style1/351.png
Normal file
|
After Width: | Height: | Size: 5.8 KiB |
BIN
resource/style1/399.png
Normal file
|
After Width: | Height: | Size: 3.2 KiB |
BIN
resource/style1/400.png
Normal file
|
After Width: | Height: | Size: 4.4 KiB |
BIN
resource/style1/401.png
Normal file
|
After Width: | Height: | Size: 5.3 KiB |
BIN
resource/style1/402.png
Normal file
|
After Width: | Height: | Size: 5.9 KiB |
BIN
resource/style1/403.png
Normal file
|
After Width: | Height: | Size: 6.5 KiB |
BIN
resource/style1/404.png
Normal file
|
After Width: | Height: | Size: 5.5 KiB |
BIN
resource/style1/405.png
Normal file
|
After Width: | Height: | Size: 3.3 KiB |
BIN
resource/style1/406.png
Normal file
|
After Width: | Height: | Size: 6.0 KiB |
BIN
resource/style1/407.png
Normal file
|
After Width: | Height: | Size: 5.7 KiB |
BIN
resource/style1/408.png
Normal file
|
After Width: | Height: | Size: 5.1 KiB |
BIN
resource/style1/409.png
Normal file
|
After Width: | Height: | Size: 5.5 KiB |
BIN
resource/style1/410.png
Normal file
|
After Width: | Height: | Size: 5.8 KiB |
BIN
resource/style1/456.png
Normal file
|
After Width: | Height: | Size: 5.3 KiB |
BIN
resource/style1/457.png
Normal file
|
After Width: | Height: | Size: 4.8 KiB |
BIN
resource/style1/499.png
Normal file
|
After Width: | Height: | Size: 3.7 KiB |
BIN
resource/style1/500.png
Normal file
|
After Width: | Height: | Size: 3.2 KiB |
BIN
resource/style1/501.png
Normal file
|
After Width: | Height: | Size: 1.0 KiB |
BIN
resource/style1/502.png
Normal file
|
After Width: | Height: | Size: 3.5 KiB |
BIN
resource/style1/503.png
Normal file
|
After Width: | Height: | Size: 5.1 KiB |
BIN
resource/style1/504.png
Normal file
|
After Width: | Height: | Size: 2.2 KiB |
BIN
resource/style1/507.png
Normal file
|
After Width: | Height: | Size: 2.5 KiB |
BIN
resource/style1/508.png
Normal file
|
After Width: | Height: | Size: 7.2 KiB |
BIN
resource/style1/509.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
BIN
resource/style1/510.png
Normal file
|
After Width: | Height: | Size: 2.5 KiB |
BIN
resource/style1/511.png
Normal file
|
After Width: | Height: | Size: 4.4 KiB |
BIN
resource/style1/512.png
Normal file
|
After Width: | Height: | Size: 4.9 KiB |
BIN
resource/style1/513.png
Normal file
|
After Width: | Height: | Size: 5.2 KiB |
BIN
resource/style1/514.png
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
BIN
resource/style1/515.png
Normal file
|
After Width: | Height: | Size: 1.8 KiB |
BIN
resource/style1/900.png
Normal file
|
After Width: | Height: | Size: 3.7 KiB |
BIN
resource/style1/901.png
Normal file
|
After Width: | Height: | Size: 3.5 KiB |
BIN
resource/style1/999.png
Normal file
|
After Width: | Height: | Size: 3.8 KiB |
BIN
resource/style2/100.png
Normal file
|
After Width: | Height: | Size: 4.6 KiB |
BIN
resource/style2/101.png
Normal file
|
After Width: | Height: | Size: 4.9 KiB |
BIN
resource/style2/102.png
Normal file
|
After Width: | Height: | Size: 3.9 KiB |
BIN
resource/style2/103.png
Normal file
|
After Width: | Height: | Size: 13 KiB |
BIN
resource/style2/104.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
resource/style2/150.png
Normal file
|
After Width: | Height: | Size: 3.9 KiB |
BIN
resource/style2/153.png
Normal file
|
After Width: | Height: | Size: 13 KiB |
BIN
resource/style2/154.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
resource/style2/300.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
resource/style2/301.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
resource/style2/302.png
Normal file
|
After Width: | Height: | Size: 10 KiB |
BIN
resource/style2/303.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
resource/style2/304.png
Normal file
|
After Width: | Height: | Size: 10 KiB |
BIN
resource/style2/305.png
Normal file
|
After Width: | Height: | Size: 8.2 KiB |
BIN
resource/style2/306.png
Normal file
|
After Width: | Height: | Size: 9.9 KiB |
BIN
resource/style2/307.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
resource/style2/308.png
Normal file
|
After Width: | Height: | Size: 3.4 KiB |
BIN
resource/style2/309.png
Normal file
|
After Width: | Height: | Size: 9.2 KiB |
BIN
resource/style2/310.png
Normal file
|
After Width: | Height: | Size: 13 KiB |
BIN
resource/style2/311.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
resource/style2/312.png
Normal file
|
After Width: | Height: | Size: 9.8 KiB |
BIN
resource/style2/313.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
resource/style2/314.png
Normal file
|
After Width: | Height: | Size: 9.8 KiB |
BIN
resource/style2/315.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
resource/style2/316.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
resource/style2/317.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
resource/style2/318.png
Normal file
|
After Width: | Height: | Size: 5.8 KiB |
BIN
resource/style2/350.png
Normal file
|
After Width: | Height: | Size: 10 KiB |