From 765ba0236b6c9785e44bbff79ba4575c8c93af77 Mon Sep 17 00:00:00 2001 From: "Laptop-Ward-o2o\\Ward" Date: Fri, 22 Dec 2023 14:19:04 +0100 Subject: [PATCH 1/2] Clean up some todo's --- src/mijnbib/parsers.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/mijnbib/parsers.py b/src/mijnbib/parsers.py index f7b081b..70a89df 100644 --- a/src/mijnbib/parsers.py +++ b/src/mijnbib/parsers.py @@ -123,7 +123,6 @@ def parse(self) -> list[Loan]: for child in children: if child.name == "h2": # we expect this to be the first child branch_name = child.get_text().strip() - # TODO: check if this resolves to the same https://github.com/myTselection/bibliotheek_be/blob/fec95c3481f78d98062c1117627da652ec8d032d/custom_components/bibliotheek_be/utils.py#L306 elif child.name == "div": # loan div # we convert child soup object to string, so called function # can be used also easily for unit tests @@ -292,7 +291,17 @@ def parse(self) -> list[Account]: "div", class_="my-library-user-library-account-list__account" ) for acc_div in acc_divs: - # TODO: get details from json object, see https://github.com/myTselection/bibliotheek_be/blob/fec95c3481f78d98062c1117627da652ec8d032d/custom_components/bibliotheek_be/utils.py#L145C53-L145C75 + # Some details also available in this json blob; perhaps useful for later + # (credits to see https://github.com/myTselection/bibliotheek_be/blob/fec95c3481f78d98062c1117627da652ec8d032d/custom_components/bibliotheek_be/utils.py#L145C53-L145C75) + # {'id', 'libraryName', 'userName', 'email', 'alertEmailSync', 'barcode'} + # try: + # details = acc_div.find(attrs={":default-active-account": True}).get( + # ":default-active-account" + # ) + # details = json.loads(details) + # except AttributeError: + # details = {} + # Get id from acc_id = acc_div.a["href"].strip().split("/")[3] From 778935635e13a91d0036a119facef89abb5a3060 Mon Sep 17 00:00:00 2001 From: "Laptop-Ward-o2o\\Ward" Date: Fri, 22 Dec 2023 14:45:20 +0100 Subject: [PATCH 2/2] Catch json error --- src/mijnbib/parsers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mijnbib/parsers.py b/src/mijnbib/parsers.py index 70a89df..b0ebb4b 100644 --- a/src/mijnbib/parsers.py +++ b/src/mijnbib/parsers.py @@ -299,7 +299,7 @@ def parse(self) -> list[Account]: # ":default-active-account" # ) # details = json.loads(details) - # except AttributeError: + # except (AttributeError, json.JSONDecodeError): # details = {} # Get id from