aboutsummaryrefslogtreecommitdiff
path: root/libraries/polaris.py
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/polaris.py')
-rw-r--r--libraries/polaris.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/libraries/polaris.py b/libraries/polaris.py
index 6fab43d..e945fcc 100644
--- a/libraries/polaris.py
+++ b/libraries/polaris.py
@@ -51,6 +51,7 @@ class Library(BaseLibrary):
self.baseurl_http = self.baseurl.replace("https://","http://")
self.src = f"{self.baseurl_http}/patronaccount/default.aspx?ctx={self.language_code}&ctx={self.language_code}"
self.src2 = urllib.parse.unquote_plus(self.src)
+ self.card_expires = None
# log in now. Why would we not?
self.login()
@@ -207,3 +208,29 @@ class Library(BaseLibrary):
for msg in ["invalid Library Card", "Please enter your Library", "Please try again"]:
if msg in response:
raise Exception(f"Failed to log in to {self.alias}")
+ # step 3: learn card expiration date
+ # curl 'https://catalog.example.org/polaris/PatronAccount/default.aspx' -H 'Referer: https://catalog.example.org/polaris/PatronAccount/requests.aspx' -H 'Cookie: ASP.NET_SessionId=umyzdtvpkv5mo45axo3fny20; OrgID=1'
+ headers = {
+ "Referer": f"{b}/PatronAccount/requests.aspx"
+ }
+ output = s.get(f"{b}/PatronAccount/default.aspx",headers=headers).content
+ soup = BeautifulSoup(output, "html.parser")
+ alldivs = soup.find_all("div",class_="row")
+ labels = []
+ values = []
+ for i in alldivs:
+ j = i.find_all("span")
+ try:
+ # replace colon-nbsp from labels with empty
+ labels.append(j[0].text.replace(":\xa0",""))
+ except:
+ labels.append("empty")
+ try:
+ values.append(j[1].text)
+ except:
+ values.append("empty")
+ values_dict = dict(map(lambda i,j:(i,j),labels,values))
+ if "Expiration date" not in values_dict:
+ print(f"Warning! Cannot determine expiration date for {self.alias}. Continuing.",file=sys.stderr)
+ else:
+ self.card_expires = dateutil.parser.parse(values_dict["Expiration date"])
bgstack15