aboutsummaryrefslogtreecommitdiffstats
path: root/fatcat_scholar/search.py
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@archive.org>2021-06-11 15:03:32 -0700
committerBryan Newbold <bnewbold@archive.org>2021-06-11 15:03:32 -0700
commit3bae05c4a4cd7d6d9b892b952b7ca35454319479 (patch)
tree83831f45e209ab208c87c443312323279dff3484 /fatcat_scholar/search.py
parent20d6a40ae5450dbec11e8774cc61f1f1abad1ead (diff)
downloadfatcat-scholar-3bae05c4a4cd7d6d9b892b952b7ca35454319479.tar.gz
fatcat-scholar-3bae05c4a4cd7d6d9b892b952b7ca35454319479.zip
update access redirect URL endpoints
Diffstat (limited to 'fatcat_scholar/search.py')
-rw-r--r--fatcat_scholar/search.py25
1 files changed, 1 insertions, 24 deletions
diff --git a/fatcat_scholar/search.py b/fatcat_scholar/search.py
index f5056c7..121cb69 100644
--- a/fatcat_scholar/search.py
+++ b/fatcat_scholar/search.py
@@ -21,7 +21,7 @@ from pydantic import BaseModel
from fatcat_scholar.config import settings
from fatcat_scholar.identifiers import *
-from fatcat_scholar.schema import ScholarDoc, ScholarFulltext
+from fatcat_scholar.schema import ScholarDoc
from fatcat_scholar.query_parse import sniff_citation_query, pre_parse_query
from fatcat_scholar.query_citation import try_fuzzy_match
@@ -464,26 +464,3 @@ def get_es_scholar_doc(key: str) -> Optional[dict]:
except Exception:
pass
return doc
-
-
-def lookup_fulltext_pdf(sha1: str) -> Optional[ScholarFulltext]:
- """
- Fetch a document by fulltext file sha1, returning only the 'fulltext' sub-document.
- """
- sha1 = sha1.lower()
- assert len(sha1) == 40 and sha1.isalnum()
- hits = do_lookup_query(
- 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
- if fulltext.file_sha1 != sha1:
- return None
- if fulltext.file_mimetype != "application/pdf":
- return None
- if not fulltext.access_url:
- return None
- return fulltext