diff --git a/scripts/auto-add-from-zenodo-communities.py b/scripts/auto-add-from-zenodo-communities.py index 19f17554..bc105678 100644 --- a/scripts/auto-add-from-zenodo-communities.py +++ b/scripts/auto-add-from-zenodo-communities.py @@ -50,10 +50,13 @@ def main(): response = requests.get('https://zenodo.org/api/records', params={'communities': community, 'access_token': token}) - online_data = response.json() - hits = online_data["hits"]["hits"] - urls = [u["links"]["self_html"] for u in hits] - + try: + online_data = response.json() + hits = online_data["hits"]["hits"] + urls = [u["links"]["self_html"] for u in hits] + except requests.exceptions.JSONDecodeError: + print(f"Error decoding JSON for community: {community}") + continue # compare which new is not in old @@ -100,6 +103,5 @@ def main(): - if __name__ == "__main__": main() diff --git a/scripts/generate_link_lists.py b/scripts/generate_link_lists.py index 16db10d9..69586dd3 100644 --- a/scripts/generate_link_lists.py +++ b/scripts/generate_link_lists.py @@ -321,7 +321,11 @@ def read_zenodo(record): # Download the file response = requests.get(url) - data = response.json() + try: + data = response.json() + except json.JSONDecodeError: + data = {} + return data