From 2a6cd4b9f398dda753093f26cd252598de5025ef Mon Sep 17 00:00:00 2001 From: Jon Michael Aanes Date: Tue, 16 Apr 2024 23:38:35 +0200 Subject: [PATCH] partisia blockchain v2 --- personal_data/fetchers/partisia_blockchain.py | 20 +++++++++++++------ personal_data/fetchers/playstation.py | 5 ----- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/personal_data/fetchers/partisia_blockchain.py b/personal_data/fetchers/partisia_blockchain.py index 412ded0..ce1513a 100644 --- a/personal_data/fetchers/partisia_blockchain.py +++ b/personal_data/fetchers/partisia_blockchain.py @@ -2,6 +2,7 @@ import dataclasses import datetime import logging import re +import json import secrets import bs4 @@ -20,6 +21,7 @@ logger = logging.getLogger(__name__) HOSTNAME = 'reader.partisiablockchain.com' URL_ACCOUNT_PLUGIN = 'https://{hostname}/{shard}blockchain/accountPlugin/local' +URL_ACCOUNT_PLUGIN_GLOBAL = 'https://{hostname}/{shard}blockchain/accountPlugin/global' @dataclasses.dataclass(frozen=True) class MpcBalance(Scraper): @@ -39,14 +41,20 @@ class MpcBalance(Scraper): shard = 'shards/Shard0/', ) - data = f"{{\"path\":[{{\"type\":\"field\",\"name\":\"accounts\"}},{{\"type\":\"avl\",\"keyType\":\"BLOCKCHAIN_ADDRESS\",\"key\":\"{address}\"}}]}}" - print(data) - response = self.session.post(url, headers = headers, data=data) + data = {'path':[{'type':'field','name':'accounts'},{'type':'avl','keyType':'BLOCKCHAIN_ADDRESS','key':address}]} + response = self.session.post(url, headers = headers, data=json.dumps(data)) response.raise_for_status() + print(response.headers) - json = response.json() - print(json) + json_data = response.json() + print(json_data ) - assert False + data_point = { + 'account.address': address, + 'account.update_time': response.headers.get('last-modified') or response.headers.get('date'), + } + data_point['balance.MPC'] = json_data['mpcTokens'] + print(data_point) + yield data_point diff --git a/personal_data/fetchers/playstation.py b/personal_data/fetchers/playstation.py index 242fda3..da73d84 100644 --- a/personal_data/fetchers/playstation.py +++ b/personal_data/fetchers/playstation.py @@ -13,11 +13,6 @@ def scrape_played_last(session): response = session.get(URL_RECENTLY_PLAYED_HTML, cookies=session.cookies) response.raise_for_status() - print('From herp') - for cookie in session.cookies: - print(' ', cookie.domain, cookie) - exit(1) - # Now trigger API call. logger.warning('Trying to fetch data from API') headers = {