@@ -27,7 +27,7 @@ def get(self, id):
2727"""
2828Base URL for fetching category.
2929"""
30- base_url = 'https://raw.githubusercontent.com/CSSEGISandData/2019-nCoV/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_%s_global.csv ' ;
30+ base_url = 'https://raw.githubusercontent.com/CSSEGISandData/2019-nCoV/master/csse_covid_19_data/csse_covid_19_time_series/' ;
3131
3232@cached (cache = TTLCache (maxsize = 1024 , ttl = 3600 ))
3333def get_category (category ):
@@ -41,8 +41,18 @@ def get_category(category):
4141 # Adhere to category naming standard.
4242 category = category .lower ();
4343
44+ # URL to request data from.
45+ url = base_url + 'time_series_covid19_%s_global.csv' % category
46+
47+ # Different URL is needed for recoveries.
48+ # Read about deprecation here: https://github.com/CSSEGISandData/COVID-19/tree/master/csse_covid_19_data/csse_covid_19_time_series.
49+ if category == 'recovered' :
50+ url = base_url + 'time_series_19-covid-Recovered.csv'
51+
52+ print (url )
53+
4454 # Request the data
45- request = requests .get (base_url % category )
55+ request = requests .get (url )
4656 text = request .text
4757
4858 # Parse the CSV.
@@ -106,6 +116,7 @@ def get_locations():
106116 # Get all of the data categories locations.
107117 confirmed = get_category ('confirmed' )['locations' ]
108118 deaths = get_category ('deaths' )['locations' ]
119+ recovered = get_category ('recovered' )['locations' ]
109120
110121 # Final locations to return.
111122 locations = []
@@ -116,7 +127,7 @@ def get_locations():
116127 timelines = {
117128 'confirmed' : confirmed [index ]['history' ],
118129 'deaths' : deaths [index ]['history' ],
119- 'recovered' : {} ,
130+ 'recovered' : recovered [ index ][ 'history' ] ,
120131 }
121132
122133 # Grab coordinates.
@@ -140,7 +151,7 @@ def get_locations():
140151 {
141152 'confirmed' : Timeline ({ datetime .strptime (date , '%m/%d/%y' ).isoformat () + 'Z' : amount for date , amount in timelines ['confirmed' ].items () }),
142153 'deaths' : Timeline ({ datetime .strptime (date , '%m/%d/%y' ).isoformat () + 'Z' : amount for date , amount in timelines ['deaths' ].items () }),
143- 'recovered' : Timeline ({})
154+ 'recovered' : Timeline ({ datetime . strptime ( date , '%m/%d/%y' ). isoformat () + 'Z' : amount for date , amount in timelines [ 'recovered' ]. items () })
144155 }
145156 ))
146157
0 commit comments