From c2146fe7b5d299dab2692d2346d0037a944ac799 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Mon, 25 Jun 2018 10:40:20 -0700 Subject: slightly more robust crossref import --- python/fatcat/crossref_importer.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/python/fatcat/crossref_importer.py b/python/fatcat/crossref_importer.py index 06c162f0..18dd2498 100644 --- a/python/fatcat/crossref_importer.py +++ b/python/fatcat/crossref_importer.py @@ -22,6 +22,11 @@ class FatcatCrossrefImporter(FatcatImporter): if (not 'author' in obj) or (not 'title' in obj): return None + # Other ways to be out of scope (provisionally) + if ((not 'type' in obj) or (not 'container-title' in obj) or + len(obj['container-title']) < 1): + return None + # contribs contribs = [] for i, am in enumerate(obj['author']): @@ -62,6 +67,10 @@ class FatcatCrossrefImporter(FatcatImporter): for i, rm in enumerate(obj.get('reference', [])): try: year = int(rm.get('year')) + if year > 2025 or year < 1000: + # NOTE: will need to update/config in the future! + # NOTE: are there crossref works with year < 1000? + return None except: year = None refs.append(fatcat_client.ReleaseRef( -- cgit v1.2.3