aboutsummaryrefslogtreecommitdiff
path: root/libraries/polaris.py
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/polaris.py')
-rw-r--r--libraries/polaris.py48
1 files changed, 40 insertions, 8 deletions
diff --git a/libraries/polaris.py b/libraries/polaris.py
index c2edf9c..6fab43d 100644
--- a/libraries/polaris.py
+++ b/libraries/polaris.py
@@ -56,11 +56,45 @@ class Library(BaseLibrary):
def get_reservations(self, verbose = False):
""" STUB """
- return []
- #availableReservations = []
- #unavailableReservations = []
- #b = self.baseurl
- #s = self.session
+ # this one lumps them all together in a list. Use the status field.
+ reservations = []
+ b = self.baseurl
+ s = self.session
+ output = s.get(f"{b}/PatronAccount/requests.aspx",headers={"Referer":f"{b}/PatronAccount/itemsout.aspx"}).content
+ soup = BeautifulSoup(output, "html.parser")
+ all_reservations = soup.find_all("tr",class_=["patron-account__grid-row","patron-account__grid-alternating-row"])
+ for item in all_reservations:
+ images_hrefs = [i["src"] for i in item.find_all("img",attrs={"aria-label":"Cover Image"})]
+ titles = [i.text for i in item.find_all("a",class_="patron-account__grid-link")]
+ labels = [i.text for i in item.find_all("label",class_="label-xs")]
+ #print(f"Labels = {labels}",file=sys.stderr)
+ values = [i.next_sibling.next_sibling for i in item.find_all("label",class_="label-xs")]
+ values2 = []
+ for i in values:
+ try:
+ values2.append(i.text)
+ except:
+ # if status = "Transferred for hold" then the position value will be blank.
+ values2.append("")
+ values_dict = dict(map(lambda i,j:(i,j),labels,values2))
+ dates = [i.text.replace("(as of ","").replace(")","").replace("(","") for i in item.find_all("span",class_="patron-account__holds-date")]
+ formats = [i["title"] for i in item.find_all("img") if "aria-label" not in i.attrs]
+ img_b64, img_type = self.get_image(images_hrefs[0])
+ obj = {
+ "patron": self.alias,
+ "position": values_dict["Hold Request Position"],
+ "status": values_dict["Status"],
+ "date_placed": dates[0],
+ "format": formats[0],
+ "location": values_dict["Pickup Library"],
+ "title": titles[0],
+ "img_href": images_hrefs[0],
+ "img50": img_b64[:50],
+ "img": img_b64,
+ "img_type": img_type,
+ }
+ reservations.append(obj)
+ return reservations
def get_checkouts(self, verbose=False):
checked_out_objects = []
@@ -105,9 +139,7 @@ class Library(BaseLibrary):
x = -1
for i in titles:
x += 1
- img_response = s.get(images_hrefs[x])
- img_b64 = base64.b64encode(img_response.content).decode()
- img_type = img_response.headers["Content-Type"]
+ img_b64, img_type = self.get_image(images_hrefs[x])
details_response = s.get(info_links[x]).content.decode().replace(" ","")
soup2 = BeautifulSoup(details_response,"html.parser")
#details_labels = [i.text for i in soup2.find_all("td",class_="nsm-label") if i.text]
bgstack15