From c6ec4dd41d1b9569f5b37ee263c4d747c47e188e Mon Sep 17 00:00:00 2001 From: "B. Stack" Date: Sat, 13 Jul 2024 16:23:06 -0400 Subject: all libraries: collect card expiry date --- libraries/aspen.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'libraries/aspen.py') diff --git a/libraries/aspen.py b/libraries/aspen.py index bb430c3..21e0115 100644 --- a/libraries/aspen.py +++ b/libraries/aspen.py @@ -41,6 +41,7 @@ class Library(BaseLibrary): self.alias = config_obj["alias"] else: self.alias = alias if alias else "Aspen-based library" + self.card_expires = None # log in now. Why would we not? self.login() @@ -104,7 +105,6 @@ class Library(BaseLibrary): img_href = i.find("img")["src"] img_b64, img_type = self.get_image(img_href) if verbose: - #print(f"DEBUG available: item {i}", file=sys.stderr) print(f"DEBUG available: title {title_obj.text}", file=sys.stderr) print(f"DEBUG available: values_dict {values_dict}", file=sys.stderr) obj = { @@ -200,3 +200,16 @@ class Library(BaseLibrary): "Priority": "u=1" } s.post(f"{b}/MyAccount/Home", headers = headers, data = data) + # step 3: learn card expiration date + # curl 'https://aspen.example.org/MyAccount/AJAX?method=getMenuDataIls&activeModule=MyAccount&activeAction=CheckedOut' -H 'Accept: application/json, text/javascript, */*; q=0.01' -H 'Referer: https://aspen.example.org/MyAccount/CheckedOut' -H 'Cookie: aspen_session=bksjhjndqhjcsoplci3b6htl3u' + params = { + "method": "getMenuDataIls", + "activeModule": "MyAccount", + "activeAction": "CheckedOut", + } + headers = { + "Referer": f"{b}/MyAccount/CheckedOut" + } + response = s.get(f"{b}/MyAccount/AJAX",params=params,headers=headers) + output = json.loads(response.content) + self.card_expires = dateutil.parser.parse(output["summary"]["expires"]) -- cgit