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"