Skip to content

Commit

Permalink
Add publisher function
Browse files Browse the repository at this point in the history
  • Loading branch information
tmorrell committed Mar 5, 2024
1 parent 1e89efc commit 69fd83d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions ames/harvesters/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
16 changes: 16 additions & 0 deletions ames/harvesters/caltechauthors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 69fd83d

Please sign in to comment.