feat(pdf): CORE fallback + Unpaywall oa_locations fix + .env support#1
Open
Navier8 wants to merge 6 commits into
Open
feat(pdf): CORE fallback + Unpaywall oa_locations fix + .env support#1Navier8 wants to merge 6 commits into
Navier8 wants to merge 6 commits into
Conversation
PDF cascade improvements for papers where the S2 API openAccessPdf field
is null despite open-access copies existing (e.g. ACM papers with
author-hosted preprints).
Changes:
- _unpaywall_pdf_url: scan all oa_locations[], not just best_oa_location,
so author-hosted PDFs in secondary locations are not silently missed
- Add _core_pdf_url: queries the CORE aggregator (core.ac.uk) by DOI
then title; honours optional CORE_API_KEY env var for higher rate limits
- Add _scholar_pdf_url_for_title: searches Google Scholar as a last resort,
matching by Jaccard title similarity (>= 0.85) to avoid wrong-paper hits
- Wire both into _download_pdf_bytes cascade:
S2 OA -> ArXiv -> Unpaywall -> Publisher -> CORE -> Google Scholar
Tested against 'Position based fluids' (Corpus ID 611962), which has
openAccessPdf=null in the S2 API but a freely downloadable preprint on
CORE (578097143.pdf, 2.6 MB, confirmed 200 OK).
Makes it easier to configure API keys without setting system environment
variables. A .env file in the project root (or any parent directory) is
loaded at server startup before any os.environ lookups.
Changes:
- Add python-dotenv>=1.0.0 to dependencies
- Load .env in server.py with a try/except so the server still works if
python-dotenv is not installed (plain env vars remain supported)
- Add CORE_API_KEY to the documented env vars in the server docstring
- Add .env.example template covering all four supported keys:
VIBESCHOLAR_DATA_DIR, S2_API_KEY, VIBESCHOLAR_EMAIL, CORE_API_KEY
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The S2 API's openAccessPdf field returns null for some papers even when free copies exist. Example: Position based fluids (Corpus ID 611962) — Unpaywall's best_oa_location is also empty, and ACM returns 403.
Changes
New cascade order
S2 OA → ArXiv → Unpaywall → Publisher → CORE → Google Scholar