1
0

PBC: Parse datetime correctly
Some checks failed
Build container / Package-Python (push) Failing after 26s
Build container / Package-Container (push) Successful in 1m22s

This commit is contained in:
Jon Michael Aanes 2024-04-23 22:11:43 +02:00
parent 4b640b7134
commit afd2f4a0b3
Signed by: Jmaa
SSH Key Fingerprint: SHA256:Ab0GfHGCblESJx7JRE4fj4bFy/KRpeLhi41y4pF3sNA

View File

@ -5,6 +5,7 @@ import re
import json import json
import secrets import secrets
from decimal import Decimal from decimal import Decimal
import email.utils
import bs4 import bs4
@ -34,7 +35,7 @@ class MpcBalance(Scraper):
deduplicate_mode = DeduplicateMode.ONLY_LATEST deduplicate_mode = DeduplicateMode.ONLY_LATEST
deduplicate_ignore_columns = ['account.update_time'] deduplicate_ignore_columns = ['account.update_time']
def get_json(self, url: str, data: dict) -> tuple[dict,str]: def get_json(self, url: str, data: dict) -> tuple[dict, datetime.datetime]:
headers = { headers = {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
'Accept': 'application/json', 'Accept': 'application/json',
@ -42,7 +43,8 @@ class MpcBalance(Scraper):
response = self.session.post(url, headers = headers, data=json.dumps(data)) response = self.session.post(url, headers = headers, data=json.dumps(data))
response.raise_for_status() response.raise_for_status()
date = response.headers.get('last-modified') or response.headers.get('date') date_text = response.headers.get('last-modified') or response.headers.get('date')
date = email.utils.parsedate_to_datetime(date_text)
json_data = response.json() json_data = response.json()
if json_data is None: if json_data is None:
msg = 'No result data for ' + url msg = 'No result data for ' + url
@ -64,11 +66,6 @@ class MpcBalance(Scraper):
address = secrets.PBC_ACCOUNT_ADDRESS address = secrets.PBC_ACCOUNT_ADDRESS
coins = self.determine_coins() coins = self.determine_coins()
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
}
url = URL_ACCOUNT_PLUGIN.format( url = URL_ACCOUNT_PLUGIN.format(
hostname = HOSTNAME, hostname = HOSTNAME,
shard = shard_id_for_address(address), shard = shard_id_for_address(address),