From 684b84c78cf65c767ffcf077ed7f89106a1acf26 Mon Sep 17 00:00:00 2001 From: "B. Stack" Date: Wed, 10 Jul 2024 23:07:49 -0400 Subject: use reservations in all get_ calls --- libraries/aspen.py | 13 ++++++++----- libraries/base.py | 13 +++++++++++++ libraries/polaris.py | 8 ++++++++ 3 files changed, 29 insertions(+), 5 deletions(-) (limited to 'libraries') diff --git a/libraries/aspen.py b/libraries/aspen.py index 40e67c1..b024263 100644 --- a/libraries/aspen.py +++ b/libraries/aspen.py @@ -54,7 +54,11 @@ class Library(BaseLibrary): "Referer": f"{b}/MyAccount/CheckedOut?source=all" } s.get(f"{b}/Holds?source=ils",headers=headers) - output = s.get(f"{b}/AJAX?method=getHolds&source=all",headers=headers) + params = { + "method": "getHolds", + "source": "all" + } + output = s.get(f"{b}/MyAccount/AJAX",params=params,headers=headers) output = json.loads(output.content)["holds"].replace("\xa0"," ") soup = BeautifulSoup(output, "html.parser") try: @@ -65,8 +69,8 @@ class Library(BaseLibrary): if unavailableholds_all: items = unavailableholds_all.find_all("div",class_=["result"]) for i in items: - labels = [j.text for i in i.find_all("div","result-label")] - values = [j.text for i in i.find_all("div","result-value")] + labels = [j.text for j in i.find_all("div","result-label")] + values = [j.text for j in i.find_all("div","result-value")] values_dict = dict(map(lambda i,j:(i,j),labels,values)) title_obj = i.find("a",class_="result-title") img_href = i.find("img")["src"] @@ -84,13 +88,12 @@ class Library(BaseLibrary): "img_type": img_type, } unavailableReservations.append(obj) - # WORKHERE: availableHolds, might not be available. # Return a single list of objects return availableReservations + unavailableReservations def get_checkouts(self, verbose = False): - # WORKHERE: no example of possible/completed renewals at this time + # WORKHERE: no example of completed renewals at this time checked_out_objects = [] b = self.baseurl s = self.session diff --git a/libraries/base.py b/libraries/base.py index f6f75e4..3c68616 100644 --- a/libraries/base.py +++ b/libraries/base.py @@ -26,6 +26,19 @@ class BaseLibrary: self.baseurl = baseurl # will need cookies or session manager here. + def get_reservations(self, verbose = False): + sample = { + "position": "1", + "status": "pending", + "date_placed": "2024-07-11", + "format": "DVD", + "location": "Somewhere", + "title": "Example reserved dvd", + "img": "DUMMYIMAGE23412341234", + "img_type": "image/sample", + } + return [sample] + def get_checkouts(self): """ STUB """ sample = { diff --git a/libraries/polaris.py b/libraries/polaris.py index a47a289..c2edf9c 100644 --- a/libraries/polaris.py +++ b/libraries/polaris.py @@ -54,6 +54,14 @@ class Library(BaseLibrary): # log in now. Why would we not? self.login() + def get_reservations(self, verbose = False): + """ STUB """ + return [] + #availableReservations = [] + #unavailableReservations = [] + #b = self.baseurl + #s = self.session + def get_checkouts(self, verbose=False): checked_out_objects = [] b = self.baseurl -- cgit