papersearch 0.6.10 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +661 -21
- package/NOTICE +51 -0
- package/README.en.md +13 -13
- package/README.md +13 -13
- package/assets/federation-map.en.png +0 -0
- package/assets/federation-map.png +0 -0
- package/dist/capabilities/{pdf-discovery → download/batch}/batch.d.ts +27 -17
- package/dist/capabilities/download/batch/batch.d.ts.map +1 -0
- package/dist/capabilities/{pdf-discovery → download/batch}/batch.js +440 -278
- package/dist/capabilities/download/batch/batch.js.map +1 -0
- package/dist/capabilities/download/batch/batchFolder.d.ts +21 -0
- package/dist/capabilities/download/batch/batchFolder.d.ts.map +1 -0
- package/dist/capabilities/download/batch/batchFolder.js +206 -0
- package/dist/capabilities/download/batch/batchFolder.js.map +1 -0
- package/dist/capabilities/{pdf-discovery → download/batch}/batchPapers.d.ts +1 -1
- package/dist/capabilities/download/batch/batchPapers.d.ts.map +1 -0
- package/dist/capabilities/download/batch/batchPapers.js.map +1 -0
- package/dist/capabilities/{pdf-discovery → download/batch}/batchSummary.d.ts +7 -9
- package/dist/capabilities/download/batch/batchSummary.d.ts.map +1 -0
- package/dist/capabilities/download/batch/batchSummary.js +269 -0
- package/dist/capabilities/download/batch/batchSummary.js.map +1 -0
- package/dist/capabilities/download/batch/networkLoss.d.ts +31 -0
- package/dist/capabilities/download/batch/networkLoss.d.ts.map +1 -0
- package/dist/capabilities/download/batch/networkLoss.js +67 -0
- package/dist/capabilities/download/batch/networkLoss.js.map +1 -0
- package/dist/capabilities/download/batch/resume.d.ts +76 -0
- package/dist/capabilities/download/batch/resume.d.ts.map +1 -0
- package/dist/capabilities/download/batch/resume.js +231 -0
- package/dist/capabilities/download/batch/resume.js.map +1 -0
- package/dist/capabilities/download/content/markdown/pageVisit.d.ts +14 -0
- package/dist/capabilities/download/content/markdown/pageVisit.d.ts.map +1 -0
- package/dist/capabilities/download/content/markdown/pageVisit.js +52 -0
- package/dist/capabilities/download/content/markdown/pageVisit.js.map +1 -0
- package/dist/capabilities/download/content/markdown/pro.d.ts +87 -0
- package/dist/capabilities/download/content/markdown/pro.d.ts.map +1 -0
- package/dist/capabilities/download/content/markdown/pro.js +109 -0
- package/dist/capabilities/download/content/markdown/pro.js.map +1 -0
- package/dist/capabilities/download/content/markdown/shortfall.d.ts +34 -0
- package/dist/capabilities/download/content/markdown/shortfall.d.ts.map +1 -0
- package/dist/capabilities/download/content/markdown/shortfall.js +99 -0
- package/dist/capabilities/download/content/markdown/shortfall.js.map +1 -0
- package/dist/capabilities/download/content/markdown/stats.d.ts +9 -0
- package/dist/capabilities/download/content/markdown/stats.d.ts.map +1 -0
- package/dist/capabilities/download/content/markdown/stats.js +39 -0
- package/dist/capabilities/download/content/markdown/stats.js.map +1 -0
- package/dist/capabilities/download/content/markdown/step.d.ts +50 -0
- package/dist/capabilities/download/content/markdown/step.d.ts.map +1 -0
- package/dist/capabilities/download/content/markdown/step.js +343 -0
- package/dist/capabilities/download/content/markdown/step.js.map +1 -0
- package/dist/capabilities/download/content/markdown/types.d.ts +120 -0
- package/dist/capabilities/download/content/markdown/types.d.ts.map +1 -0
- package/dist/capabilities/download/content/markdown/types.js +8 -0
- package/dist/capabilities/download/content/markdown/types.js.map +1 -0
- package/dist/capabilities/{pdf-discovery → download/content/pdf}/DownloadTier.d.ts +13 -4
- package/dist/capabilities/download/content/pdf/DownloadTier.d.ts.map +1 -0
- package/dist/capabilities/download/content/pdf/DownloadTier.js.map +1 -0
- package/dist/capabilities/{pdf-discovery → download/content/pdf}/OpenAccessFallbackService.d.ts +5 -5
- package/dist/capabilities/download/content/pdf/OpenAccessFallbackService.d.ts.map +1 -0
- package/dist/capabilities/{pdf-discovery → download/content/pdf}/OpenAccessFallbackService.js +26 -14
- package/dist/capabilities/download/content/pdf/OpenAccessFallbackService.js.map +1 -0
- package/dist/capabilities/download/content/pdf/arxiv.d.ts.map +1 -0
- package/dist/capabilities/{pdf-discovery → download/content/pdf}/arxiv.js +2 -2
- package/dist/capabilities/download/content/pdf/arxiv.js.map +1 -0
- package/dist/capabilities/{pdf-discovery → download/content/pdf}/identity.d.ts +1 -1
- package/dist/capabilities/download/content/pdf/identity.d.ts.map +1 -0
- package/dist/capabilities/download/content/pdf/identity.js.map +1 -0
- package/dist/capabilities/download/content/pdf/open/oaHosts.d.ts.map +1 -0
- package/dist/capabilities/download/content/pdf/open/oaHosts.js.map +1 -0
- package/dist/capabilities/download/content/pdf/open/pmcCloud.d.ts.map +1 -0
- package/dist/capabilities/{pdf-discovery → download/content/pdf/open}/pmcCloud.js +2 -2
- package/dist/capabilities/download/content/pdf/open/pmcCloud.js.map +1 -0
- package/dist/capabilities/download/content/pdf/open/publisherApi/elsevier.d.ts.map +1 -0
- package/dist/capabilities/{pdf-discovery → download/content/pdf/open}/publisherApi/elsevier.js +3 -3
- package/dist/capabilities/download/content/pdf/open/publisherApi/elsevier.js.map +1 -0
- package/dist/capabilities/download/content/pdf/open/publisherApi/index.d.ts.map +1 -0
- package/dist/capabilities/download/content/pdf/open/publisherApi/index.js.map +1 -0
- package/dist/capabilities/download/content/pdf/open/publisherApi/springer.d.ts.map +1 -0
- package/dist/capabilities/{pdf-discovery → download/content/pdf/open}/publisherApi/springer.js +3 -3
- package/dist/capabilities/download/content/pdf/open/publisherApi/springer.js.map +1 -0
- package/dist/capabilities/download/content/pdf/open/tiers/directPdfUrl.d.ts +5 -0
- package/dist/capabilities/download/content/pdf/open/tiers/directPdfUrl.d.ts.map +1 -0
- package/dist/capabilities/{pdf-discovery → download/content/pdf/open}/tiers/directPdfUrl.js +3 -3
- package/dist/capabilities/download/content/pdf/open/tiers/directPdfUrl.js.map +1 -0
- package/dist/capabilities/download/content/pdf/open/tiers/preprint.d.ts +5 -0
- package/dist/capabilities/download/content/pdf/open/tiers/preprint.d.ts.map +1 -0
- package/dist/capabilities/{pdf-discovery → download/content/pdf/open}/tiers/preprint.js +5 -5
- package/dist/capabilities/download/content/pdf/open/tiers/preprint.js.map +1 -0
- package/dist/capabilities/download/content/pdf/open/tiers/primary.d.ts +3 -0
- package/dist/capabilities/download/content/pdf/open/tiers/primary.d.ts.map +1 -0
- package/dist/capabilities/download/content/pdf/open/tiers/primary.js.map +1 -0
- package/dist/capabilities/{pdf-discovery → download/content/pdf/open}/tiers/publisherApi.d.ts +1 -1
- package/dist/capabilities/download/content/pdf/open/tiers/publisherApi.d.ts.map +1 -0
- package/dist/capabilities/{pdf-discovery → download/content/pdf/open}/tiers/publisherApi.js +5 -5
- package/dist/capabilities/download/content/pdf/open/tiers/publisherApi.js.map +1 -0
- package/dist/capabilities/{pdf-discovery → download/content/pdf/open}/tiers/repositories.d.ts +1 -1
- package/dist/capabilities/download/content/pdf/open/tiers/repositories.d.ts.map +1 -0
- package/dist/capabilities/{pdf-discovery → download/content/pdf/open}/tiers/repositories.js +2 -2
- package/dist/capabilities/download/content/pdf/open/tiers/repositories.js.map +1 -0
- package/dist/capabilities/download/content/pdf/open/tiers/scihub.d.ts +3 -0
- package/dist/capabilities/download/content/pdf/open/tiers/scihub.d.ts.map +1 -0
- package/dist/capabilities/download/content/pdf/open/tiers/scihub.js.map +1 -0
- package/dist/capabilities/download/content/pdf/open/tiers/unpaywall.d.ts +3 -0
- package/dist/capabilities/download/content/pdf/open/tiers/unpaywall.d.ts.map +1 -0
- package/dist/capabilities/{pdf-discovery → download/content/pdf/open}/tiers/unpaywall.js +2 -2
- package/dist/capabilities/download/content/pdf/open/tiers/unpaywall.js.map +1 -0
- package/dist/capabilities/download/content/pdf/school.d.ts +4 -0
- package/dist/capabilities/download/content/pdf/school.d.ts.map +1 -0
- package/dist/capabilities/{pdf-discovery/tiers/entitledAccess.js → download/content/pdf/school.js} +16 -38
- package/dist/capabilities/download/content/pdf/school.js.map +1 -0
- package/dist/capabilities/download/content/supplements/fetch.d.ts +27 -0
- package/dist/capabilities/download/content/supplements/fetch.d.ts.map +1 -0
- package/dist/capabilities/download/content/supplements/fetch.js +150 -0
- package/dist/capabilities/download/content/supplements/fetch.js.map +1 -0
- package/dist/capabilities/download/content/supplements/shortfall.d.ts +11 -0
- package/dist/capabilities/download/content/supplements/shortfall.d.ts.map +1 -0
- package/dist/capabilities/download/content/supplements/shortfall.js +24 -0
- package/dist/capabilities/download/content/supplements/shortfall.js.map +1 -0
- package/dist/capabilities/{pdf-discovery → download}/handler.d.ts +12 -4
- package/dist/capabilities/download/handler.d.ts.map +1 -0
- package/dist/capabilities/download/handler.js +275 -0
- package/dist/capabilities/download/handler.js.map +1 -0
- package/dist/capabilities/{pdf-discovery → download}/index.d.ts +3 -3
- package/dist/capabilities/download/index.d.ts.map +1 -0
- package/dist/capabilities/{pdf-discovery → download}/index.js +2 -2
- package/dist/capabilities/download/index.js.map +1 -0
- package/dist/capabilities/download/outputLayout.d.ts.map +1 -0
- package/dist/capabilities/{pdf-discovery → download}/outputLayout.js +63 -6
- package/dist/capabilities/download/outputLayout.js.map +1 -0
- package/dist/capabilities/{pdf-discovery → download}/schemas.d.ts +143 -18
- package/dist/capabilities/download/schemas.d.ts.map +1 -0
- package/dist/capabilities/download/schemas.js +126 -0
- package/dist/capabilities/download/schemas.js.map +1 -0
- package/dist/capabilities/{pdf-discovery → download}/tools.d.ts +68 -6
- package/dist/capabilities/download/tools.d.ts.map +1 -0
- package/dist/capabilities/download/tools.js +197 -0
- package/dist/capabilities/download/tools.js.map +1 -0
- package/dist/capabilities/download/types.d.ts +222 -0
- package/dist/capabilities/download/types.d.ts.map +1 -0
- package/dist/capabilities/download/types.js +7 -0
- package/dist/capabilities/download/types.js.map +1 -0
- package/dist/cli.js +98 -17
- package/dist/cli.js.map +1 -1
- package/dist/config/edition.d.ts +8 -0
- package/dist/config/edition.d.ts.map +1 -0
- package/dist/config/edition.js +31 -0
- package/dist/config/edition.js.map +1 -0
- package/dist/core/handleToolCall.d.ts +1 -1
- package/dist/core/handleToolCall.d.ts.map +1 -1
- package/dist/core/handleToolCall.js +1 -1
- package/dist/core/handleToolCall.js.map +1 -1
- package/dist/core/schemas.d.ts +1 -1
- package/dist/core/schemas.d.ts.map +1 -1
- package/dist/core/schemas.js +1 -1
- package/dist/core/schemas.js.map +1 -1
- package/dist/core/tools.d.ts +2 -1
- package/dist/core/tools.d.ts.map +1 -1
- package/dist/core/tools.js +8 -2
- package/dist/core/tools.js.map +1 -1
- package/dist/infrastructure/pdf/PdfIdentity.d.ts.map +1 -1
- package/dist/infrastructure/pdf/PdfIdentity.js +76 -5
- package/dist/infrastructure/pdf/PdfIdentity.js.map +1 -1
- package/dist/infrastructure/runlog/RunLedger.d.ts +12 -2
- package/dist/infrastructure/runlog/RunLedger.d.ts.map +1 -1
- package/dist/infrastructure/runlog/RunLedger.js +39 -11
- package/dist/infrastructure/runlog/RunLedger.js.map +1 -1
- package/dist/infrastructure/runlog/failureClass.d.ts +9 -6
- package/dist/infrastructure/runlog/failureClass.d.ts.map +1 -1
- package/dist/infrastructure/runlog/failureClass.js +81 -41
- package/dist/infrastructure/runlog/failureClass.js.map +1 -1
- package/dist/infrastructure/school/SchoolAttempt.d.ts.map +1 -0
- package/dist/{capabilities/pdf-discovery → infrastructure}/school/SchoolAttempt.js +12 -3
- package/dist/infrastructure/school/SchoolAttempt.js.map +1 -0
- package/dist/{capabilities/pdf-discovery → infrastructure}/school/SchoolMcpClient.d.ts +17 -0
- package/dist/infrastructure/school/SchoolMcpClient.d.ts.map +1 -0
- package/dist/{capabilities/pdf-discovery → infrastructure}/school/SchoolMcpClient.js +99 -10
- package/dist/infrastructure/school/SchoolMcpClient.js.map +1 -0
- package/dist/{capabilities/pdf-discovery → infrastructure}/school/SchoolProgress.d.ts +1 -0
- package/dist/infrastructure/school/SchoolProgress.d.ts.map +1 -0
- package/dist/{capabilities/pdf-discovery → infrastructure}/school/SchoolProgress.js +1 -0
- package/dist/infrastructure/school/SchoolProgress.js.map +1 -0
- package/dist/{capabilities/pdf-discovery → infrastructure}/school/SchoolReadiness.d.ts +7 -1
- package/dist/infrastructure/school/SchoolReadiness.d.ts.map +1 -0
- package/dist/{capabilities/pdf-discovery → infrastructure}/school/SchoolReadiness.js +10 -2
- package/dist/infrastructure/school/SchoolReadiness.js.map +1 -0
- package/dist/infrastructure/school/SchoolResultNormalizer.d.ts.map +1 -0
- package/dist/{capabilities/pdf-discovery → infrastructure}/school/SchoolResultNormalizer.js +72 -3
- package/dist/infrastructure/school/SchoolResultNormalizer.js.map +1 -0
- package/dist/{capabilities/pdf-discovery → infrastructure}/school/index.d.ts +2 -1
- package/dist/infrastructure/school/index.d.ts.map +1 -0
- package/dist/{capabilities/pdf-discovery → infrastructure}/school/index.js +3 -2
- package/dist/infrastructure/school/index.js.map +1 -0
- package/dist/{capabilities/pdf-discovery → infrastructure}/school/types.d.ts +85 -5
- package/dist/infrastructure/school/types.d.ts.map +1 -0
- package/dist/infrastructure/school/types.js +5 -0
- package/dist/infrastructure/school/types.js.map +1 -0
- package/dist/management/capability-profile/schoolReadiness.d.ts +1 -1
- package/dist/management/capability-profile/schoolReadiness.d.ts.map +1 -1
- package/dist/management/capability-profile/schoolReadiness.js +1 -1
- package/dist/management/capability-profile/schoolReadiness.js.map +1 -1
- package/dist/management/failures/exportReport.d.ts +6 -0
- package/dist/management/failures/exportReport.d.ts.map +1 -1
- package/dist/management/failures/exportReport.js +28 -18
- package/dist/management/failures/exportReport.js.map +1 -1
- package/dist/management/failures/index.d.ts +3 -0
- package/dist/management/failures/index.d.ts.map +1 -1
- package/dist/management/failures/index.js +5 -2
- package/dist/management/failures/index.js.map +1 -1
- package/dist/management/failures/markdownReport.d.ts +55 -0
- package/dist/management/failures/markdownReport.d.ts.map +1 -0
- package/dist/management/failures/markdownReport.js +96 -0
- package/dist/management/failures/markdownReport.js.map +1 -0
- package/dist/management/pro/install.d.ts +58 -0
- package/dist/management/pro/install.d.ts.map +1 -0
- package/dist/management/pro/install.js +235 -0
- package/dist/management/pro/install.js.map +1 -0
- package/dist/management/reports/index.d.ts.map +1 -1
- package/dist/management/reports/index.js +4 -1
- package/dist/management/reports/index.js.map +1 -1
- package/dist/management/school/autoUpdate.d.ts +4 -3
- package/dist/management/school/autoUpdate.d.ts.map +1 -1
- package/dist/management/school/autoUpdate.js +6 -4
- package/dist/management/school/autoUpdate.js.map +1 -1
- package/dist/management/school/cliProgress.d.ts +1 -1
- package/dist/management/school/cliProgress.d.ts.map +1 -1
- package/dist/management/school/cliProgress.js +1 -0
- package/dist/management/school/cliProgress.js.map +1 -1
- package/dist/management/school/host.js +1 -1
- package/dist/management/school/host.js.map +1 -1
- package/dist/management/school/installer.d.ts +1 -2
- package/dist/management/school/installer.d.ts.map +1 -1
- package/dist/management/school/installer.js.map +1 -1
- package/dist/management/school/legacy.js +1 -1
- package/dist/management/school/legacy.js.map +1 -1
- package/dist/management/school/settingsWindow.d.ts +14 -3
- package/dist/management/school/settingsWindow.d.ts.map +1 -1
- package/dist/management/school/settingsWindow.js +14 -4
- package/dist/management/school/settingsWindow.js.map +1 -1
- package/dist/management/skills/autoSync.d.ts +3 -3
- package/dist/management/skills/autoSync.d.ts.map +1 -1
- package/dist/management/skills/autoSync.js +13 -20
- package/dist/management/skills/autoSync.js.map +1 -1
- package/dist/services/OpenAccessFallbackService.d.ts +3 -3
- package/dist/services/OpenAccessFallbackService.d.ts.map +1 -1
- package/dist/services/OpenAccessFallbackService.js +1 -1
- package/dist/services/OpenAccessFallbackService.js.map +1 -1
- package/dist/skills/SkillInstaller.d.ts +26 -0
- package/dist/skills/SkillInstaller.d.ts.map +1 -1
- package/dist/skills/SkillInstaller.js +80 -10
- package/dist/skills/SkillInstaller.js.map +1 -1
- package/package.json +10 -2
- package/school/LICENSE +661 -21
- package/school/LICENSE-scansci-pdf +21 -0
- package/school/NOTICE +10 -0
- package/school/README.md +1 -1
- package/school/paper_search_school/_core/__init__.py +2 -1
- package/school/paper_search_school/adapters/__init__.py +3 -3
- package/school/paper_search_school/adapters/acm/__init__.py +7 -1
- package/school/paper_search_school/adapters/acs/__init__.py +4 -0
- package/school/paper_search_school/adapters/aha_journals/__init__.py +5 -1
- package/school/paper_search_school/adapters/aip/__init__.py +17 -0
- package/school/paper_search_school/adapters/ams/__init__.py +36 -0
- package/school/paper_search_school/adapters/annual_reviews/__init__.py +24 -1
- package/school/paper_search_school/adapters/aps/__init__.py +118 -0
- package/school/paper_search_school/adapters/asce/__init__.py +7 -1
- package/school/paper_search_school/adapters/base.py +21 -1
- package/school/paper_search_school/adapters/bmj/__init__.py +54 -0
- package/school/paper_search_school/adapters/copernicus/__init__.py +35 -0
- package/school/paper_search_school/adapters/dovepress/__init__.py +31 -0
- package/school/paper_search_school/adapters/elsevier/__init__.py +33 -0
- package/school/paper_search_school/adapters/frontiers/__init__.py +46 -1
- package/school/paper_search_school/adapters/ieee/__init__.py +94 -2
- package/school/paper_search_school/adapters/iop/__init__.py +65 -0
- package/school/paper_search_school/adapters/jama/__init__.py +4 -0
- package/school/paper_search_school/adapters/karger/__init__.py +6 -1
- package/school/paper_search_school/adapters/lww/__init__.py +3 -0
- package/school/paper_search_school/adapters/lww/ovid.py +28 -0
- package/school/paper_search_school/adapters/mdpi/__init__.py +73 -0
- package/school/paper_search_school/adapters/nejm/__init__.py +5 -1
- package/school/paper_search_school/adapters/neurology/__init__.py +5 -1
- package/school/paper_search_school/adapters/optica/__init__.py +49 -0
- package/school/paper_search_school/adapters/oup/__init__.py +34 -2
- package/school/paper_search_school/adapters/platforms/atypon/__init__.py +83 -2
- package/school/paper_search_school/adapters/platforms/figshare/__init__.py +0 -3
- package/school/paper_search_school/adapters/platforms/silverchair/__init__.py +76 -0
- package/school/paper_search_school/adapters/plos/__init__.py +85 -2
- package/school/paper_search_school/adapters/pnas/__init__.py +5 -1
- package/school/paper_search_school/adapters/royal_society/__init__.py +17 -0
- package/school/paper_search_school/adapters/rsc/__init__.py +4 -1
- package/school/paper_search_school/adapters/sage/__init__.py +6 -0
- package/school/paper_search_school/adapters/science/__init__.py +5 -1
- package/school/paper_search_school/adapters/springer/__init__.py +102 -0
- package/school/paper_search_school/adapters/taylor_francis/__init__.py +11 -1
- package/school/paper_search_school/adapters/thieme/__init__.py +46 -0
- package/school/paper_search_school/adapters/wiley/__init__.py +28 -0
- package/school/paper_search_school/adapters/world_scientific/__init__.py +15 -4
- package/school/paper_search_school/assets/capsule.html +607 -41
- package/school/paper_search_school/assets/capsule_en.json +314 -5
- package/school/paper_search_school/browser/__init__.py +5 -2
- package/school/paper_search_school/browser/backend.py +161 -9
- package/school/paper_search_school/browser/batch_session.py +76 -2
- package/school/paper_search_school/browser/challenge/__init__.py +13 -0
- package/school/paper_search_school/browser/{challenges.py → challenge/detection.py} +1 -1
- package/school/paper_search_school/browser/{challenge_interaction.py → challenge/interaction.py} +92 -19
- package/school/paper_search_school/browser/challenge/pointer.py +228 -0
- package/school/paper_search_school/browser/challenge/prompt.py +154 -0
- package/school/paper_search_school/browser/challenge/warmup.py +90 -0
- package/school/paper_search_school/browser/driver.py +12 -0
- package/school/paper_search_school/browser/profiles.py +54 -3
- package/school/paper_search_school/browser/watchdog.py +8 -0
- package/school/paper_search_school/cli.py +150 -10
- package/school/paper_search_school/cold_start.py +5 -2
- package/school/paper_search_school/config.py +25 -1
- package/school/paper_search_school/download_diagnostics.py +3 -2
- package/school/paper_search_school/edition.py +22 -0
- package/school/paper_search_school/engine/access_rules.py +62 -2
- package/school/paper_search_school/engine/batch.py +56 -12
- package/school/paper_search_school/engine/batch_access.py +12 -1
- package/school/paper_search_school/engine/batch_capture.py +309 -9
- package/school/paper_search_school/engine/batch_common.py +3 -1
- package/school/paper_search_school/engine/batch_institution.py +145 -21
- package/school/paper_search_school/engine/batch_login.py +554 -21
- package/school/paper_search_school/engine/batch_waits.py +76 -1
- package/school/paper_search_school/engine/bridge.py +139 -7
- package/school/paper_search_school/engine/fulltext_page.py +340 -0
- package/school/paper_search_school/engine/pdf_guard.py +65 -5
- package/school/paper_search_school/engine/router.py +3 -2
- package/school/paper_search_school/engine/supplement_transfer.py +22 -7
- package/school/paper_search_school/engine/supplements.py +5 -8
- package/school/paper_search_school/federations/__init__.py +9 -6
- package/school/paper_search_school/{carsi_schools.py → federations/carsi.py} +1 -1
- package/school/paper_search_school/federations/{builtin → data/asia}/cstcloud.json +2 -2
- package/school/paper_search_school/federations/{builtin → data/europe}/eduidhu.json +2 -2
- package/school/paper_search_school/login_routes.py +45 -0
- package/school/paper_search_school/markdown_report.py +426 -0
- package/school/paper_search_school/orchestrator.py +25 -1
- package/school/paper_search_school/pro_status.py +192 -0
- package/school/paper_search_school/progress_capsule.py +192 -2
- package/school/paper_search_school/progress_reporter.py +100 -16
- package/school/paper_search_school/progress_status.py +1 -1
- package/school/paper_search_school/progress_view.py +171 -26
- package/school/paper_search_school/publishers/profiles.py +6 -0
- package/school/paper_search_school/rate_limit.py +7 -0
- package/school/paper_search_school/report_sanitizer.py +25 -11
- package/school/paper_search_school/school_login.py +373 -0
- package/school/paper_search_school/schools/__init__.py +7 -0
- package/school/paper_search_school/{federations/schools.py → schools/lookup.py} +3 -3
- package/school/paper_search_school/schools/saved.py +111 -0
- package/school/paper_search_school/server.py +53 -9
- package/school/paper_search_school/user_settings.py +14 -0
- package/school/pyproject.toml +3 -2
- package/skills/paper-search/SKILL.md +11 -12
- package/skills/paper-search/references/browser-download.md +20 -15
- package/skills/paper-search/references/capability-routing.md +1 -1
- package/skills/paper-search/references/cli-contract.md +7 -5
- package/skills/paper-search/references/management-layer.md +3 -3
- package/skills/paper-search/references/publisher-support.md +5 -5
- package/skills/paper-search/references/school-setup.md +14 -0
- package/skills/paper-search/references/troubleshooting.md +0 -1
- package/assets/ask-with-skill.png +0 -0
- package/dist/capabilities/pdf-discovery/DownloadTier.d.ts.map +0 -1
- package/dist/capabilities/pdf-discovery/DownloadTier.js.map +0 -1
- package/dist/capabilities/pdf-discovery/OpenAccessFallbackService.d.ts.map +0 -1
- package/dist/capabilities/pdf-discovery/OpenAccessFallbackService.js.map +0 -1
- package/dist/capabilities/pdf-discovery/arxiv.d.ts.map +0 -1
- package/dist/capabilities/pdf-discovery/arxiv.js.map +0 -1
- package/dist/capabilities/pdf-discovery/batch.d.ts.map +0 -1
- package/dist/capabilities/pdf-discovery/batch.js.map +0 -1
- package/dist/capabilities/pdf-discovery/batchPapers.d.ts.map +0 -1
- package/dist/capabilities/pdf-discovery/batchPapers.js.map +0 -1
- package/dist/capabilities/pdf-discovery/batchSummary.d.ts.map +0 -1
- package/dist/capabilities/pdf-discovery/batchSummary.js +0 -191
- package/dist/capabilities/pdf-discovery/batchSummary.js.map +0 -1
- package/dist/capabilities/pdf-discovery/handler.d.ts.map +0 -1
- package/dist/capabilities/pdf-discovery/handler.js +0 -166
- package/dist/capabilities/pdf-discovery/handler.js.map +0 -1
- package/dist/capabilities/pdf-discovery/identity.d.ts.map +0 -1
- package/dist/capabilities/pdf-discovery/identity.js.map +0 -1
- package/dist/capabilities/pdf-discovery/index.d.ts.map +0 -1
- package/dist/capabilities/pdf-discovery/index.js.map +0 -1
- package/dist/capabilities/pdf-discovery/oaHosts.d.ts.map +0 -1
- package/dist/capabilities/pdf-discovery/oaHosts.js.map +0 -1
- package/dist/capabilities/pdf-discovery/outputLayout.d.ts.map +0 -1
- package/dist/capabilities/pdf-discovery/outputLayout.js.map +0 -1
- package/dist/capabilities/pdf-discovery/pmcCloud.d.ts.map +0 -1
- package/dist/capabilities/pdf-discovery/pmcCloud.js.map +0 -1
- package/dist/capabilities/pdf-discovery/publisherApi/elsevier.d.ts.map +0 -1
- package/dist/capabilities/pdf-discovery/publisherApi/elsevier.js.map +0 -1
- package/dist/capabilities/pdf-discovery/publisherApi/index.d.ts.map +0 -1
- package/dist/capabilities/pdf-discovery/publisherApi/index.js.map +0 -1
- package/dist/capabilities/pdf-discovery/publisherApi/springer.d.ts.map +0 -1
- package/dist/capabilities/pdf-discovery/publisherApi/springer.js.map +0 -1
- package/dist/capabilities/pdf-discovery/resume.d.ts +0 -22
- package/dist/capabilities/pdf-discovery/resume.d.ts.map +0 -1
- package/dist/capabilities/pdf-discovery/resume.js +0 -114
- package/dist/capabilities/pdf-discovery/resume.js.map +0 -1
- package/dist/capabilities/pdf-discovery/schemas.d.ts.map +0 -1
- package/dist/capabilities/pdf-discovery/schemas.js +0 -75
- package/dist/capabilities/pdf-discovery/schemas.js.map +0 -1
- package/dist/capabilities/pdf-discovery/school/SchoolAttempt.d.ts.map +0 -1
- package/dist/capabilities/pdf-discovery/school/SchoolAttempt.js.map +0 -1
- package/dist/capabilities/pdf-discovery/school/SchoolMcpClient.d.ts.map +0 -1
- package/dist/capabilities/pdf-discovery/school/SchoolMcpClient.js.map +0 -1
- package/dist/capabilities/pdf-discovery/school/SchoolProgress.d.ts.map +0 -1
- package/dist/capabilities/pdf-discovery/school/SchoolProgress.js.map +0 -1
- package/dist/capabilities/pdf-discovery/school/SchoolReadiness.d.ts.map +0 -1
- package/dist/capabilities/pdf-discovery/school/SchoolReadiness.js.map +0 -1
- package/dist/capabilities/pdf-discovery/school/SchoolResultNormalizer.d.ts.map +0 -1
- package/dist/capabilities/pdf-discovery/school/SchoolResultNormalizer.js.map +0 -1
- package/dist/capabilities/pdf-discovery/school/index.d.ts.map +0 -1
- package/dist/capabilities/pdf-discovery/school/index.js.map +0 -1
- package/dist/capabilities/pdf-discovery/school/types.d.ts.map +0 -1
- package/dist/capabilities/pdf-discovery/school/types.js +0 -2
- package/dist/capabilities/pdf-discovery/school/types.js.map +0 -1
- package/dist/capabilities/pdf-discovery/tiers/directPdfUrl.d.ts +0 -5
- package/dist/capabilities/pdf-discovery/tiers/directPdfUrl.d.ts.map +0 -1
- package/dist/capabilities/pdf-discovery/tiers/directPdfUrl.js.map +0 -1
- package/dist/capabilities/pdf-discovery/tiers/entitledAccess.d.ts +0 -10
- package/dist/capabilities/pdf-discovery/tiers/entitledAccess.d.ts.map +0 -1
- package/dist/capabilities/pdf-discovery/tiers/entitledAccess.js.map +0 -1
- package/dist/capabilities/pdf-discovery/tiers/preprint.d.ts +0 -5
- package/dist/capabilities/pdf-discovery/tiers/preprint.d.ts.map +0 -1
- package/dist/capabilities/pdf-discovery/tiers/preprint.js.map +0 -1
- package/dist/capabilities/pdf-discovery/tiers/primary.d.ts +0 -3
- package/dist/capabilities/pdf-discovery/tiers/primary.d.ts.map +0 -1
- package/dist/capabilities/pdf-discovery/tiers/primary.js.map +0 -1
- package/dist/capabilities/pdf-discovery/tiers/publisherApi.d.ts.map +0 -1
- package/dist/capabilities/pdf-discovery/tiers/publisherApi.js.map +0 -1
- package/dist/capabilities/pdf-discovery/tiers/repositories.d.ts.map +0 -1
- package/dist/capabilities/pdf-discovery/tiers/repositories.js.map +0 -1
- package/dist/capabilities/pdf-discovery/tiers/scihub.d.ts +0 -3
- package/dist/capabilities/pdf-discovery/tiers/scihub.d.ts.map +0 -1
- package/dist/capabilities/pdf-discovery/tiers/scihub.js.map +0 -1
- package/dist/capabilities/pdf-discovery/tiers/unpaywall.d.ts +0 -3
- package/dist/capabilities/pdf-discovery/tiers/unpaywall.d.ts.map +0 -1
- package/dist/capabilities/pdf-discovery/tiers/unpaywall.js.map +0 -1
- package/dist/capabilities/pdf-discovery/tools.d.ts.map +0 -1
- package/dist/capabilities/pdf-discovery/tools.js +0 -146
- package/dist/capabilities/pdf-discovery/tools.js.map +0 -1
- package/dist/capabilities/pdf-discovery/types.d.ts +0 -102
- package/dist/capabilities/pdf-discovery/types.d.ts.map +0 -1
- package/dist/capabilities/pdf-discovery/types.js +0 -2
- package/dist/capabilities/pdf-discovery/types.js.map +0 -1
- /package/dist/capabilities/{pdf-discovery → download/batch}/batchPapers.js +0 -0
- /package/dist/capabilities/{pdf-discovery → download/content/pdf}/DownloadTier.js +0 -0
- /package/dist/capabilities/{pdf-discovery → download/content/pdf}/arxiv.d.ts +0 -0
- /package/dist/capabilities/{pdf-discovery → download/content/pdf}/identity.js +0 -0
- /package/dist/capabilities/{pdf-discovery → download/content/pdf/open}/oaHosts.d.ts +0 -0
- /package/dist/capabilities/{pdf-discovery → download/content/pdf/open}/oaHosts.js +0 -0
- /package/dist/capabilities/{pdf-discovery → download/content/pdf/open}/pmcCloud.d.ts +0 -0
- /package/dist/capabilities/{pdf-discovery → download/content/pdf/open}/publisherApi/elsevier.d.ts +0 -0
- /package/dist/capabilities/{pdf-discovery → download/content/pdf/open}/publisherApi/index.d.ts +0 -0
- /package/dist/capabilities/{pdf-discovery → download/content/pdf/open}/publisherApi/index.js +0 -0
- /package/dist/capabilities/{pdf-discovery → download/content/pdf/open}/publisherApi/springer.d.ts +0 -0
- /package/dist/capabilities/{pdf-discovery → download/content/pdf/open}/tiers/primary.js +0 -0
- /package/dist/capabilities/{pdf-discovery → download/content/pdf/open}/tiers/scihub.js +0 -0
- /package/dist/capabilities/{pdf-discovery → download}/outputLayout.d.ts +0 -0
- /package/dist/{capabilities/pdf-discovery → infrastructure}/school/SchoolAttempt.d.ts +0 -0
- /package/dist/{capabilities/pdf-discovery → infrastructure}/school/SchoolResultNormalizer.d.ts +0 -0
- /package/school/paper_search_school/federations/{builtin → data/africa}/eduidbf.json +0 -0
- /package/school/paper_search_school/federations/{builtin → data/africa}/eduidma.json +0 -0
- /package/school/paper_search_school/federations/{builtin → data/africa}/eduidtg.json +0 -0
- /package/school/paper_search_school/federations/{builtin → data/africa}/fidern.json +0 -0
- /package/school/paper_search_school/federations/{builtin → data/africa}/garnet.json +0 -0
- /package/school/paper_search_school/federations/{builtin → data/africa}/maren.json +0 -0
- /package/school/paper_search_school/federations/{builtin → data/africa}/ngrenid.json +0 -0
- /package/school/paper_search_school/federations/{builtin → data/africa}/rafiki.json +0 -0
- /package/school/paper_search_school/federations/{builtin → data/africa}/rif.json +0 -0
- /package/school/paper_search_school/federations/{builtin → data/africa}/safire.json +0 -0
- /package/school/paper_search_school/federations/{builtin → data/africa}/ternet.json +0 -0
- /package/school/paper_search_school/federations/{builtin → data/americas}/caf.json +0 -0
- /package/school/paper_search_school/federations/{builtin → data/americas}/cafe.json +0 -0
- /package/school/paper_search_school/federations/{builtin → data/americas}/cofre.json +0 -0
- /package/school/paper_search_school/federations/{builtin → data/americas}/colfire.json +0 -0
- /package/school/paper_search_school/federations/{builtin → data/americas}/fenix.json +0 -0
- /package/school/paper_search_school/federations/{builtin → data/americas}/incommon.json +0 -0
- /package/school/paper_search_school/federations/{builtin → data/americas}/minga.json +0 -0
- /package/school/paper_search_school/federations/{builtin → data/asia}/azsciencenet.json +0 -0
- /package/school/paper_search_school/federations/{builtin → data/asia}/carsi.json +0 -0
- /package/school/paper_search_school/federations/{builtin → data/asia}/cynet.json +0 -0
- /package/school/paper_search_school/federations/{builtin → data/asia}/gakunin.json +0 -0
- /package/school/paper_search_school/federations/{builtin → data/asia}/hkaf.json +0 -0
- /package/school/paper_search_school/federations/{builtin → data/asia}/infed.json +0 -0
- /package/school/paper_search_school/federations/{builtin → data/asia}/irfed.json +0 -0
- /package/school/paper_search_school/federations/{builtin → data/asia}/iucc.json +0 -0
- /package/school/paper_search_school/federations/{builtin → data/asia}/kafe.json +0 -0
- /package/school/paper_search_school/federations/{builtin → data/asia}/liaf.json +0 -0
- /package/school/paper_search_school/federations/{builtin → data/asia}/maeen.json +0 -0
- /package/school/paper_search_school/federations/{builtin → data/asia}/omren.json +0 -0
- /package/school/paper_search_school/federations/{builtin → data/asia}/pkifed.json +0 -0
- /package/school/paper_search_school/federations/{builtin → data/asia}/sgaf.json +0 -0
- /package/school/paper_search_school/federations/{builtin → data/asia}/sifulan.json +0 -0
- /package/school/paper_search_school/federations/{builtin → data/asia}/tigerfed.json +0 -0
- /package/school/paper_search_school/federations/{builtin → data/asia}/yetkim.json +0 -0
- /package/school/paper_search_school/federations/{builtin → data/europe}/aaieduhr.json +0 -0
- /package/school/paper_search_school/federations/{builtin → data/europe}/aaiedumk.json +0 -0
- /package/school/paper_search_school/federations/{builtin → data/europe}/aconet.json +0 -0
- /package/school/paper_search_school/federations/{builtin → data/europe}/arnesaai.json +0 -0
- /package/school/paper_search_school/federations/{builtin → data/europe}/belnet.json +0 -0
- /package/school/paper_search_school/federations/{builtin → data/europe}/bif.json +0 -0
- /package/school/paper_search_school/federations/{builtin → data/europe}/dfnaai.json +0 -0
- /package/school/paper_search_school/federations/{builtin → data/europe}/edugate.json +0 -0
- /package/school/paper_search_school/federations/{builtin → data/europe}/eduidcz.json +0 -0
- /package/school/paper_search_school/federations/{builtin → data/europe}/eduidlu.json +0 -0
- /package/school/paper_search_school/federations/{builtin → data/europe}/febas.json +0 -0
- /package/school/paper_search_school/federations/{builtin → data/europe}/feide.json +0 -0
- /package/school/paper_search_school/federations/{builtin → data/europe}/grnet.json +0 -0
- /package/school/paper_search_school/federations/{builtin → data/europe}/haka.json +0 -0
- /package/school/paper_search_school/federations/{builtin → data/europe}/iamres.json +0 -0
- /package/school/paper_search_school/federations/{builtin → data/europe}/idedume.json +0 -0
- /package/school/paper_search_school/federations/{builtin → data/europe}/idem.json +0 -0
- /package/school/paper_search_school/federations/{builtin → data/europe}/laife.json +0 -0
- /package/school/paper_search_school/federations/{builtin → data/europe}/leaf.json +0 -0
- /package/school/paper_search_school/federations/{builtin → data/europe}/litnet.json +0 -0
- /package/school/paper_search_school/federations/{builtin → data/europe}/peano.json +0 -0
- /package/school/paper_search_school/federations/{builtin → data/europe}/pionierid.json +0 -0
- /package/school/paper_search_school/federations/{builtin → data/europe}/rash.json +0 -0
- /package/school/paper_search_school/federations/{builtin → data/europe}/rctsaai.json +0 -0
- /package/school/paper_search_school/federations/{builtin → data/europe}/renater.json +0 -0
- /package/school/paper_search_school/federations/{builtin → data/europe}/ricerkanet.json +0 -0
- /package/school/paper_search_school/federations/{builtin → data/europe}/roedunetid.json +0 -0
- /package/school/paper_search_school/federations/{builtin → data/europe}/safeid.json +0 -0
- /package/school/paper_search_school/federations/{builtin → data/europe}/sir.json +0 -0
- /package/school/paper_search_school/federations/{builtin → data/europe}/surfconext.json +0 -0
- /package/school/paper_search_school/federations/{builtin → data/europe}/swamid.json +0 -0
- /package/school/paper_search_school/federations/{builtin → data/europe}/switchaai.json +0 -0
- /package/school/paper_search_school/federations/{builtin → data/europe}/taat.json +0 -0
- /package/school/paper_search_school/federations/{builtin → data/europe}/ukfederation.json +0 -0
- /package/school/paper_search_school/federations/{builtin → data/europe}/wayf.json +0 -0
- /package/school/paper_search_school/federations/{builtin → data/global}/openathens.json +0 -0
- /package/school/paper_search_school/federations/{builtin → data/oceania}/aaf.json +0 -0
- /package/school/paper_search_school/federations/{builtin → data/oceania}/tuakiri.json +0 -0
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
"""--fulltext: the article's full-text page, saved while the browser is on it for the PDF.
|
|
2
|
+
|
|
3
|
+
PaperSearch turns the page into Markdown (src/capabilities/download/content/markdown/); this module only
|
|
4
|
+
keeps what it needs, in two steps that never load the article page again:
|
|
5
|
+
|
|
6
|
+
1. ``read_page``, on the article page before the PDF is captured: once the page has
|
|
7
|
+
stopped changing, and only when it names this DOI and shows the full text (the
|
|
8
|
+
adapter's ``fulltext_shown_js``, waited for up to 15 s: a body may come after), the page's HTML and the figure images it lists
|
|
9
|
+
(the adapter's ``fulltext_images_js``). An adapter's ``fulltext_prepare_js`` runs
|
|
10
|
+
first, in the page's own world (ScienceDirect keeps each formula's MathML), given the
|
|
11
|
+
text of the document its ``fulltext_prepare_source`` names (PLOS's article XML, which the
|
|
12
|
+
page cannot fetch). No figure is fetched yet, so the PDF's time is not spent on figures.
|
|
13
|
+
2. ``save_page``, after the PDF, with the same session's cookies (the institution login
|
|
14
|
+
and Cloudflare clearance apply): the HTML and the images into
|
|
15
|
+
|
|
16
|
+
<output dir>/<DOI>_fulltext_page/article.html
|
|
17
|
+
<output dir>/<DOI>_fulltext_page/images/<name>
|
|
18
|
+
|
|
19
|
+
and the result's ``fulltext_page``: ``{"file", "url", "images": [{"url", "file"}]}``.
|
|
20
|
+
|
|
21
|
+
Limits as for supplementary files: 50 images, 200 MB, 3 minutes.
|
|
22
|
+
"""
|
|
23
|
+
from __future__ import annotations
|
|
24
|
+
|
|
25
|
+
import re
|
|
26
|
+
import time
|
|
27
|
+
from pathlib import Path
|
|
28
|
+
from typing import Any, Callable
|
|
29
|
+
from urllib.parse import unquote, urlparse
|
|
30
|
+
|
|
31
|
+
from ..identifiers import normalize_doi
|
|
32
|
+
|
|
33
|
+
MAX_IMAGES = 50
|
|
34
|
+
MAX_BYTES = 200 * 1024 * 1024
|
|
35
|
+
TIME_BUDGET_SEC = 180
|
|
36
|
+
REQUEST_TIMEOUT_MS = 30_000
|
|
37
|
+
STABLE_INTERVAL_SEC = 0.75
|
|
38
|
+
STABLE_TIMEOUT_SEC = 8.0
|
|
39
|
+
SHOWN_WAIT_MS = 15_000
|
|
40
|
+
# The document an adapter's preparation is given (fulltext_prepare_source): at most this
|
|
41
|
+
# long and this large; without it the script runs with "" and says so.
|
|
42
|
+
PREPARE_SOURCE_TIMEOUT_MS = 15_000
|
|
43
|
+
PREPARE_SOURCE_MAX_BYTES = 20 * 1024 * 1024
|
|
44
|
+
PDF_ONLY = "pdf_only" # in the reason a page is not read: its text is in the PDF alone
|
|
45
|
+
|
|
46
|
+
# What changes while a page is still filling in: its text length and its images.
|
|
47
|
+
_FINGERPRINT_JS = """() => {
|
|
48
|
+
const body = document.body;
|
|
49
|
+
return body ? `${body.innerText.length}:${document.images.length}:${document.querySelectorAll('math, mjx-container').length}` : "";
|
|
50
|
+
}"""
|
|
51
|
+
|
|
52
|
+
# The DOI the page says it is (citation_doi, Dublin Core, PRISM).
|
|
53
|
+
_PAGE_DOI_JS = """() => {
|
|
54
|
+
const names = ["citation_doi", "dc.identifier", "dc.Identifier", "DC.identifier", "prism.doi"];
|
|
55
|
+
for (const name of names) {
|
|
56
|
+
for (const meta of document.querySelectorAll(`meta[name="${name}"]`)) {
|
|
57
|
+
const value = (meta.getAttribute("content") || "").trim();
|
|
58
|
+
if (/10\\.\\d{4,9}\\//.test(value)) return value;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return "";
|
|
62
|
+
}"""
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
# For an adapter's ``fulltext_prepare_js`` on a MathJax page that keeps no MathML in the
|
|
66
|
+
# DOM (ScienceDirect's MathJax 4, Wiley's lazy MathJax 4.1, 2026-11-14): each formula's
|
|
67
|
+
# source written onto its element as data-original-mathml, which PaperSearch reads. A
|
|
68
|
+
# formula not typeset yet (lazy) keeps it on its source node. MathJax 2 pages too. A TeX
|
|
69
|
+
# formula is left as it is: MathJax 4 writes its TeX on the output (data-latex; Optica,
|
|
70
|
+
# 2026-11-15).
|
|
71
|
+
MATHJAX_SOURCES_JS = r"""async () => {
|
|
72
|
+
const startup = window.MathJax?.startup?.promise;
|
|
73
|
+
if (startup) await Promise.race([startup, new Promise((done) => setTimeout(done, 5000))]);
|
|
74
|
+
let kept = 0;
|
|
75
|
+
const keep = (node, source) => {
|
|
76
|
+
if (node?.setAttribute && typeof source === 'string' && /^\s*<(?:[\w-]+:)?math[\s>]/.test(source)) {
|
|
77
|
+
node.setAttribute('data-original-mathml', source);
|
|
78
|
+
kept += 1;
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
const doc = window.MathJax?.startup?.document;
|
|
82
|
+
if (doc?.getMathItemsWithin) {
|
|
83
|
+
for (const item of doc.getMathItemsWithin(document.body)) keep(item.typesetRoot || item.start?.node, item.math);
|
|
84
|
+
}
|
|
85
|
+
if (window.MathJax?.Hub?.getAllJax) {
|
|
86
|
+
for (const jax of window.MathJax.Hub.getAllJax()) {
|
|
87
|
+
const source = jax.SourceElement && jax.SourceElement();
|
|
88
|
+
keep(document.getElementById(jax.inputID + '-Frame') || source?.previousElementSibling, jax.originalText);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return kept;
|
|
92
|
+
}"""
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def page_dir(output_dir: Path, doi: str) -> Path:
|
|
96
|
+
return Path(output_dir) / (re.sub(r"[^A-Za-z0-9._-]+", "_", doi) + "_fulltext_page")
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
# MathJax 2 typesets a page's formulas a batch at a time, saying so in its message box
|
|
100
|
+
# ("Typesetting math: 37%"), and the page changes until it is done: a Frontiers page with
|
|
101
|
+
# 157 formulas took 36 s, read as never settling (page_not_stable, 2026-11-18). What the box
|
|
102
|
+
# says while MathJax is at work, else "".
|
|
103
|
+
_MATHJAX_BUSY_JS = """() => {
|
|
104
|
+
const box = document.getElementById('MathJax_Message');
|
|
105
|
+
if (!box || getComputedStyle(box).display === 'none' || getComputedStyle(box).visibility === 'hidden') return '';
|
|
106
|
+
const said = (box.textContent || '').replace(/\\s+/g, ' ').trim();
|
|
107
|
+
return /^(?:typesetting|processing|loading)\\b/i.test(said) ? said.slice(0, 60) : '';
|
|
108
|
+
}"""
|
|
109
|
+
# The longest wait for MathJax 2 while its progress moves; the page read's own time goes on
|
|
110
|
+
# with it (``watchdog.extend_operation``).
|
|
111
|
+
MATHJAX_WAIT_SEC = 90
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
def wait_stable(page: Any, *, interval: float = STABLE_INTERVAL_SEC, timeout: float = STABLE_TIMEOUT_SEC,
|
|
115
|
+
clock: Callable[[], float] | None = None) -> bool:
|
|
116
|
+
"""Whether the page stopped changing: the same fingerprint twice, ``interval`` apart
|
|
117
|
+
(the browser runs meanwhile), with MathJax 2 not at work. While MathJax 2 typesets and
|
|
118
|
+
its progress moves, the wait goes on, up to ``MATHJAX_WAIT_SEC``."""
|
|
119
|
+
from ..browser import watchdog
|
|
120
|
+
|
|
121
|
+
clock = clock or time.monotonic
|
|
122
|
+
started = clock()
|
|
123
|
+
deadline = started + timeout
|
|
124
|
+
last, progress = page.evaluate(_FINGERPRINT_JS), ""
|
|
125
|
+
while clock() < deadline:
|
|
126
|
+
page.wait_for_timeout(int(interval * 1000))
|
|
127
|
+
current = page.evaluate(_FINGERPRINT_JS)
|
|
128
|
+
busy = page.evaluate(_MATHJAX_BUSY_JS)
|
|
129
|
+
if current and current == last and not busy:
|
|
130
|
+
return True
|
|
131
|
+
if busy and busy != progress and clock() - started < MATHJAX_WAIT_SEC:
|
|
132
|
+
deadline = min(max(deadline, clock() + timeout), started + MATHJAX_WAIT_SEC)
|
|
133
|
+
watchdog.extend_operation(timeout + 15)
|
|
134
|
+
last, progress = current, busy
|
|
135
|
+
return False
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
# The general rules, for a site without page scripts and a maintainer's sample
|
|
139
|
+
# (``publisher-check --fulltext``): any article page with a fair amount of text; each figure
|
|
140
|
+
# image on it, the largest a link or a lazy loader names, one address per figure (a shared
|
|
141
|
+
# placeholder would count many figures as one).
|
|
142
|
+
_SAMPLE_SHOWN_JS = """() => ((document.querySelector('main, article, [role="main"]') || document.body)?.innerText.length || 0) > 3000"""
|
|
143
|
+
_SAMPLE_IMAGES_JS = """() => [...document.querySelectorAll('figure img, .figure img, .fig img, img[data-open="viewer"]')]
|
|
144
|
+
.filter((img) => !img.closest('nav, header, footer, aside'))
|
|
145
|
+
.map((img) => {
|
|
146
|
+
const link = img.closest('a[href]');
|
|
147
|
+
const large = link && /\\.(jpe?g|png|gif|webp|tiff?)(\\?|$)/i.test(link.getAttribute('href')) ? link.getAttribute('href') : '';
|
|
148
|
+
const named = large || img.getAttribute('data-lg-src') || img.getAttribute('data-src') || img.getAttribute('data-original') || img.currentSrc || img.src;
|
|
149
|
+
try { return new URL(named, location.href).href; } catch (error) { return ''; }
|
|
150
|
+
})
|
|
151
|
+
.filter((url) => /^https?:/.test(url))"""
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
# What a page that was not taken for the full text had, for the record: its host and the
|
|
155
|
+
# text length of the usual body containers.
|
|
156
|
+
# A page that is the PDF itself (Chrome's viewer: a retracted article opened as its PDF), or
|
|
157
|
+
# whose body is a line or two while the page sends the reader to the PDF for the rest (a
|
|
158
|
+
# one-page figure article: "To view this SnapShot, open or download the PDF", 2026-11-18; an
|
|
159
|
+
# Atypon page with no HTML of the article: "You can view the full content in the following
|
|
160
|
+
# formats: PDF/eReader", ACM 10.1145/3863936, 2026-11-19):
|
|
161
|
+
# there is no full text to wait for, and no school login brings one. What it said, or "".
|
|
162
|
+
_PDF_ONLY_JS = """() => {
|
|
163
|
+
if (document.contentType === 'application/pdf'
|
|
164
|
+
|| document.querySelector('embed[type="application/pdf"], embed[type="application/x-google-chrome-pdf"]')) {
|
|
165
|
+
return 'the page is the PDF';
|
|
166
|
+
}
|
|
167
|
+
const body = ['#body', 'section#bodymatter', '[property="articleBody"]']
|
|
168
|
+
.map((selector) => document.querySelector(selector)).find(Boolean);
|
|
169
|
+
const text = ((document.querySelector('article') || document.body)?.innerText || '').replace(/\\s+/g, ' ');
|
|
170
|
+
const said = text.match(/[^.]*\\bopen or download the pdf\\b[^.]*|[^.]*\\b(?:full[ -]text|this article|the article) is (?:only )?available (?:only )?(?:as|in) (?:a )?pdf\\b[^.]*|[^.]*\\bview the full (?:content|text) in the following formats?:?\\s*pdf\\b[^.]*/i);
|
|
171
|
+
return said && (body ? body.innerText.trim().length : 0) < 600 ? said[0].trim().slice(0, 160) : '';
|
|
172
|
+
}"""
|
|
173
|
+
|
|
174
|
+
_NOT_SHOWN_EVIDENCE_JS = """() => {
|
|
175
|
+
const sizes = ['#body', 'section#bodymatter', '[property="articleBody"]', 'article', 'main']
|
|
176
|
+
.map((selector) => `${selector}=${document.querySelector(selector)?.innerText.length ?? '-'}`);
|
|
177
|
+
return `${location.hostname} ${sizes.join(' ')}`;
|
|
178
|
+
}"""
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
def read_page(page: Any, doi: str, adapter: Any, *, sample: bool = False) -> tuple[dict[str, Any] | None, str]:
|
|
182
|
+
"""The page's HTML, address and figure image addresses, or None and why not.
|
|
183
|
+
``sample``: a maintainer's sample, read with the general rules whatever the site's own
|
|
184
|
+
say (a site without rules, or one whose rules missed the page).
|
|
185
|
+
|
|
186
|
+
A site whose adapter has no page scripts (the general flow's ``site:<domain>``, or a
|
|
187
|
+
publisher without them) is read with the general rules too: PaperSearch tries its
|
|
188
|
+
templates on the page and keeps the Markdown only when it is complete (user,
|
|
189
|
+
2026-11-16). Its figures are the ones the general rule finds, a lower bound."""
|
|
190
|
+
own = getattr(adapter, "fulltext_shown_js", None)
|
|
191
|
+
general = sample or not own
|
|
192
|
+
shown_js = _SAMPLE_SHOWN_JS if general else own
|
|
193
|
+
if not wait_stable(page):
|
|
194
|
+
return None, "page_not_stable"
|
|
195
|
+
named = normalize_doi(str(page.evaluate(_PAGE_DOI_JS) or "")).lower()
|
|
196
|
+
if named and named != (normalize_doi(doi) or "").lower():
|
|
197
|
+
return None, "other_article"
|
|
198
|
+
if not sample:
|
|
199
|
+
pdf_only = str(page.evaluate(_PDF_ONLY_JS) or "")
|
|
200
|
+
if pdf_only:
|
|
201
|
+
return None, f"fulltext_not_shown: {PDF_ONLY}: {pdf_only}"
|
|
202
|
+
# A site may show the abstract first and fetch the body after it (ScienceDirect: the
|
|
203
|
+
# page stood still with "body":{} in its state, 2026-11-14): wait for the full text.
|
|
204
|
+
from .batch_common import pump_until
|
|
205
|
+
|
|
206
|
+
if not pump_until(page, lambda: bool(page.evaluate(shown_js)), SHOWN_WAIT_MS):
|
|
207
|
+
if not sample:
|
|
208
|
+
return None, f"fulltext_not_shown: {page.evaluate(_NOT_SHOWN_EVIDENCE_JS)}"
|
|
209
|
+
# A maintainer's sample is kept whatever the general rule saw: what the page holds
|
|
210
|
+
# is the point (AMS keeps its body outside main and article, 2026-11-15).
|
|
211
|
+
wait_stable(page) # the body that just arrived settles
|
|
212
|
+
# The general rules keep the formulas' MathML MathJax holds (nothing without MathJax).
|
|
213
|
+
prepare_js = getattr(adapter, "fulltext_prepare_js", None) or (MATHJAX_SOURCES_JS if general and not sample else None)
|
|
214
|
+
prepared = None
|
|
215
|
+
if prepare_js:
|
|
216
|
+
# In the page's own world: it reads the page's globals (MathJax). What it did (a
|
|
217
|
+
# count, or the site's own short report) goes into the record.
|
|
218
|
+
from ..browser.driver import main_world
|
|
219
|
+
|
|
220
|
+
source = _prepare_source(page, adapter, doi) if prepare_js is getattr(adapter, "fulltext_prepare_js", None) else None
|
|
221
|
+
if source is None:
|
|
222
|
+
prepared = page.evaluate(prepare_js, **main_world(page))
|
|
223
|
+
else:
|
|
224
|
+
text, missing = source
|
|
225
|
+
prepared = page.evaluate(prepare_js, text, **main_world(page))
|
|
226
|
+
if missing:
|
|
227
|
+
prepared = f"{prepared}; {missing}"
|
|
228
|
+
url = str(page.url)
|
|
229
|
+
html = page.evaluate("() => document.documentElement.outerHTML")
|
|
230
|
+
if str(page.url) != url:
|
|
231
|
+
# The page moved while being read: not one page's HTML.
|
|
232
|
+
return None, "page_moved"
|
|
233
|
+
own_images = getattr(adapter, "fulltext_images_js", None)
|
|
234
|
+
images_js = (own_images or _SAMPLE_IMAGES_JS) if sample else (_SAMPLE_IMAGES_JS if general else own_images)
|
|
235
|
+
images = page.evaluate(images_js) if images_js else []
|
|
236
|
+
addresses = []
|
|
237
|
+
for value in images if isinstance(images, list) else []:
|
|
238
|
+
if isinstance(value, str) and urlparse(value).scheme in ("http", "https") and value not in addresses:
|
|
239
|
+
addresses.append(value)
|
|
240
|
+
read = {"html": "<!DOCTYPE html>\n" + str(html), "url": url, "image_urls": addresses[:MAX_IMAGES],
|
|
241
|
+
**({"general": True} if general and not sample else {})}
|
|
242
|
+
if isinstance(prepared, (int, float, str)) and not isinstance(prepared, bool):
|
|
243
|
+
read["prepared"] = str(prepared)[:300]
|
|
244
|
+
return read, ""
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
def _prepare_source(page: Any, adapter: Any, doi: str) -> tuple[str, str] | None:
|
|
248
|
+
"""The document the adapter's preparation is given, fetched in the browser session (its
|
|
249
|
+
cookies; no CORS): its text and "", or "" and why there is none; None when the adapter
|
|
250
|
+
names no document."""
|
|
251
|
+
named = getattr(adapter, "fulltext_prepare_source", None)
|
|
252
|
+
url = named(doi, str(page.url)) if callable(named) else ""
|
|
253
|
+
if not url:
|
|
254
|
+
return None
|
|
255
|
+
from ..browser import watchdog
|
|
256
|
+
from ..browser.driver import driver_lost, is_driver_error
|
|
257
|
+
|
|
258
|
+
# The page read's budget leaves the fetch its time, as it does MathJax's wait.
|
|
259
|
+
watchdog.extend_operation(PREPARE_SOURCE_TIMEOUT_MS / 1000 + 5)
|
|
260
|
+
try:
|
|
261
|
+
response = page.context.request.get(url, timeout=PREPARE_SOURCE_TIMEOUT_MS)
|
|
262
|
+
except Exception as exc:
|
|
263
|
+
if not is_driver_error(exc) or driver_lost(exc):
|
|
264
|
+
raise
|
|
265
|
+
return "", f"source not fetched: {type(exc).__name__}"
|
|
266
|
+
try:
|
|
267
|
+
if not response.ok:
|
|
268
|
+
return "", f"source not fetched: http_{response.status}"
|
|
269
|
+
body = response.body()
|
|
270
|
+
if len(body) > PREPARE_SOURCE_MAX_BYTES:
|
|
271
|
+
return "", "source not fetched: too_large"
|
|
272
|
+
return body.decode("utf-8", errors="replace"), ""
|
|
273
|
+
finally:
|
|
274
|
+
response.dispose()
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
def _image_name(url: str, content_type: str, taken: set[str]) -> str:
|
|
278
|
+
raw = unquote(urlparse(url).path.rsplit("/", 1)[-1]) or "image"
|
|
279
|
+
name = re.sub(r"[^A-Za-z0-9._-]+", "_", raw).strip("._") or "image"
|
|
280
|
+
if not re.search(r"\.(jpe?g|png|gif|webp|svg|tiff?)$", name, re.I):
|
|
281
|
+
extension = {"image/jpeg": ".jpg", "image/png": ".png", "image/gif": ".gif", "image/webp": ".webp",
|
|
282
|
+
"image/svg+xml": ".svg"}.get(content_type.split(";")[0].strip().lower(), "")
|
|
283
|
+
name += extension
|
|
284
|
+
stem, dot, extension = name.rpartition(".")
|
|
285
|
+
candidate, n = name, 2
|
|
286
|
+
while candidate.lower() in taken:
|
|
287
|
+
candidate = f"{stem}-{n}.{extension}" if dot else f"{name}-{n}"
|
|
288
|
+
n += 1
|
|
289
|
+
taken.add(candidate.lower())
|
|
290
|
+
return candidate
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
def save_page(read: dict[str, Any], output_dir: Path, doi: str, request: Any, *,
|
|
294
|
+
clock: Callable[[], float] = time.monotonic) -> dict[str, Any]:
|
|
295
|
+
"""Writes the HTML and fetches the images with ``request`` (the browser session's)."""
|
|
296
|
+
folder = page_dir(output_dir, doi)
|
|
297
|
+
(folder / "images").mkdir(parents=True, exist_ok=True)
|
|
298
|
+
html_file = folder / "article.html"
|
|
299
|
+
html_file.write_text(read["html"], encoding="utf-8")
|
|
300
|
+
saved: list[dict[str, str]] = []
|
|
301
|
+
failed: list[dict[str, str]] = []
|
|
302
|
+
taken: set[str] = set()
|
|
303
|
+
total = 0
|
|
304
|
+
deadline = clock() + TIME_BUDGET_SEC
|
|
305
|
+
for url in read.get("image_urls") or []:
|
|
306
|
+
if clock() > deadline or total >= MAX_BYTES:
|
|
307
|
+
failed.append({"url": url, "reason": "time_limit" if clock() > deadline else "too_large"})
|
|
308
|
+
continue
|
|
309
|
+
try:
|
|
310
|
+
response = request.get(url, timeout=REQUEST_TIMEOUT_MS)
|
|
311
|
+
except Exception as exc:
|
|
312
|
+
# Recorded; PaperSearch reports each figure without a file.
|
|
313
|
+
failed.append({"url": url, "reason": type(exc).__name__})
|
|
314
|
+
continue
|
|
315
|
+
try:
|
|
316
|
+
content_type = str(response.headers.get("content-type") or "")
|
|
317
|
+
if not response.ok:
|
|
318
|
+
failed.append({"url": url, "reason": f"http_{response.status}"})
|
|
319
|
+
continue
|
|
320
|
+
if not content_type.lower().startswith("image/"):
|
|
321
|
+
failed.append({"url": url, "reason": "not_an_image"})
|
|
322
|
+
continue
|
|
323
|
+
body = bytearray()
|
|
324
|
+
for chunk in response.chunks():
|
|
325
|
+
body.extend(chunk)
|
|
326
|
+
if total + len(body) > MAX_BYTES or clock() > deadline:
|
|
327
|
+
break
|
|
328
|
+
else:
|
|
329
|
+
if not body:
|
|
330
|
+
failed.append({"url": url, "reason": "empty"})
|
|
331
|
+
continue
|
|
332
|
+
target = folder / "images" / _image_name(url, content_type, taken)
|
|
333
|
+
target.write_bytes(bytes(body))
|
|
334
|
+
total += len(body)
|
|
335
|
+
saved.append({"url": url, "file": str(target)})
|
|
336
|
+
continue
|
|
337
|
+
failed.append({"url": url, "reason": "time_limit" if clock() > deadline else "too_large"})
|
|
338
|
+
finally:
|
|
339
|
+
response.dispose()
|
|
340
|
+
return {"file": str(html_file), "url": read["url"], "images": saved, "failed_images": failed}
|
|
@@ -16,7 +16,10 @@ misread letters, reading order) does not matter, and the evidence is weighed:
|
|
|
16
16
|
|
|
17
17
|
Strong evidence, or two single pieces, verify the PDF; one single piece verifies
|
|
18
18
|
it while the pages print no other DOI. Other DOIs and no evidence at all:
|
|
19
|
-
another article. A title's numbers must always be exact.
|
|
19
|
+
another article. A title's numbers must always be exact. Nothing after the first
|
|
20
|
+
reference list counts, unless the article begins there: its title on lines of its
|
|
21
|
+
own and its DOI alone on a line soon after (a short piece sharing its first page
|
|
22
|
+
with the end of the one before it, Cell's Previews). An attachment
|
|
20
23
|
(supplementary material, disclosure form) and a notice about the article
|
|
21
24
|
(correction, retraction, briefing, letter to the editor), each known by its own
|
|
22
25
|
heading line, are not the article, unless the notice is itself the requested
|
|
@@ -53,6 +56,7 @@ LETTERS_PER_ERROR = 12 # one misread letter allowed per this many letters
|
|
|
53
56
|
HEAD_CHARS = 400 # where an attachment or a notice announces itself
|
|
54
57
|
SHARED_SUFFIX = 10 # a suffix this long names one article under whichever prefix
|
|
55
58
|
SCAN_MAX_LETTERS = 300 # fewer letters on the pages read: a scan without a text layer
|
|
59
|
+
HEAD_REACH = 1200 # an article's own DOI line after its title: authors, affiliations, correspondence
|
|
56
60
|
|
|
57
61
|
# A reference list cites other articles: its DOIs and titles are not evidence.
|
|
58
62
|
_REFERENCES_HEADING = re.compile(r"^\s*(?:references?|literature cited)\s*$", re.I | re.M)
|
|
@@ -62,6 +66,10 @@ _ATTACHMENT_HEADING = re.compile(
|
|
|
62
66
|
r"(?:information|materials?|data|content|appendix|methods|figures?|figure legends|tables?|text|files?)"
|
|
63
67
|
r"\s*(?:for\b.*|:.*)?$|^\s*appendix(?:\s+[a-z0-9])?\s*:?\s*$|^\s*plain language summary\b|^\s*(?:icmje\s+)?disclosure\s+form"
|
|
64
68
|
r"|^\s*conflicts?\s+of\s+interest\s+(?:form|disclosure)", re.I | re.M)
|
|
69
|
+
# A line that ends mid-sentence: the next line goes on with it and is no heading (a Lancet
|
|
70
|
+
# margin note, "For the Spanish translation of the abstract see Online for" then "appendix 1",
|
|
71
|
+
# 2026-11-19).
|
|
72
|
+
_GOES_ON = re.compile(r"\b(?:see|for|in|of|the|and|or|to|at|on|with|from|by)\s*$", re.I)
|
|
65
73
|
# A notice's own heading line: the word opens the line, alone or followed by ":" or
|
|
66
74
|
# "to" ("CORRECTION", "Correction to: …", "Retraction Note", "RETRACTED ARTICLE: …",
|
|
67
75
|
# "Notice of Retraction"), or closes it after a colon ("<title>: Erratum"); not a
|
|
@@ -83,6 +91,10 @@ _ABOUT_LABEL = re.compile(
|
|
|
83
91
|
_ABOUT_REACH = 200 # how far after its label the DOI of the article a notice is about may be
|
|
84
92
|
# A DOI may break right after its prefix ("https://doi.org/10.1016/" then "S0140-…", The Lancet).
|
|
85
93
|
_DOI_IN_TEXT = re.compile(r"10\.\d{4,9}/(?:[ \t]*\n[ \t]*)?[^\s\"<>]+")
|
|
94
|
+
# DOIs of registrations and deposited data, which name no other article: OSF (a review's protocol,
|
|
95
|
+
# "https://doi.org/10.17605/OSF.IO/J483F", eClinicalMedicine, 2026-11-19), Zenodo, figshare,
|
|
96
|
+
# Dryad, Mendeley Data, Harvard Dataverse.
|
|
97
|
+
_DEPOSIT_PREFIXES = ("10.17605/", "10.5281/", "10.6084/", "10.5061/", "10.17632/", "10.7910/")
|
|
86
98
|
_LETTER = re.compile(r"[a-zЀ-ӿ一-鿿]")
|
|
87
99
|
# The copyright line right after a DOI ("https://doi.org/…" then "1063-4584/© 2025 …"):
|
|
88
100
|
# the item's own footer. Text extraction can put the footer after the reference list
|
|
@@ -155,6 +167,18 @@ def _numbers_match(window: str, title: str) -> bool:
|
|
|
155
167
|
|
|
156
168
|
|
|
157
169
|
def _title_evidence(text: str, chars: str, at: list[int], title: str) -> str | None:
|
|
170
|
+
"""How the title is printed: "strong", "single" or None. A title that opens with a label
|
|
171
|
+
and a colon may be printed without the label: the rest, when long enough to name the
|
|
172
|
+
article alone, is one piece of evidence ("Spiers Memorial Lecture: Mechanistic
|
|
173
|
+
Non-Adiabatic Chemistry: …", an RSC accepted manuscript, 2026-11-19)."""
|
|
174
|
+
found = _printed_title(text, chars, at, title)
|
|
175
|
+
rest = re.split(r"[::]", title, maxsplit=1)[1] if found is None and re.search(r"[::]", title) else ""
|
|
176
|
+
if _weight(_letters(normalize_doi_text(_plain_title(rest)))[0]) >= STRONG_TITLE and _printed_title(text, chars, at, rest):
|
|
177
|
+
return "single"
|
|
178
|
+
return found
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
def _printed_title(text: str, chars: str, at: list[int], title: str) -> str | None:
|
|
158
182
|
plain = normalize_doi_text(_plain_title(title))
|
|
159
183
|
key = _letters(plain)[0]
|
|
160
184
|
if _weight(key) < SHORT_TITLE:
|
|
@@ -212,7 +236,9 @@ def _doi_named(pages: str, target: str) -> bool:
|
|
|
212
236
|
return False
|
|
213
237
|
pattern = lambda value: r"\s*".join(re.escape(char) for char in value) # noqa: E731
|
|
214
238
|
suffix = _suffix(target)
|
|
215
|
-
|
|
239
|
+
# A margin can break a DOI after "10." as well ("https://doi.org/10." / "1016/j.eclinm.2025." /
|
|
240
|
+
# "103705", eClinicalMedicine, 2026-11-19).
|
|
241
|
+
head = r"10\.\s*\d{4,9}/\s*" if len(_bare(suffix)) >= SHARED_SUFFIX else pattern(target[:-len(suffix)]) + r"\s*"
|
|
216
242
|
return re.search(rf"(?<![0-9.]){head}{pattern(suffix)}(?![0-9a-z_/-]|\.[0-9a-z])", pages) is not None
|
|
217
243
|
|
|
218
244
|
|
|
@@ -235,8 +261,10 @@ def _same_article(doi: str, target: str) -> bool:
|
|
|
235
261
|
|
|
236
262
|
|
|
237
263
|
def _other_dois(pages: str, target: str) -> list[str]:
|
|
238
|
-
"""DOIs printed that are not the target, nor a piece, an extension, a misprint or an older prefix of it
|
|
239
|
-
|
|
264
|
+
"""DOIs printed that are not the target, nor a piece, an extension, a misprint or an older prefix of it,
|
|
265
|
+
nor a registration's or data's."""
|
|
266
|
+
return [doi for doi in map(_clean_doi, _DOI_IN_TEXT.finditer(pages))
|
|
267
|
+
if not _same_article(doi, target) and not doi.startswith(_DEPOSIT_PREFIXES)]
|
|
240
268
|
|
|
241
269
|
|
|
242
270
|
def _about_dois(pages: str) -> list[str]:
|
|
@@ -266,12 +294,41 @@ def _not_the_article(head: str, title: str, named: bool) -> bool:
|
|
|
266
294
|
# A supplementary file opens with its heading and names the article after it;
|
|
267
295
|
# an article whose toolbar lists "Supporting Information" below its own title
|
|
268
296
|
# is the article (ACS, 2026-11-02).
|
|
269
|
-
attachment = _ATTACHMENT_HEADING.
|
|
297
|
+
attachment = next((found for found in _ATTACHMENT_HEADING.finditer(head)
|
|
298
|
+
if not _GOES_ON.search(head[:found.start()])), None)
|
|
270
299
|
if attachment and not _title_before(head[:attachment.start()], title):
|
|
271
300
|
return True
|
|
272
301
|
return bool(_NOTICE.search(head)) and not named and not _NOTICE_TITLE.search(_plain_title(title))
|
|
273
302
|
|
|
274
303
|
|
|
304
|
+
def _head_after_references(text: str, target: str, title: str) -> str:
|
|
305
|
+
"""The requested article's own text when it begins after another article's reference
|
|
306
|
+
list on the same pages, from its title to its own reference list; "" when it does not.
|
|
307
|
+
A short piece can share its first page with the end of the one before it, references
|
|
308
|
+
included (Cell's Previews, 2026-11-18). It takes the title standing on its own lines
|
|
309
|
+
and, within HEAD_REACH after it and no other DOI between, the target DOI alone on its
|
|
310
|
+
line: a reference list cites an article on lines it shares with its authors, year
|
|
311
|
+
and journal, and ends its DOI with a full stop."""
|
|
312
|
+
first = _REFERENCES_HEADING.search(text)
|
|
313
|
+
plain = normalize_doi_text(_plain_title(title))
|
|
314
|
+
key = _letters(plain)[0]
|
|
315
|
+
if not first or not re.match(r"10\.\d{4,9}/\S", target) or _weight(key) < SHORT_TITLE:
|
|
316
|
+
return ""
|
|
317
|
+
doi_line = re.compile(rf"^[ \t]*(?:https?://(?:dx\.)?doi\.org/|doi:?[ \t]*)?{re.escape(target)}[ \t]*$", re.M)
|
|
318
|
+
for line in doi_line.finditer(text, first.end()):
|
|
319
|
+
offset = max(first.end(), line.start() - HEAD_REACH)
|
|
320
|
+
chars, at = _letters(text[offset:line.start()])
|
|
321
|
+
found = chars.rfind(key)
|
|
322
|
+
while found >= 0:
|
|
323
|
+
begin, end = offset + at[found], offset + at[found + len(key) - 1] + 1
|
|
324
|
+
if (_numbers_match(text[max(0, begin - 25):end + 26], plain) and _stands_alone(text, begin, end)
|
|
325
|
+
and not _DOI_IN_TEXT.search(text, end, line.start())):
|
|
326
|
+
after = _REFERENCES_HEADING.search(text, line.end())
|
|
327
|
+
return text[begin:after.start() if after else len(text)]
|
|
328
|
+
found = chars.rfind(key, 0, found)
|
|
329
|
+
return ""
|
|
330
|
+
|
|
331
|
+
|
|
275
332
|
def evidence(first_pages: str, identifier: str, title: str = "") -> dict | None:
|
|
276
333
|
"""What the first pages show; None without any text."""
|
|
277
334
|
if not (first_pages or "").strip():
|
|
@@ -279,6 +336,9 @@ def evidence(first_pages: str, identifier: str, title: str = "") -> dict | None:
|
|
|
279
336
|
text = normalize_doi_text(first_pages)
|
|
280
337
|
front = _REFERENCES_HEADING.split(text, maxsplit=1)[0]
|
|
281
338
|
target = _target_doi(identifier)
|
|
339
|
+
# Nothing of the article before the first reference list: it may begin after another's.
|
|
340
|
+
if not _doi_named(front, target) and not ((title or "").strip() and _title_evidence(front, *_letters(front), title)):
|
|
341
|
+
front = _head_after_references(text, target, title or "") or front
|
|
282
342
|
chars, at = _letters(front)
|
|
283
343
|
own_footer = _doi_above_copyright(text, target)
|
|
284
344
|
doi = _doi_named(front, target) or own_footer
|
|
@@ -458,11 +458,12 @@ def _append_oxford_candidates(candidates: list[str], doi: str, source_url: str)
|
|
|
458
458
|
source_path = parsed.path.rstrip("/")
|
|
459
459
|
if parsed.scheme not in {"http", "https"} or not host.endswith("academic.oup.com"):
|
|
460
460
|
return
|
|
461
|
-
|
|
461
|
+
# An advance article's PDF is under advance-article-pdf.
|
|
462
|
+
match = re.match(r"^/(?P<journal>[^/]+)/(?P<kind>advance-article|article)/(?P<rest>.+)$", source_path, flags=re.IGNORECASE)
|
|
462
463
|
if not match:
|
|
463
464
|
return
|
|
464
465
|
suffix = doi.rsplit("/", 1)[-1] if "/" in doi else doi
|
|
465
|
-
pdf_path = f"/{match.group('journal')}/
|
|
466
|
+
pdf_path = f"/{match.group('journal')}/{match.group('kind').lower()}-pdf/{match.group('rest')}/{suffix}.pdf"
|
|
466
467
|
_append_candidate(candidates, urlunparse((parsed.scheme, parsed.netloc, pdf_path, "", "", "")))
|
|
467
468
|
|
|
468
469
|
|
|
@@ -34,22 +34,37 @@ class Request:
|
|
|
34
34
|
return Response(self._session.get(url, stream=True, timeout=(10, timeout / 1000)))
|
|
35
35
|
|
|
36
36
|
|
|
37
|
+
def browser_session(page: Any) -> dict[str, Any]:
|
|
38
|
+
"""What requests outside the browser need of its session, as it is now: the browser's
|
|
39
|
+
user agent and its cookies (for ``session_request``). Kept in memory only."""
|
|
40
|
+
return {"user_agent": page.evaluate("navigator.userAgent"), "cookies": page.context.cookies()}
|
|
41
|
+
|
|
42
|
+
|
|
37
43
|
@contextmanager
|
|
38
|
-
def
|
|
39
|
-
"""
|
|
44
|
+
def session_request(session_state: dict[str, Any], config: dict, *, referer: str, proxy: str | None = None):
|
|
45
|
+
"""Requests with a browser session read before (``browser_session``), without asking the
|
|
46
|
+
browser: also once the watchdog has ended this process's browser calls.
|
|
40
47
|
|
|
41
|
-
|
|
42
|
-
|
|
48
|
+
Cookie domain/path/secure scope and the browser's configured egress are kept. Cookies
|
|
49
|
+
remain in memory. Requests' redirect handling reapplies cookie scope on each host; no
|
|
50
|
+
manually copied Cookie header follows cross-site redirects.
|
|
43
51
|
"""
|
|
44
52
|
with requests.Session() as session:
|
|
45
53
|
session.trust_env = False
|
|
46
54
|
proxy = str(proxy or config.get("browser_static_proxy") or config.get("network_proxy") or "").strip()
|
|
47
55
|
if proxy:
|
|
48
56
|
session.proxies.update(http=proxy, https=proxy)
|
|
49
|
-
session.headers.update({"User-Agent":
|
|
50
|
-
|
|
51
|
-
for cookie in page.context.cookies():
|
|
57
|
+
session.headers.update({"User-Agent": session_state["user_agent"], "Referer": referer})
|
|
58
|
+
for cookie in session_state["cookies"]:
|
|
52
59
|
session.cookies.set(cookie["name"], cookie["value"], domain=cookie["domain"],
|
|
53
60
|
path=cookie.get("path", "/"), secure=bool(cookie.get("secure")),
|
|
54
61
|
expires=int(cookie["expires"]) if cookie.get("expires", -1) > 0 else None)
|
|
55
62
|
yield Request(session)
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
@contextmanager
|
|
66
|
+
def browser_request(page: Any, config: dict, *, proxy: str | None = None, referer: str | None = None):
|
|
67
|
+
"""Requests with the browser's session as it is now (``session_request``)."""
|
|
68
|
+
session_state = browser_session(page)
|
|
69
|
+
with session_request(session_state, config, referer=referer or str(page.url), proxy=proxy) as request:
|
|
70
|
+
yield request
|
|
@@ -27,7 +27,10 @@ from ..browser import watchdog
|
|
|
27
27
|
from ..entitlements import UserMarkedNoEntitlement, UserSkippedArticle, UserStoppedBatch
|
|
28
28
|
|
|
29
29
|
MAX_FILES = 50
|
|
30
|
-
|
|
30
|
+
# No size cap on a file written to disk (user, 2026-11-17: a 310 MB data file is the paper's too,
|
|
31
|
+
# and 2 of ARD's and AR's files were left for it). A file the browser's own PDF viewer holds is
|
|
32
|
+
# read out of its memory: at most this much.
|
|
33
|
+
VIEWER_MAX_BYTES = 1024 * 1024 * 1024
|
|
31
34
|
# No progress for this long ends the collection; active transfers refresh it.
|
|
32
35
|
TIME_BUDGET_SEC = 180
|
|
33
36
|
# Still bounded even when a server trickles bytes forever; below the MCP cap.
|
|
@@ -225,8 +228,6 @@ def collect(request: Any, links: Iterable[SupplementLink], output_dir: Path, doi
|
|
|
225
228
|
length = int(response.headers.get("content-length") or 0)
|
|
226
229
|
if not response.ok:
|
|
227
230
|
entry.update(status="failed", reason=f"http_{response.status}")
|
|
228
|
-
elif length > MAX_FILE_BYTES:
|
|
229
|
-
entry.update(status="skipped", reason="too_large", size=length)
|
|
230
231
|
elif "text/html" in content_type.lower():
|
|
231
232
|
# A login wall or landing page instead of the file: which one, for the record.
|
|
232
233
|
# A firewall's human verification page is told apart (Figshare's AWS WAF,
|
|
@@ -251,16 +252,12 @@ def collect(request: Any, links: Iterable[SupplementLink], output_dir: Path, doi
|
|
|
251
252
|
if not chunk:
|
|
252
253
|
continue
|
|
253
254
|
size += len(chunk)
|
|
254
|
-
if size > MAX_FILE_BYTES:
|
|
255
|
-
break
|
|
256
255
|
fh.write(chunk)
|
|
257
256
|
last_progress = now
|
|
258
257
|
if activity is not None:
|
|
259
258
|
activity()
|
|
260
259
|
_check_interrupted()
|
|
261
|
-
if size
|
|
262
|
-
entry.update(status="skipped", reason="too_large", size=size)
|
|
263
|
-
elif not size or (length and not response.headers.get("content-encoding") and size != length):
|
|
260
|
+
if not size or (length and not response.headers.get("content-encoding") and size != length):
|
|
264
261
|
entry.update(status="failed", reason="incomplete_body", size=size)
|
|
265
262
|
else:
|
|
266
263
|
temporary.replace(path)
|
|
@@ -4,11 +4,14 @@ choosers name it, and its own school-choosing pages.
|
|
|
4
4
|
The federation layer stands beside the publisher layers (engine, platforms,
|
|
5
5
|
publishers, journals; ADR 0014). Publisher rules never name a federation: they
|
|
6
6
|
ask the configured one whether a chooser's entry is it (``Federation.matches``).
|
|
7
|
-
Each federation is one data file in ``
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
Each federation is one data file in ``data/<continent>/`` (asia, europe, americas,
|
|
8
|
+
oceania, africa; global for a service across countries, OpenAthens) (``schema``
|
|
9
|
+
below); one whose own pages need code gets a module of its own here (``carsi.py``,
|
|
10
|
+
CARSI's member list). No school is named here (ADR 0009): the school is the
|
|
11
|
+
user's setting, found and saved by the ``schools`` package (the user, 2026-11-17:
|
|
12
|
+
federations and schools apart).
|
|
10
13
|
|
|
11
|
-
``
|
|
14
|
+
``data/<continent>/<code>.json``:
|
|
12
15
|
|
|
13
16
|
- ``code``: the value of ``publisher_institution_federation`` ("carsi").
|
|
14
17
|
- ``name``: its short name, as users and the records call it.
|
|
@@ -49,7 +52,7 @@ from pathlib import Path
|
|
|
49
52
|
from typing import Any, Iterable
|
|
50
53
|
from urllib.parse import urlparse
|
|
51
54
|
|
|
52
|
-
|
|
55
|
+
_DATA = Path(__file__).with_name("data")
|
|
53
56
|
|
|
54
57
|
|
|
55
58
|
@dataclass(frozen=True)
|
|
@@ -120,7 +123,7 @@ def _load(path: Path) -> Federation:
|
|
|
120
123
|
@lru_cache(maxsize=1)
|
|
121
124
|
def all_federations() -> tuple[Federation, ...]:
|
|
122
125
|
"""Every built-in federation, CARSI first (the default)."""
|
|
123
|
-
found = [_load(path) for path in sorted(
|
|
126
|
+
found = [_load(path) for path in sorted(_DATA.glob("*/*.json"), key=lambda path: path.name)]
|
|
124
127
|
return tuple(sorted(found, key=lambda f: (f.code != "carsi", f.code)))
|
|
125
128
|
|
|
126
129
|
|
|
@@ -57,7 +57,7 @@ def load_school_list(config: dict[str, Any], data_dir: Path) -> list[CarsiSchool
|
|
|
57
57
|
cache = Path(data_dir) / CACHE_FILE
|
|
58
58
|
if cache.exists() and time.time() - cache.stat().st_mtime < CACHE_MAX_AGE_SEC:
|
|
59
59
|
return parse_school_list(cache.read_text(encoding="utf-8"))
|
|
60
|
-
from
|
|
60
|
+
from ..network import fetch
|
|
61
61
|
|
|
62
62
|
response = fetch(SCHOOL_LIST_URL, config)
|
|
63
63
|
response.raise_for_status()
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
"name": "CSTCloud",
|
|
4
4
|
"country": "CN",
|
|
5
5
|
"registration_authorities": ["https://www.cstcloud.net/"],
|
|
6
|
-
"chooser_labels": ["CSTCloud Federation"],
|
|
7
|
-
"chooser_pattern": "\\bCSTCloud\\b
|
|
6
|
+
"chooser_labels": ["CSTCloud Federation", "China (CSTCloudFederation)", "China Science and Technology Network"],
|
|
7
|
+
"chooser_pattern": "\\bCSTCloud(?:\\s*Federation)?\\b|中国科技云|\\bChina\\s+Science\\s+and\\s+Technology\\s+Network\\b",
|
|
8
8
|
"discovery_hosts": [],
|
|
9
9
|
"service_domains": ["cstcloud.net"],
|
|
10
10
|
"metadata_url": "http://www.cstcloud.net/discovery/metadata/cstcloud-fed-metadata-sig.xml"
|