aboutsummaryrefslogtreecommitdiff
path: root/libraries/aspen.py
diff options
context:
space:
mode:
authorB. Stack <bgstack15@gmail.com>2024-07-13 16:23:06 -0400
committerB. Stack <bgstack15@gmail.com>2024-07-13 16:23:06 -0400
commitc6ec4dd41d1b9569f5b37ee263c4d747c47e188e (patch)
treef8e76d74522c8aebe36674769951aca04c2aaf12 /libraries/aspen.py
parentupdate cron-run script to use separate images for html (diff)
downloadlibrary-info-c6ec4dd41d1b9569f5b37ee263c4d747c47e188e.tar.gz
library-info-c6ec4dd41d1b9569f5b37ee263c4d747c47e188e.tar.bz2
library-info-c6ec4dd41d1b9569f5b37ee263c4d747c47e188e.zip
all libraries: collect card expiry date
Diffstat (limited to 'libraries/aspen.py')
-rw-r--r--libraries/aspen.py15
1 files changed, 14 insertions, 1 deletions
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"])
bgstack15