Skip to content

Commit

Permalink
接口数据貌似出现问题,遂去除国内新增功能。以及一些小修复。
Browse files Browse the repository at this point in the history
  • Loading branch information
RiverKy committed Oct 24, 2020
1 parent 9a7de61 commit 3c61fa5
Showing 1 changed file with 24 additions and 11 deletions.
35 changes: 24 additions & 11 deletions wuhan.10s.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
# 填写想看到的省份的名字,如
# targetProvinceName = {"北京", "湖北", "广东"}
# 如果不填,默认展示确诊人数前五的省份
targetProvinceName = {'浙江', "北京", "广东", "上海", "山东"}
targetProvinceName = {}

# 除了 targetProvinceName 之外,还想额外看到的省份
# 如果不填则不会展示
additionProvinceName = {"江苏", "河南", "河北", "香港", "陕西", "湖南", "重庆", "福建", "天津", "云南", "四川", "广西", "安徽", "海南", "江西", "湖北", "山西", "辽宁", "台湾", "黑龙江", "内蒙古", "澳门", "贵州", "青海", "新疆", "西藏", "吉林", "宁夏"}
additionProvinceName = {}

# 除了中国之外,还想额外看到的国家
additionCountryName = {"美国", "塞尔维亚", "印度", "俄罗斯", "澳大利亚", "日本"}
Expand Down Expand Up @@ -66,16 +66,18 @@ def showCountryInfo(dataEntry, textColor):

print(displayString)


def showDailyInfo(add_dailyEntry, textColor):

dailyAddConfirm = add_dailyEntry.get('addcon')
dailyAddSus = add_dailyEntry.get('wjw_addsus')
dailyAddSus = add_dailyEntry.get('addsus')
dailyAddCure = add_dailyEntry.get('addcure')
dailyAddDeath = add_dailyEntry.get('adddeath')
displayAddString = "全国新增 确: %s 疑: %s 亡: %s 愈: %s" % (
dailyAddConfirm, dailyAddSus, dailyAddDeath, dailyAddCure)
print(displayAddString + ' | color=' + textColor)


def showProvinceInfo(province, textColor):
provinceName = province.get('name')
provinceNowConfirmedCount = province.get('econNum')
Expand All @@ -88,7 +90,8 @@ def showProvinceInfo(province, textColor):
print(displayString)

dailyAddList = province.get('adddaily')
dailyAddStr = "新增 确: %s 亡: %s 愈: %s" % (dailyAddList.get('conadd'), dailyAddList.get('deathadd'), dailyAddList.get('cureadd'))
dailyAddStr = "新增 确: %s 亡: %s 愈: %s" % (dailyAddList.get(
'conadd'), dailyAddList.get('deathadd'), dailyAddList.get('cureadd'))
print('--' + dailyAddStr + ' | color=' + textColor)

cityList = province.get('city')
Expand All @@ -97,6 +100,7 @@ def showProvinceInfo(province, textColor):
'conNum'), city.get('deathNum'), city.get('cureNum'))
print('--' + cityDataStr + ' | color=' + textColor)


def showGlobalInfo(dataEntry, otherEntry, textColor):
dataTime = dataEntry.get('cachetime')
print('COVID-19 全球疫情数据统计 @%s | color=gray' % dataTime)
Expand All @@ -105,31 +109,38 @@ def showGlobalInfo(dataEntry, otherEntry, textColor):
globalDeathCount = otherEntry.get('die')
globalNowConfirmedCount = otherEntry.get('ecertain')
globalAddConfirm = otherEntry.get('certain_inc')
globalAddNowCon = otherEntry.get('ecertain_inc')
globalAddCure = otherEntry.get('recure_inc')
globalAddDeath = otherEntry.get('die_inc')

# 感谢Bash版作者的思路
print('💊确诊:%s (%s) | color=#DC143C' % (globalConfirmCount, globalAddConfirm))
print('😷现存:%s | color=#FFA500' % (globalNowConfirmedCount))
print('💊确诊:%s (%s) | color=#DC143C' %
(globalConfirmCount, globalAddConfirm))
print('😷现存:%s (%s)| color=#FFA500' %
(globalNowConfirmedCount, globalAddNowCon))
print('🍂死亡:%s (%s) | color=#FF7F50' % (globalDeathCount, globalAddDeath))
print('🍀治愈:%s (%s) | color=#32CD32' % (globalCureCount, globalAddCure))



def showOtherInfo(otherCEntry, textColor):
countryName = otherCEntry.get('name')
otherConfirmCount = otherCEntry.get('conNum')
otherCureCount = otherCEntry.get('cureNum')
otherSusCount = otherCEntry.get('susNum')
otherDeathCount = otherCEntry.get('deathNum')
otherNowConfirmedCount = otherCEntry.get('econNum')
otherStr = "%s 确: %s 疑: %s 亡: %s 愈: %s 现: %s" % (countryName, otherConfirmCount, otherSusCount, otherDeathCount, otherCureCount, otherNowConfirmedCount)
otherStr = "%s 确: %s 疑: %s 亡: %s 愈: %s 现: %s" % (
countryName, otherConfirmCount, otherSusCount, otherDeathCount, otherCureCount, otherNowConfirmedCount)
print(otherStr + ' | color=' + textColor)
otherAddConfirm = otherCEntry.get('conadd')
otherAddCure = otherCEntry.get('cureadd')
otherAddDeath = otherCEntry.get('deathadd')
otherAddSus = otherCEntry.get('susadd')
otherAddStr = "新增 确: %s 疑: %s 亡: %s 愈: %s" % (otherAddConfirm, otherAddSus, otherAddDeath, otherAddCure)
otherAddStr = "新增 确: %s 疑: %s 亡: %s 愈: %s" % (
otherAddConfirm, otherAddSus, otherAddDeath, otherAddCure)
print('--' + otherAddStr + ' | color=' + textColor)


def main():
bitBarDarkMode = os.getenv('BitBarDarkMode', 0)
textColor = "black"
Expand All @@ -142,7 +153,7 @@ def main():

jsonData = json.loads(response.text)
dataEntry = jsonData.get('data')
add_dailyEntry = dataEntry.get('add_daily')
# add_dailyEntry = dataEntry.get('add_daily')
otherEntry = dataEntry.get('othertotal')
otherCEntry = dataEntry.get('otherlist')
provinceList = dataEntry.get('list')
Expand All @@ -151,7 +162,8 @@ def main():
print('---')
showGlobalInfo(dataEntry, otherEntry, textColor)
showCountryInfo(dataEntry, textColor)
showDailyInfo(add_dailyEntry, textColor)
# showDailyInfo(add_dailyEntry, textColor)
# 功能为显示国内每日新增数据,但是后来发现数据出现问题,得到的是累计数据,遂去除

if len(additionCountryName) > 0:
print('---')
Expand Down Expand Up @@ -188,5 +200,6 @@ def main():
print('---')
print('刷新... | refresh=true')


if __name__ == "__main__":
main()

0 comments on commit 3c61fa5

Please sign in to comment.