aboutsummaryrefslogtreecommitdiff
path: root/libraries
diff options
context:
space:
mode:
authorB. Stack <bgstack15@gmail.com>2024-07-31 08:46:01 -0400
committerB. Stack <bgstack15@gmail.com>2024-07-31 08:46:01 -0400
commit113f68d455f56a6c5b29f8870131cd44d1192812 (patch)
tree818d93ec10ad1f69d19d2cd551fe6e4854123736 /libraries
parentfix aspen holds parsing (diff)
downloadlibrary-info-113f68d455f56a6c5b29f8870131cd44d1192812.tar.gz
library-info-113f68d455f56a6c5b29f8870131cd44d1192812.tar.bz2
library-info-113f68d455f56a6c5b29f8870131cd44d1192812.zip
adjust aspen reservations againHEADmaster
Diffstat (limited to 'libraries')
-rw-r--r--libraries/aspen.py21
1 files changed, 17 insertions, 4 deletions
diff --git a/libraries/aspen.py b/libraries/aspen.py
index f37fad7..4b84178 100644
--- a/libraries/aspen.py
+++ b/libraries/aspen.py
@@ -60,6 +60,8 @@ class Library(BaseLibrary):
}
output = s.get(f"{b}/MyAccount/AJAX",params=params,headers=headers)
output = json.loads(output.content)["holds"].replace("\xa0"," ")
+ #with open(os.path.join("/tmp",self.alias + ".html"),"w") as w:
+ # w.write(output)
soup = BeautifulSoup(output, "html.parser")
holds_all = soup.find_all("div",class_=["result"])
for i in holds_all:
@@ -73,7 +75,13 @@ class Library(BaseLibrary):
pos_values = [j.text for j in pos_obj.find_all("div","result-value")]
pos_values_dict = dict(map(lambda pos_obj,j:(pos_obj,j),pos_labels,pos_values))
except Exception as e:
- pos_values_dict = {}
+ try:
+ pos_obj = i.parent.next_sibling
+ pos_labels = [j.text for j in pos_obj.find_all("div","result-label")]
+ pos_values = [j.text for j in pos_obj.find_all("div","result-value")]
+ pos_values_dict = dict(map(lambda pos_obj,j:(pos_obj,j),pos_labels,pos_values))
+ except Exception as e2:
+ pos_values_dict = {}
for p in pos_values_dict:
values_dict[p] = pos_values_dict[p]
title_obj = i.find("a",class_="result-title")
@@ -85,7 +93,6 @@ class Library(BaseLibrary):
obj = {
"patron": self.alias,
"position": values_dict["Position"] if "Position" in values_dict else "",
- "status": values_dict["Status"],
"format": values_dict["Format"],
"location": values_dict["Pickup Location"],
"title": title_obj.text,
@@ -94,10 +101,16 @@ class Library(BaseLibrary):
"img": img_b64,
"img_type": img_type,
}
- if "Date Placed" in values_dict:
+ if "Pickup By" in values_dict:
+ obj["date_placed"] = "until " + values_dict["Pickup By"]
+ else:
obj["date_placed"] = "placed " + values_dict["Date Placed"]
+ if "Status" in values_dict:
+ obj["status"] = values_dict["Status"]
else:
- obj["date_placed"] = "until " + values_dict["Pickup By"]
+ obj["status"] = ""
+ if "Available" in values_dict:
+ obj["status"] = "Available " + values_dict["Available"]
reservations.append(obj)
return reservations
bgstack15