aboutsummaryrefslogtreecommitdiff
path: root/libraries
diff options
context:
space:
mode:
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