From 69fd83d39961510899a02c78531018bce5a7d835 Mon Sep 17 00:00:00 2001 From: Tom Morrell Date: Tue, 5 Mar 2024 14:09:56 -0800 Subject: [PATCH] Add publisher function --- ames/harvesters/__init__.py | 1 + ames/harvesters/caltechauthors.py | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/ames/harvesters/__init__.py b/ames/harvesters/__init__.py index 2306505..f429deb 100644 --- a/ames/harvesters/__init__.py +++ b/ames/harvesters/__init__.py @@ -16,3 +16,4 @@ from .caltechauthors import get_records_from_date from .caltechauthors import get_request_comments from .caltechauthors import get_request_id_title +from .caltechauthors import get_publisher diff --git a/ames/harvesters/caltechauthors.py b/ames/harvesters/caltechauthors.py index 0358d84..53025a2 100644 --- a/ames/harvesters/caltechauthors.py +++ b/ames/harvesters/caltechauthors.py @@ -62,6 +62,22 @@ def get_request_comments(token, request): return cleaned +def get_publisher(token, record, test=False, draft=True): + if test: + url = "https://authors.caltechlibrary.dev/api/records" + else: + url = "https://authors.library.caltech.edu/api/records" + url = url + "/" + record + headers = { + "Authorization": "Bearer %s" % token, + "Content-type": "application/json", + } + if draft: + url = url + "/draft" + response = requests.get(url, headers=headers) + return response.json()["metadata"]["publisher"] + + def get_author_records(token, author_identifier, year=None, test=False): if test: url = "https://authors.caltechlibrary.dev/api/records"