diff --git a/crons/acfa_updater.py b/crons/acfa_updater.py index f8ca4bf..ac4874f 100644 --- a/crons/acfa_updater.py +++ b/crons/acfa_updater.py @@ -38,6 +38,7 @@ def all_repos(self, acfa_api_token): acfa_api_token, as_client, repo, self.parent_cache ).daily_update() + class UpdateRepository(object): def __init__(self, acfa_api_token, as_client, repo, parent_cache): self.export_params = { @@ -70,6 +71,13 @@ def daily_update(self, timestamp=None): ead_filepath = Path(self.ead_cache, f"as_ead_{bibid}.xml") with open(ead_filepath, "w") as ead_file: ead_file.write(ead_response.content.decode("utf-8")) + pdf_filepath = Path(self.pdf_cache, f"as_ead_{bibid}.pdf") + pdf_response = self.as_client.aspace.client.get( + f"/repositories/{self.repo.id}/resource_descriptions/{resource.id}.pdf", + params=self.export_params, + ) + with open(pdf_filepath, "wb") as pdf_file: + pdf_file.write(pdf_response.content) bibids.append(bibid) except Exception as e: print(bibid, e) @@ -111,13 +119,3 @@ def update_index(self, bibids): } response = requests.post(url, json=json_data, headers=headers) return response - - def save_pdf(self, resource): - try: - pdf_response = self.as_client.aspace.client.get( - f"/repositories/{self.repo.id}/resource_descriptions/{resource.id}.pdf", - params=self.export_params, - ) - except Exception as e: - pass -