Skip to content

Commit

Permalink
Update Zenodo ingestor in line with API changes
Browse files Browse the repository at this point in the history
  • Loading branch information
fbacall committed Mar 1, 2024
1 parent 3cd1b1b commit be703ea
Show file tree
Hide file tree
Showing 7 changed files with 12,745 additions and 3,668 deletions.
11 changes: 6 additions & 5 deletions lib/ingestors/zenodo_ingestor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ def read(url)
begin
# process each page
until next_page.nil?
response = RestClient::Request.new(method: :get, url: CGI.unescape_html(next_page), verify_ssl: false).execute
if response.code == 200
content = open_url(CGI.unescape_html(next_page))

if content
# format response
results = JSON.parse(response.to_str)
results = JSON.parse(content.read)

# extract materials from results
unless results['hits'].nil? and results['hits']['hits'].nil?
Expand Down Expand Up @@ -65,7 +66,7 @@ def process_material(input)
material.title = metadata['title'] unless metadata['title'].nil?
material.description = process_description metadata['description']
material.keywords = metadata['keywords'] unless metadata['keywords'].nil?
material.licence = metadata['license']['id'] unless metadata['license'].nil? or metadata['license']['id'].nil?
material.licence = metadata['license']['id'].upcase unless metadata.dig('license', 'id').nil?
unless metadata['creators'].nil?
metadata['creators'].each do |c|
entry = c['orcid'].nil? ? c['name'] : "#{c['name']} (orcid: #{c['orcid']})"
Expand All @@ -80,7 +81,7 @@ def process_material(input)
end

end
material.url = links['html'] if !links.nil? && !links['html'].nil?
material.url = links['self_html'] if !links.nil? && !links['self_html'].nil?

# add material to array
add_material material
Expand Down
5,278 changes: 3,984 additions & 1,294 deletions test/fixtures/files/ingestion/zenodo_abt.json

Large diffs are not rendered by default.

Loading

0 comments on commit be703ea

Please sign in to comment.