summaryrefslogtreecommitdiffstats
path: root/fatcat_scholar/search.py
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@archive.org>2021-04-27 20:53:24 -0700
committerBryan Newbold <bnewbold@archive.org>2021-04-27 20:53:26 -0700
commit9907d45e4f54fe70e8e062f47f75197a3ae1b58e (patch)
treed5654721d401a9b96e7ce803b0039e0d140b1cb4 /fatcat_scholar/search.py
parente35e99bceff3277afaac8f2d5519aa4f07aabe49 (diff)
downloadfatcat-scholar-9907d45e4f54fe70e8e062f47f75197a3ae1b58e.tar.gz
fatcat-scholar-9907d45e4f54fe70e8e062f47f75197a3ae1b58e.zip
iterate on access redirects and landing page implementation
Small code refactors and minimal test coverage
Diffstat (limited to 'fatcat_scholar/search.py')
-rw-r--r--fatcat_scholar/search.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/fatcat_scholar/search.py b/fatcat_scholar/search.py
index c5fca35..a0cad2c 100644
--- a/fatcat_scholar/search.py
+++ b/fatcat_scholar/search.py
@@ -469,14 +469,17 @@ def lookup_fulltext_pdf(sha1: str) -> Optional[dict]:
sha1 = sha1.lower()
assert len(sha1) == 40 and sha1.isalnum()
hits = do_lookup_query(
- f'fulltext.file_sha1:{sha1} fulltext.file_mimetype:"application/pdf"'
+ f'fulltext.file_sha1:{sha1} fulltext.file_mimetype:"application/pdf" fulltext.access_url:*'
)
if not hits.results:
return None
fulltext = ScholarFulltext.parse_obj(hits.results[0]["fulltext"])
if not fulltext.access_type in ("ia_file", "wayback"):
return None
- assert fulltext.file_sha1 == sha1
- assert fulltext.file_mimetype == "application/pdf"
- assert fulltext.access_url
+ if fulltext.file_sha1 != sha1:
+ return None
+ if fulltext.file_mimetype != "application/pdf":
+ return None
+ if not fulltext.access_url:
+ return None
return fulltext