From 55d2fd24b2b89181b4fc15e7262ea2f612109536 Mon Sep 17 00:00:00 2001 From: oddluck <39967334+oddluck@users.noreply.github.com> Date: Tue, 3 Mar 2020 23:28:17 +0000 Subject: [PATCH] Corona: add state/province searching --- Corona/plugin.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Corona/plugin.py b/Corona/plugin.py index 340bc94..b77e5c5 100644 --- a/Corona/plugin.py +++ b/Corona/plugin.py @@ -73,11 +73,20 @@ class Corona(callbacks.Plugin): r = region.get('attributes') if search: - name = r.get('Country_Region') + region = r.get('Country_Region') + state = r.get('Province_State') + if state and ',' in state: + state = state.split(',', 1)[1].strip() if 'china' in search.lower(): search = 'mainland china' - if search.lower() == name.lower(): - location = name + if region and search.lower() == region.lower(): + location = region + confirmed += r.get('Confirmed') + deaths += r.get('Deaths') + recovered += r.get('Recovered') + local_ratio_dead = "{0:.00%}".format(deaths/confirmed) + elif state and search.lower() == state.lower(): + location = state confirmed += r.get('Confirmed') deaths += r.get('Deaths') recovered += r.get('Recovered')