|
@@ -15,6 +15,10 @@ INVASIONS_API_URL = 'https://www.toontownrewritten.com/api/invasions?format=json
|
|
|
LOGIN_API_URL = 'https://www.toontownrewritten.com/api/login?format=json'
|
|
|
|
|
|
|
|
|
+def _utc_from_timestamp(timestamp):
|
|
|
+ dt = datetime.datetime.utcfromtimestamp(timestamp)
|
|
|
+ return dt.replace(tzinfo = datetime.timezone.utc)
|
|
|
+
|
|
|
def api_request(url, params=None, validate_ssl_cert=True):
|
|
|
resp = urllib.request.urlopen(
|
|
|
url=url,
|
|
@@ -103,14 +107,12 @@ def request_active_invasions(validate_ssl_certs=True):
|
|
|
despawned_number, total_number = inv_data['progress'].split('/')
|
|
|
invs[district] = InvasionProgress(
|
|
|
district=district,
|
|
|
- date=datetime.datetime.utcfromtimestamp(inv_data['asOf']),
|
|
|
+ date=_utc_from_timestamp(inv_data['asOf']),
|
|
|
cog_type=inv_data['type'],
|
|
|
despawned_number=int(despawned_number),
|
|
|
total_number=int(total_number),
|
|
|
)
|
|
|
return InvasionsResponse(
|
|
|
- update_date=datetime.datetime.utcfromtimestamp(
|
|
|
- resp_data['lastUpdated']
|
|
|
- ),
|
|
|
+ update_date=_utc_from_timestamp(resp_data['lastUpdated']),
|
|
|
invasions=invs,
|
|
|
)
|