papersearch 0.6.11 → 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 +24 -16
- package/dist/capabilities/download/batch/batch.d.ts.map +1 -0
- package/dist/capabilities/{pdf-discovery → download/batch}/batch.js +416 -286
- 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 +4 -8
- package/dist/capabilities/download/batch/batchSummary.d.ts.map +1 -0
- package/dist/capabilities/{pdf-discovery → download/batch}/batchSummary.js +91 -32
- package/dist/capabilities/download/batch/batchSummary.js.map +1 -0
- package/dist/capabilities/{pdf-discovery → download/batch}/networkLoss.d.ts +1 -1
- package/dist/capabilities/download/batch/networkLoss.d.ts.map +1 -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 +24 -13
- 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 -40
- 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 -43
- 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 +10 -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 +78 -3
- 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 +599 -38
- package/school/paper_search_school/assets/capsule_en.json +309 -7
- 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 +2 -1
- 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 +118 -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 +92 -14
- package/school/paper_search_school/progress_status.py +1 -1
- package/school/paper_search_school/progress_view.py +148 -28
- 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 +19 -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.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/networkLoss.d.ts.map +0 -1
- package/dist/capabilities/pdf-discovery/networkLoss.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 -124
- 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/batch}/networkLoss.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
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
import { resolveDownloadPath } from "
|
|
2
|
-
import { dirname } from "node:path";
|
|
3
|
-
import { createOutputLayout, inPaperDir, isInside, lookupOutputMetadata, moveIntoPaperDir, organizeFiles, removeWorkFolder } from "./outputLayout.js";
|
|
1
|
+
import { resolveDownloadPath } from "../../../config/ConfigService.js";
|
|
4
2
|
import { randomUUID } from "node:crypto";
|
|
5
|
-
import { RunLedger } from "
|
|
6
|
-
import {
|
|
7
|
-
import { createDefaultDownloadTiers, downloadWithFallback, } from "
|
|
8
|
-
import { schoolAttemptDetails, schoolShortReason } from "
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
3
|
+
import { RunLedger } from "../../../infrastructure/runlog/RunLedger.js";
|
|
4
|
+
import { FAILURE_CLASS_NAMES, } from "../../../infrastructure/runlog/failureClass.js";
|
|
5
|
+
import { createDefaultDownloadTiers, downloadWithFallback, } from "../content/pdf/OpenAccessFallbackService.js";
|
|
6
|
+
import { schoolAttemptDetails, schoolShortReason } from "../../../infrastructure/school/index.js";
|
|
7
|
+
import { downloadSupplementsOnly, filesPastNetworkLoss } from "../content/supplements/fetch.js";
|
|
8
|
+
import { supplementShortfall } from "../content/supplements/shortfall.js";
|
|
9
|
+
import { fulltextPageVisit } from "../content/markdown/pageVisit.js";
|
|
10
|
+
import { fulltextAlone, fulltextForItem, markdownBeside, markdownPastNetworkLoss } from "../content/markdown/step.js";
|
|
11
|
+
import { markdownDoubt, markdownMissing } from "../content/markdown/shortfall.js";
|
|
12
|
+
import { batchPaper, failure, reportBatchResults, stoppedItem } from "./batchSummary.js";
|
|
13
|
+
import { loadMarkdownPro, markdownBlocked } from "../content/markdown/pro.js";
|
|
11
14
|
import { PaperList } from "./batchPapers.js";
|
|
12
15
|
import { networkReachable, pastNetworkLoss } from "./networkLoss.js";
|
|
13
|
-
|
|
16
|
+
import { openBatchFolder } from "./batchFolder.js";
|
|
14
17
|
/** From this many items the progress window opens at the start, in the open-access stretch. */
|
|
15
18
|
export const OPEN_PROGRESS_MIN_ITEMS = 5;
|
|
16
19
|
/** Every source that needs no browser: open access, publisher APIs, Sci-Hub when on (the guide's 开放下载). */
|
|
@@ -62,106 +65,11 @@ function itemOptions(item, options) {
|
|
|
62
65
|
useEntitledAccess: options.useEntitledAccess,
|
|
63
66
|
useSciHub: options.useSciHub,
|
|
64
67
|
...(options.content && options.content !== "main" ? { content: options.content } : {}),
|
|
68
|
+
...(options.fulltext ? { fulltext: true } : {}),
|
|
69
|
+
...(options.fulltext && options.mode === "entitled_only" ? { fulltextPageOnly: true } : {}),
|
|
70
|
+
...(options.school?.trim() ? { school: options.school.trim() } : {}),
|
|
65
71
|
};
|
|
66
72
|
}
|
|
67
|
-
/**
|
|
68
|
-
* Supplementary files only: the entitled-access backend visits the article
|
|
69
|
-
* page for them. An empty completed check is also ok; it is not a failed download,
|
|
70
|
-
* nor is a site without a supplementary-file rule (user, 2026-11-11). Reported to
|
|
71
|
-
* the run ledger through ``request.onStage`` as the "supplements" stage.
|
|
72
|
-
* ``mainPath``: the paper's main text, saved before; once a file is saved it moves
|
|
73
|
-
* into the paper's folder beside them (the returned ``path``).
|
|
74
|
-
*/
|
|
75
|
-
export async function downloadSupplementsOnly(request, backend, searchers, mainPath) {
|
|
76
|
-
request = { ...request, savePath: resolveDownloadPath(request.savePath) };
|
|
77
|
-
const startedAt = Date.now();
|
|
78
|
-
const metadata = searchers ? await lookupOutputMetadata(searchers, request.doi ? "crossref" : request.source, request.doi || request.paperId) : {};
|
|
79
|
-
let layout = createOutputLayout(request.savePath, request.doi || request.paperId, { ...metadata, title: request.title || metadata.title }, false, { diagnosticsDir: request.diagnosticsDir });
|
|
80
|
-
// A main text already in a folder of its own (an earlier download): its files go beside it.
|
|
81
|
-
const mainDir = mainPath ? dirname(mainPath) : "";
|
|
82
|
-
if (mainDir && isInside(mainDir, request.savePath))
|
|
83
|
-
layout = inPaperDir(layout, mainDir);
|
|
84
|
-
let trace;
|
|
85
|
-
const files = await fetchSupplementsOnly(backend, {
|
|
86
|
-
identifier: request.doi || request.paperId,
|
|
87
|
-
outputDir: layout.paperDir,
|
|
88
|
-
diagnosticsDir: layout.workDiagnosticsDir,
|
|
89
|
-
...(request.batch ? { batch: request.batch } : {}),
|
|
90
|
-
...(request.shortUserWait ? { userWait: "short" } : {}),
|
|
91
|
-
}, value => { trace = value; });
|
|
92
|
-
const saved = files?.filter((f) => f.status === "saved").length ?? 0;
|
|
93
|
-
const noneListed = files?.length === 0;
|
|
94
|
-
// No rule for the site's supplementary files: not known whether there are any, and no fault to diagnose.
|
|
95
|
-
const unsupported = !!files?.length && files.every((file) => file.reason === "supplements_not_supported");
|
|
96
|
-
let filingFailed = false;
|
|
97
|
-
let movedMain;
|
|
98
|
-
try {
|
|
99
|
-
const status = files?.every((file) => file.status === "saved") || unsupported ? "ok" : "error";
|
|
100
|
-
if (files)
|
|
101
|
-
organizeFiles({ supplements: files, trace, status }, layout, layout.paperDir, undefined, request.recordsDir);
|
|
102
|
-
if (saved && mainPath) {
|
|
103
|
-
const moved = moveIntoPaperDir(mainPath, layout);
|
|
104
|
-
if (moved !== mainPath)
|
|
105
|
-
movedMain = moved;
|
|
106
|
-
}
|
|
107
|
-
removeWorkFolder(layout);
|
|
108
|
-
}
|
|
109
|
-
catch {
|
|
110
|
-
filingFailed = true;
|
|
111
|
-
} // Preserve saved files and report filing separately below.
|
|
112
|
-
const attempt = files === undefined
|
|
113
|
-
? { stage: "supplements", status: "skipped", message: "No entitled-access backend for supplementary files." }
|
|
114
|
-
: noneListed
|
|
115
|
-
? { stage: "supplements", status: "skipped", code: "no_supplements",
|
|
116
|
-
message: "Article page checked; no supplementary files were listed." }
|
|
117
|
-
: unsupported
|
|
118
|
-
? { stage: "supplements", status: "skipped", code: "supplements_not_supported",
|
|
119
|
-
message: "No supplementary-file rule for this site yet; get them from the article page by hand." }
|
|
120
|
-
: {
|
|
121
|
-
stage: "supplements",
|
|
122
|
-
status: saved ? "ok" : "error",
|
|
123
|
-
message: `${saved}/${files.length} supplementary files saved.`,
|
|
124
|
-
...(saved ? {} : { code: "supplements_failed" }),
|
|
125
|
-
};
|
|
126
|
-
request.onStage?.({ ...attempt, ...(trace ? { trace } : {}), startedAt: new Date(startedAt).toISOString(), durationMs: Date.now() - startedAt });
|
|
127
|
-
const title = request.title || metadata.title;
|
|
128
|
-
return {
|
|
129
|
-
status: saved || noneListed || unsupported ? "ok" : "error",
|
|
130
|
-
...(movedMain ? { path: movedMain } : {}),
|
|
131
|
-
...(title ? { title } : {}),
|
|
132
|
-
...(metadata.journal ? { journal: metadata.journal } : {}),
|
|
133
|
-
attempts: [attempt, ...(filingFailed ? [{ stage: "output_layout", status: "error",
|
|
134
|
-
code: "output_layout_failed", message: "File organization failed; use the returned file paths." }] : [])],
|
|
135
|
-
...(files ? { supplements: files } : {}),
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
/** content "both": supplementary files for an item whose main text came from an open stage. */
|
|
139
|
-
async function supplementsForOpenItem(result, request, backend, searchers) {
|
|
140
|
-
if (request.content !== "both" || result.status !== "ok" || result.supplements)
|
|
141
|
-
return;
|
|
142
|
-
const extra = await downloadSupplementsOnly({ ...request, ...(result.publishedDoi ? { doi: result.publishedDoi } : {}) }, backend, searchers, result.path && !result.version ? result.path : undefined);
|
|
143
|
-
if (extra.supplements)
|
|
144
|
-
result.supplements = extra.supplements;
|
|
145
|
-
if (extra.path)
|
|
146
|
-
result.path = extra.path; // moved into its folder beside the files
|
|
147
|
-
return extra;
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* supplementsForOpenItem, asked again after a network loss: the files the lost network
|
|
151
|
-
* failed are fetched anew once it is back (those a first visit found stand otherwise).
|
|
152
|
-
*/
|
|
153
|
-
async function filesPastNetworkLoss(result, request, backend, searchers, watch) {
|
|
154
|
-
let extra;
|
|
155
|
-
let again = false;
|
|
156
|
-
await pastNetworkLoss(async () => {
|
|
157
|
-
if (again)
|
|
158
|
-
delete result.supplements;
|
|
159
|
-
again = true;
|
|
160
|
-
extra = await supplementsForOpenItem(result, request, backend, searchers);
|
|
161
|
-
return extra ?? { status: "ok", attempts: [] };
|
|
162
|
-
}, watch);
|
|
163
|
-
return extra;
|
|
164
|
-
}
|
|
165
73
|
/**
|
|
166
74
|
* A school login that lapsed, and nothing else: the paper's wait ran out (login_timeout) on
|
|
167
75
|
* the school's own sign-in page, a password box or the school's sign-in step, as the backend
|
|
@@ -187,14 +95,15 @@ function waitedOutOnUser(result) {
|
|
|
187
95
|
(attempt.code === "login_timeout" || attempt.code === "download_timeout")));
|
|
188
96
|
}
|
|
189
97
|
/**
|
|
190
|
-
*
|
|
191
|
-
* limit was reached before it opened (dependencies section 6, state L).
|
|
98
|
+
* The seconds the backend asked this article to wait, and whose limit it is: the publisher's
|
|
99
|
+
* hourly limit was reached before it opened (dependencies section 6, state L).
|
|
192
100
|
*/
|
|
193
101
|
function rateLimitWait(result) {
|
|
194
102
|
if (result.status === "ok")
|
|
195
|
-
return
|
|
103
|
+
return undefined;
|
|
196
104
|
const attempt = result.attempts.find((a) => a.stage === "entitled_access" && a.code === "rate_limited");
|
|
197
|
-
return attempt ? Math.max(1, Math.min(3600, attempt.retryAfterSec ?? 60))
|
|
105
|
+
return attempt ? { wait: Math.max(1, Math.min(3600, attempt.retryAfterSec ?? 60)),
|
|
106
|
+
...(attempt.hourlyPublisher ? { publisher: attempt.hourlyPublisher } : {}) } : undefined;
|
|
198
107
|
}
|
|
199
108
|
/**
|
|
200
109
|
* How often a batch waiting for the hourly limit keeps the publisher's session alive:
|
|
@@ -202,26 +111,73 @@ function rateLimitWait(result) {
|
|
|
202
111
|
* and the school's login had expired by then too (Windows, 2026-11-12).
|
|
203
112
|
*/
|
|
204
113
|
export const KEEP_SESSION_EVERY_MS = 10 * 60_000;
|
|
114
|
+
/**
|
|
115
|
+
* How often a batch waiting for the hourly limit asks the backend how long it still waits: with
|
|
116
|
+
* the settings window's 马上生效 on, a limit raised there, or none, goes on at once (the user,
|
|
117
|
+
* 2026-11-19). Each ask reads the backend's settings and count only.
|
|
118
|
+
*/
|
|
119
|
+
export const HOURLY_RECHECK_EVERY_MS = 10_000;
|
|
205
120
|
/**
|
|
206
121
|
* Runs the item again after each wait the publisher's hourly limit asks for. During a
|
|
207
|
-
* wait,
|
|
122
|
+
* wait, the backend's keepSession runs every KEEP_SESSION_EVERY_MS.
|
|
208
123
|
*/
|
|
209
|
-
async function pastHourlyLimit(run, log, pause,
|
|
124
|
+
async function pastHourlyLimit(run, log, pause, backend) {
|
|
210
125
|
let result = await run();
|
|
211
|
-
for (let
|
|
212
|
-
|
|
213
|
-
log(`[批量] 这家出版社一小时内的下载已到上限(防止学校被暂停访问),${resume} 继续这一篇`);
|
|
214
|
-
for (let left = wait * 1000; left > 0;) {
|
|
215
|
-
const step = Math.min(left, KEEP_SESSION_EVERY_MS);
|
|
216
|
-
await pause(step);
|
|
217
|
-
left -= step;
|
|
218
|
-
if (left > 0 && keep)
|
|
219
|
-
await keep().catch(() => false);
|
|
220
|
-
}
|
|
126
|
+
for (let held = rateLimitWait(result); held; held = rateLimitWait(result)) {
|
|
127
|
+
await waitOutHour(held.wait, log, pause, backend, held.publisher);
|
|
221
128
|
result = await run();
|
|
222
129
|
}
|
|
223
130
|
return result;
|
|
224
131
|
}
|
|
132
|
+
/**
|
|
133
|
+
* The wait the publisher's hourly limit asks for, said once, the session kept alive meanwhile.
|
|
134
|
+
* A backend that can say how long ``publisher`` still waits is asked every
|
|
135
|
+
* HOURLY_RECHECK_EVERY_MS: the wait ends as soon as the limit the user set allows the article.
|
|
136
|
+
*/
|
|
137
|
+
async function waitOutHour(wait, log, pause, backend, publisher) {
|
|
138
|
+
const resume = new Date(Date.now() + wait * 1000).toTimeString().slice(0, 5);
|
|
139
|
+
log(`[批量] 这家出版社一小时内的下载已到上限(防止学校被暂停访问),${resume} 继续这一篇`);
|
|
140
|
+
const recheck = publisher && backend?.hourlyWait ? () => backend.hourlyWait(publisher) : undefined;
|
|
141
|
+
let sinceKeep = 0;
|
|
142
|
+
for (let left = wait * 1000; left > 0;) {
|
|
143
|
+
const step = Math.min(left, KEEP_SESSION_EVERY_MS - sinceKeep, recheck ? HOURLY_RECHECK_EVERY_MS : Infinity);
|
|
144
|
+
await pause(step);
|
|
145
|
+
left -= step;
|
|
146
|
+
sinceKeep += step;
|
|
147
|
+
if (left <= 0)
|
|
148
|
+
break;
|
|
149
|
+
const now = recheck ? await recheck().catch(() => undefined) : undefined;
|
|
150
|
+
if (now?.waitSec === 0) {
|
|
151
|
+
log(`[批量] 按现在的每小时上限(${now.limit > 0 ? `${now.limit} 篇` : "不限"})可以接着下这一篇`);
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
if (now)
|
|
155
|
+
left = now.waitSec * 1000;
|
|
156
|
+
if (sinceKeep >= KEEP_SESSION_EVERY_MS) {
|
|
157
|
+
sinceKeep = 0;
|
|
158
|
+
await backend?.keepSession?.().catch(() => false);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* A batch's visit for an article page alone (its Markdown), waiting out the publisher's
|
|
164
|
+
* hourly limit as a download does: the page reads count toward it, and with no PDF in the
|
|
165
|
+
* Markdown's place there is no download to wait in (user, 2026-11-16).
|
|
166
|
+
*/
|
|
167
|
+
function pageVisit(backend, request, log, pause, seen) {
|
|
168
|
+
const visit = fulltextPageVisit(backend, request);
|
|
169
|
+
if (!visit)
|
|
170
|
+
return undefined;
|
|
171
|
+
return async (doi, outputDir, diagnosticsDir) => {
|
|
172
|
+
let outcome = await visit(doi, outputDir, diagnosticsDir);
|
|
173
|
+
while (outcome?.code === "rate_limited") {
|
|
174
|
+
await waitOutHour(Math.max(1, Math.min(3600, outcome.retryAfterSec ?? 60)), log, pause, backend, outcome.hourlyPublisher);
|
|
175
|
+
outcome = await visit(doi, outputDir, diagnosticsDir);
|
|
176
|
+
}
|
|
177
|
+
seen?.(outcome?.trace);
|
|
178
|
+
return outcome;
|
|
179
|
+
};
|
|
180
|
+
}
|
|
225
181
|
/** The journal's site blocked the current network (state L): a protection page,
|
|
226
182
|
* or the school paused for downloading too much. The backend answers the
|
|
227
183
|
* journal's later items at once; every other item goes on (the user, 2026-11-02). */
|
|
@@ -233,7 +189,7 @@ function stoppedByUser(result) {
|
|
|
233
189
|
const STOP_NOTICE = "[批量] 已在进度窗口终止任务,剩下的篇目不再下载";
|
|
234
190
|
/** The user pressed 终止 in the batch's window (papers not reached, or still paused, show it). */
|
|
235
191
|
export function batchStopped(result) {
|
|
236
|
-
return result.items.some((item) => stoppedByUser(item) || item.attempts.some((attempt) => attempt.code === "login_paused"));
|
|
192
|
+
return !!result.stopped || result.items.some((item) => stoppedByUser(item) || item.attempts.some((attempt) => attempt.code === "login_paused"));
|
|
237
193
|
}
|
|
238
194
|
/** The attempt recorded for an item the batch did not reach because the user stopped it. */
|
|
239
195
|
function notReached() {
|
|
@@ -256,6 +212,15 @@ function runItem(index, request) {
|
|
|
256
212
|
...(request.title ? { title: request.title } : {}),
|
|
257
213
|
};
|
|
258
214
|
}
|
|
215
|
+
/**
|
|
216
|
+
* A failed paper's class and reason, as the failed list names them (batchSummary.failure);
|
|
217
|
+
* undefined for a saved paper or one the stop left undone. Every failed paper is in a class: a
|
|
218
|
+
* batch of the Markdown alone counted only those whose step ended in an error, "失败 6" beside
|
|
219
|
+
* classes of 1 (AHA, 2026-11-17).
|
|
220
|
+
*/
|
|
221
|
+
function failedAs(item, content) {
|
|
222
|
+
return item.status === "ok" || stoppedItem(item) ? undefined : failure(item, content ?? "main");
|
|
223
|
+
}
|
|
259
224
|
/** Request options that report each stage of ``item`` to the ledger. */
|
|
260
225
|
function recorded(request, ledger, item) {
|
|
261
226
|
return ledger
|
|
@@ -270,10 +235,13 @@ function openLedger(mode, batchId, options, log) {
|
|
|
270
235
|
total: options.items.length,
|
|
271
236
|
...(options.savePath ? { savePath: options.savePath } : {}),
|
|
272
237
|
content: options.content ?? "main",
|
|
238
|
+
...(options.fulltext ? { fulltext: true } : {}),
|
|
239
|
+
...(options.school?.trim() ? { school: options.school.trim() } : {}),
|
|
273
240
|
...(options.resumeOf ? { resumeOf: options.resumeOf } : {}),
|
|
274
241
|
});
|
|
275
242
|
if (ledger)
|
|
276
243
|
log(`[批量] 运行记录:${ledger.dir}`);
|
|
244
|
+
options.folderRecord?.attach(ledger);
|
|
277
245
|
return ledger;
|
|
278
246
|
}
|
|
279
247
|
function itemResult(result, index, options) {
|
|
@@ -290,11 +258,9 @@ function summary(mode, batchId, items, extra = {}) {
|
|
|
290
258
|
const stopped = items.filter(stoppedItem).length;
|
|
291
259
|
const failureClasses = {};
|
|
292
260
|
for (const item of items) {
|
|
293
|
-
const
|
|
294
|
-
if (
|
|
295
|
-
|
|
296
|
-
const failureClass = classifyFailureCode(entitled.code);
|
|
297
|
-
failureClasses[failureClass] = (failureClasses[failureClass] ?? 0) + 1;
|
|
261
|
+
const failed = failedAs(item, extra.content);
|
|
262
|
+
if (failed)
|
|
263
|
+
failureClasses[failed.cls] = (failureClasses[failed.cls] ?? 0) + 1;
|
|
298
264
|
}
|
|
299
265
|
return {
|
|
300
266
|
status: failed === 0 ? "ok" : succeeded === 0 ? "error" : "partial",
|
|
@@ -313,10 +279,41 @@ function summary(mode, batchId, items, extra = {}) {
|
|
|
313
279
|
/** Download a list serially; one batch id ties it to one progress window. */
|
|
314
280
|
export async function downloadBatch(searchers, options, backend, log = (line) => process.stderr.write(`${line}\n`), createTiers = createDefaultDownloadTiers, pause = wait, online = networkReachable) {
|
|
315
281
|
options = { ...options, savePath: resolveDownloadPath(options.savePath) };
|
|
282
|
+
// The batch's own folder keeps its records beside its papers (user, 2026-11-17).
|
|
283
|
+
const { folderRecord: _given, ...asked } = options;
|
|
284
|
+
const folderRecord = openBatchFolder(options.savePath, asked);
|
|
285
|
+
if (folderRecord) {
|
|
286
|
+
const out = log;
|
|
287
|
+
log = (line) => {
|
|
288
|
+
out(line);
|
|
289
|
+
folderRecord.log(line);
|
|
290
|
+
};
|
|
291
|
+
options = { ...options, folderRecord };
|
|
292
|
+
}
|
|
316
293
|
const startedAt = Date.now();
|
|
294
|
+
// The Markdown is PaperSearch Pro's (content/markdown/pro.ts): without it, or while it cannot
|
|
295
|
+
// be used, the batch says so once and its papers' Markdown says why.
|
|
296
|
+
const wantsMarkdown = !!options.fulltext || options.content === "markdown";
|
|
297
|
+
const pro = wantsMarkdown ? await loadMarkdownPro() : undefined;
|
|
298
|
+
const blocked = wantsMarkdown ? markdownBlocked(pro) : undefined;
|
|
299
|
+
if (blocked)
|
|
300
|
+
log(`[批量] ${blocked.code === "markdown_pro_required" ? "Markdown 全文是 PaperSearch Pro 的功能,本机没有安装 Pro(设置窗口的“Markdown 全文”页点“安装”,或运行 paper-search pro install)" : `PaperSearch Pro 暂不可用:${blocked.message}`};PDF 和补充材料照常下载`);
|
|
301
|
+
// Each batch tries the sites not yet supported afresh (three failures in a row give one up).
|
|
302
|
+
if (pro && !blocked)
|
|
303
|
+
pro.batchStarted();
|
|
304
|
+
// Their first papers go first, so how they convert shows early (landingScan.ts, user 2026-11-16).
|
|
305
|
+
if (pro && !blocked && backend && options.items.length > pro.triedFirstCount) {
|
|
306
|
+
const dois = options.items.flatMap((item) => (item.doi ? [item.doi] : []));
|
|
307
|
+
const { items, sites } = pro.triedFirst(options.items, await pro.landingHosts(dois));
|
|
308
|
+
if (sites.length) {
|
|
309
|
+
options = { ...options, items };
|
|
310
|
+
log(`[批量] 预查:${sites.map((site) => `${site.host} ${site.papers} 篇`).join("、")},这些网站没有登记 Markdown 规则,`
|
|
311
|
+
+ `各先试前 ${pro.triedFirstCount} 篇(先用出版社的规则);转换完整才保存,前 ${pro.triedFirstCount} 篇都不完整的本批不再尝试`);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
317
314
|
const run = async (backend) => {
|
|
318
|
-
const result = await (options.content === "supplements"
|
|
319
|
-
?
|
|
315
|
+
const result = await (options.content === "supplements" || options.content === "markdown"
|
|
316
|
+
? downloadSerialBatch(options, backend, log, searchers, createTiers, pause, online)
|
|
320
317
|
: options.mode === "per_item"
|
|
321
318
|
? downloadPerItem(searchers, options, backend, log, createTiers, pause, online)
|
|
322
319
|
: downloadTwoPhase(searchers, options, backend, log, createTiers, options.mode === "entitled_only" ? "entitled_only" : "two_phase", pause, online));
|
|
@@ -324,8 +321,23 @@ export async function downloadBatch(searchers, options, backend, log = (line) =>
|
|
|
324
321
|
return result;
|
|
325
322
|
};
|
|
326
323
|
const result = await (backend?.withBatchSession ? backend.withBatchSession(run) : run(backend));
|
|
324
|
+
// Each class with its reasons: "原因不明 1(PDF 身份未确认 1)", not a class alone beside the
|
|
325
|
+
// list's reason (Windows, 2026-11-17).
|
|
326
|
+
const reasons = new Map();
|
|
327
|
+
for (const item of result.items) {
|
|
328
|
+
const failed = failedAs(item, result.content);
|
|
329
|
+
if (!failed)
|
|
330
|
+
continue;
|
|
331
|
+
const byReason = reasons.get(failed.cls) ?? new Map();
|
|
332
|
+
byReason.set(failed.reason, (byReason.get(failed.reason) ?? 0) + 1);
|
|
333
|
+
reasons.set(failed.cls, byReason);
|
|
334
|
+
}
|
|
327
335
|
const byClass = Object.entries(result.failureClasses ?? {})
|
|
328
|
-
.map(([failureClass, count]) =>
|
|
336
|
+
.map(([failureClass, count]) => {
|
|
337
|
+
const said = [...(reasons.get(failureClass) ?? [])].sort((a, b) => b[1] - a[1]);
|
|
338
|
+
const listed = said.slice(0, 3).map(([reason, n]) => `${reason} ${n}`).join("、") + (said.length > 3 ? " 等" : "");
|
|
339
|
+
return `${FAILURE_CLASS_NAMES[failureClass]} ${count}` + (listed ? `(${listed})` : "");
|
|
340
|
+
})
|
|
329
341
|
.join("、");
|
|
330
342
|
// Main text and supplementary files apart: "附录未下全 2 篇:网站人机验证拦截 2".
|
|
331
343
|
const shortfalls = new Map();
|
|
@@ -337,36 +349,88 @@ export async function downloadBatch(searchers, options, backend, log = (line) =>
|
|
|
337
349
|
shortfalls.set(reason, (shortfalls.get(reason) ?? 0) + 1);
|
|
338
350
|
}
|
|
339
351
|
const missed = [...shortfalls.values()].reduce((sum, n) => sum + n, 0);
|
|
352
|
+
// The Markdown not saved, by reason: beside the PDF or the files, for a paper saved without
|
|
353
|
+
// it (432 such went unsaid at the end of an ARD batch, user 2026-11-16); in a batch of the
|
|
354
|
+
// Markdown alone, for each paper it failed.
|
|
355
|
+
const noMarkdown = new Map();
|
|
356
|
+
for (const item of result.items) {
|
|
357
|
+
if (!item.markdown || item.markdown.status === "ok" || stoppedItem(item))
|
|
358
|
+
continue;
|
|
359
|
+
if (result.content !== "markdown" && item.status !== "ok")
|
|
360
|
+
continue;
|
|
361
|
+
const { reason } = markdownMissing(item.markdown);
|
|
362
|
+
const site = item.markdown.unverified ? `(${item.markdown.unverified.host})` : "";
|
|
363
|
+
noMarkdown.set(reason + site, (noMarkdown.get(reason + site) ?? 0) + 1);
|
|
364
|
+
}
|
|
365
|
+
const incomplete = [...noMarkdown.values()].reduce((sum, n) => sum + n, 0);
|
|
366
|
+
// Saved, its checks finding something short (a registered site's page, user 2026-11-17).
|
|
367
|
+
const doubts = new Map();
|
|
368
|
+
for (const item of result.items) {
|
|
369
|
+
const doubt = item.status === "ok" ? markdownDoubt(item.markdown) : undefined;
|
|
370
|
+
if (doubt)
|
|
371
|
+
doubts.set(doubt.reason, (doubts.get(doubt.reason) ?? 0) + 1);
|
|
372
|
+
}
|
|
373
|
+
const doubtful = [...doubts.values()].reduce((sum, n) => sum + n, 0);
|
|
340
374
|
// Papers the stop left undone are told apart, not counted as failed (user, 2026-11-16).
|
|
341
375
|
const stopped = result.stoppedItems ?? 0;
|
|
342
376
|
log(`[批量] 完成:成功 ${result.succeeded},失败 ${result.failed - stopped}` + (stopped ? `,已终止 ${stopped}` : "")
|
|
343
377
|
+ `,共 ${result.total} 篇` +
|
|
344
378
|
(byClass ? `。失败分类:${byClass};详情:paper-search failures --format text` : "") +
|
|
345
|
-
(missed ? `。附录未下全 ${missed} 篇:${[...shortfalls].map(([reason, n]) => `${reason} ${n}`).join("、")}` : "")
|
|
379
|
+
(missed ? `。附录未下全 ${missed} 篇:${[...shortfalls].map(([reason, n]) => `${reason} ${n}`).join("、")}` : "") +
|
|
380
|
+
(incomplete ? `。Markdown 未生成 ${incomplete} 篇:${[...noMarkdown].map(([reason, n]) => `${reason} ${n}`).join("、")}` : "") +
|
|
381
|
+
(doubtful ? `。Markdown 可能不全 ${doubtful} 篇(已保存,请核对):${[...doubts].map(([reason, n]) => `${reason} ${n}`).join("、")}` : ""));
|
|
346
382
|
// What is left goes on later with one word (user, 2026-11-15).
|
|
347
|
-
if ((result.failed || missed) && result.runLog) {
|
|
383
|
+
if ((result.failed || missed || incomplete) && result.runLog) {
|
|
348
384
|
log("[批量] 没下全的篇目:回来后对 AI 说“接着下”即可补(download_batch 的 resume: \"latest\",同一套环境变量)");
|
|
349
385
|
}
|
|
386
|
+
folderRecord?.refresh();
|
|
350
387
|
return result;
|
|
351
388
|
}
|
|
352
|
-
/**
|
|
353
|
-
|
|
389
|
+
/**
|
|
390
|
+
* content "supplements" or "markdown": every item, one after another, without the main
|
|
391
|
+
* text's stages: its supplementary files, its Markdown (the full-text package, no PDF in
|
|
392
|
+
* its place: user, 2026-11-16), or both (user, 2026-11-14).
|
|
393
|
+
*/
|
|
394
|
+
async function downloadSerialBatch(options, backend, log, searchers, createTiers, pause, online) {
|
|
395
|
+
const content = options.content === "markdown" ? "markdown" : "supplements";
|
|
354
396
|
const batchId = randomUUID();
|
|
355
397
|
const total = options.items.length;
|
|
356
|
-
const ledger = openLedger(
|
|
398
|
+
const ledger = openLedger(content, batchId, options, log);
|
|
399
|
+
const watch = { log, pause, online };
|
|
357
400
|
// The window's lists (成功, 失败, 剩余 open on a click), as the other batches send them: a
|
|
358
|
-
// batch of the files alone sent none (Windows, 2026-11-15).
|
|
359
|
-
const papers = new PaperList(backend, batchId, options.savePath, options.items.map((item) => batchPaper(itemOptions(item, options), undefined, "open",
|
|
401
|
+
// batch of the Markdown or the files alone sent none (Windows, 2026-11-15).
|
|
402
|
+
const papers = new PaperList(backend, batchId, options.savePath, options.items.map((item) => batchPaper(itemOptions(item, options), undefined, "open", content, item.mainPath)));
|
|
360
403
|
await papers.send();
|
|
361
404
|
const items = [];
|
|
362
405
|
let succeeded = 0;
|
|
363
406
|
let failed = 0;
|
|
407
|
+
let away = false;
|
|
364
408
|
for (const [offset, item] of options.items.entries()) {
|
|
365
409
|
const batch = { id: batchId, index: offset + 1, total, done: offset, succeeded, failed };
|
|
366
|
-
const request = { ...itemOptions(item, options), batch };
|
|
410
|
+
const request = { ...itemOptions(item, options), batch, ...(away ? { shortUserWait: true } : {}) };
|
|
367
411
|
const entry = runItem(offset + 1, request);
|
|
368
|
-
log(`[批量] 补充材料 ${offset + 1}/${total}:${request.doi || request.paperId}`);
|
|
369
|
-
|
|
412
|
+
log(`[批量] ${content === "markdown" ? "Markdown" : options.fulltext ? "补充材料和 Markdown" : "补充材料"} ${offset + 1}/${total}:${request.doi || request.paperId}`);
|
|
413
|
+
// 接着下 (resume.ts): a paper whose PDF a batch saved before gets its Markdown beside it, not the PDF again.
|
|
414
|
+
// Done again after a network loss, from what was there before it (``before`` copied each time).
|
|
415
|
+
const markdown = (before) => pastNetworkLoss(() => {
|
|
416
|
+
const from = { ...before, attempts: [...before.attempts] };
|
|
417
|
+
return item.mainPath
|
|
418
|
+
? markdownBeside(from, item.mainPath, recorded(request, ledger, entry), searchers, pageVisit(backend, request, log, pause))
|
|
419
|
+
: fulltextAlone(from, recorded(request, ledger, entry), searchers, pageVisit(backend, request, log, pause));
|
|
420
|
+
}, watch);
|
|
421
|
+
let result;
|
|
422
|
+
if (content === "markdown") {
|
|
423
|
+
result = await markdown({ status: "error", attempts: [] });
|
|
424
|
+
}
|
|
425
|
+
else {
|
|
426
|
+
result = await pastNetworkLoss(() => downloadSupplementsOnly(recorded(request, ledger, entry), backend, searchers, item.mainPath), watch);
|
|
427
|
+
if (options.fulltext && !stoppedByUser(result))
|
|
428
|
+
result = await markdown(result);
|
|
429
|
+
}
|
|
430
|
+
if (!away && waitedOutOnUser(result)) {
|
|
431
|
+
away = true;
|
|
432
|
+
log(AWAY_NOTICE);
|
|
433
|
+
}
|
|
370
434
|
await reportBatchItem(request, result, backend);
|
|
371
435
|
if (result.status === "ok")
|
|
372
436
|
succeeded += 1;
|
|
@@ -374,17 +438,17 @@ async function downloadSupplementsBatch(options, backend, log, searchers, watch)
|
|
|
374
438
|
failed += 1;
|
|
375
439
|
ledger?.item(entry, result);
|
|
376
440
|
items.push(itemResult(result, offset + 1, request));
|
|
377
|
-
papers.set(offset, batchPaper(request, items[items.length - 1], undefined,
|
|
441
|
+
papers.set(offset, batchPaper(request, items[items.length - 1], undefined, content, item.mainPath));
|
|
378
442
|
if (stoppedByUser(result)) {
|
|
379
443
|
for (const [rest, item] of options.items.entries()) {
|
|
380
444
|
if (rest <= offset)
|
|
381
445
|
continue;
|
|
382
446
|
const request = itemOptions(item, options);
|
|
383
447
|
const skipped = itemResult({ status: "error", attempts: [notReached()],
|
|
384
|
-
supplements: [{ status: "skipped", label: "", reason: "batch_stopped" }] }, rest + 1, request);
|
|
448
|
+
...(content === "supplements" ? { supplements: [{ status: "skipped", label: "", reason: "batch_stopped" }] } : {}) }, rest + 1, request);
|
|
385
449
|
items.push(skipped);
|
|
386
450
|
ledger?.item(runItem(rest + 1, request), skipped);
|
|
387
|
-
papers.set(rest, batchPaper(request, skipped, undefined,
|
|
451
|
+
papers.set(rest, batchPaper(request, skipped, undefined, content, item.mainPath));
|
|
388
452
|
}
|
|
389
453
|
log(STOP_NOTICE);
|
|
390
454
|
break;
|
|
@@ -394,7 +458,7 @@ async function downloadSupplementsBatch(options, backend, log, searchers, watch)
|
|
|
394
458
|
await papers.send(true);
|
|
395
459
|
ledger?.close();
|
|
396
460
|
return summary(options.mode ?? "two_phase", batchId, items, {
|
|
397
|
-
content
|
|
461
|
+
content,
|
|
398
462
|
...(ledger ? { runLog: ledger.dir } : {}),
|
|
399
463
|
});
|
|
400
464
|
}
|
|
@@ -416,7 +480,7 @@ async function downloadPerItem(searchers, options, backend, log, createTiers, pa
|
|
|
416
480
|
const entry = runItem(index, request);
|
|
417
481
|
log(`[批量] 第 ${index}/${total} 篇:${request.doi || request.paperId}`);
|
|
418
482
|
const batch = { id: batchId, index, total, done: offset, succeeded, failed };
|
|
419
|
-
const result = await pastNetworkLoss(() => pastHourlyLimit(() => downloadWithFallback(searchers, recorded({ ...request, batch, ...(away ? { shortUserWait: true } : {}) }, ledger, entry), createTiers(backend)), log, pause,
|
|
483
|
+
const result = await pastNetworkLoss(() => pastHourlyLimit(() => downloadWithFallback(searchers, recorded({ ...request, batch, ...(away ? { shortUserWait: true } : {}) }, ledger, entry), createTiers(backend)), log, pause, backend), watch);
|
|
420
484
|
if (result.status === "ok")
|
|
421
485
|
succeeded += 1;
|
|
422
486
|
else
|
|
@@ -428,6 +492,9 @@ async function downloadPerItem(searchers, options, backend, log, createTiers, pa
|
|
|
428
492
|
const finished = itemResult(result, index, request);
|
|
429
493
|
if (!stoppedByUser(result))
|
|
430
494
|
await filesPastNetworkLoss(finished, recorded({ ...request, batch }, ledger, entry), backend, searchers, watch);
|
|
495
|
+
if (!stoppedByUser(result)) {
|
|
496
|
+
await markdownPastNetworkLoss(finished, recorded({ ...request, batch }, ledger, entry), searchers, pageVisit(backend, { ...request, batch }, log, pause), watch);
|
|
497
|
+
}
|
|
431
498
|
await reportBatchItem({ ...request, batch }, finished, backend);
|
|
432
499
|
ledger?.item(entry, finished);
|
|
433
500
|
items.push(finished);
|
|
@@ -483,19 +550,25 @@ async function downloadTwoPhase(searchers, options, backend, log, createTiers, m
|
|
|
483
550
|
};
|
|
484
551
|
const id = (offset) => requests[offset].doi || requests[offset].paperId;
|
|
485
552
|
// Two lanes at once. The open lane checks every item in turn, needing no
|
|
486
|
-
// browser; each item it misses joins the queue of the
|
|
553
|
+
// browser; each item it misses joins the queue of the browser's lane, which
|
|
487
554
|
// starts on the first one at once and takes them one after another (one
|
|
488
|
-
// browser, one school login).
|
|
489
|
-
//
|
|
490
|
-
//
|
|
491
|
-
//
|
|
492
|
-
|
|
555
|
+
// browser, one school login). Each paper is finished in its turn, its PDF, its
|
|
556
|
+
// supplementary files and its Markdown, never left for a later round (user,
|
|
557
|
+
// 2026-11-15): an open-access paper whose files or page need the browser joins
|
|
558
|
+
// the same queue, to be finished there. A large batch shows the window from the
|
|
559
|
+
// start: one count for the whole batch, where an item counts once it is finished.
|
|
560
|
+
const wantsFiles = options.content === "both";
|
|
561
|
+
const wantsMarkdown = !!options.fulltext;
|
|
562
|
+
/** Open-access papers in the browser's queue for their files or page. */
|
|
563
|
+
const finishing = new Set();
|
|
493
564
|
const openProgress = mode !== "entitled_only" && total >= OPEN_PROGRESS_MIN_ITEMS && !!backend?.reportBatchProgress;
|
|
494
565
|
const missed = [];
|
|
495
566
|
const queue = [];
|
|
496
567
|
let openRunning = mode !== "entitled_only";
|
|
497
568
|
let checked = 0;
|
|
498
569
|
let openFound = 0;
|
|
570
|
+
/** Open-access papers finished (the browser's part done, when they needed one). */
|
|
571
|
+
let openSettled = 0;
|
|
499
572
|
let succeeded = 0;
|
|
500
573
|
let failed = 0;
|
|
501
574
|
/** Of the entitled lane's 成功: arXiv copies, open ones (as the finished card counts them). */
|
|
@@ -508,7 +581,7 @@ async function downloadTwoPhase(searchers, options, backend, log, createTiers, m
|
|
|
508
581
|
wake = undefined;
|
|
509
582
|
resume?.();
|
|
510
583
|
};
|
|
511
|
-
const settledOk = () =>
|
|
584
|
+
const settledOk = () => openSettled + succeeded;
|
|
512
585
|
// The window's lines while the lanes run, one report after another so that
|
|
513
586
|
// the counts never go back. Beside a running download only the counts and
|
|
514
587
|
// the lanes lines change (a backend that cannot do that gets none of these).
|
|
@@ -560,13 +633,25 @@ async function downloadTwoPhase(searchers, options, backend, log, createTiers, m
|
|
|
560
633
|
}
|
|
561
634
|
results[offset] = itemResult(result, offset + 1, request);
|
|
562
635
|
checked = offset + 1;
|
|
563
|
-
settle(offset, result.status === "ok" ? undefined : "school");
|
|
564
636
|
if (result.status === "ok") {
|
|
565
637
|
openFound += 1;
|
|
566
|
-
if
|
|
638
|
+
// Its Markdown from the open sources now; the browser's part, if any, in its queue.
|
|
639
|
+
const later = wantsFiles || wantsMarkdown &&
|
|
640
|
+
await fulltextForItem(results[offset], recorded(request, ledger, entries[offset]), searchers, "later") === "later";
|
|
641
|
+
// The window lists its PDF as saved now, as it did (its files' shortfall, if any, later).
|
|
642
|
+
settle(offset);
|
|
643
|
+
if (later) {
|
|
644
|
+
finishing.add(offset);
|
|
645
|
+
queue.push(offset);
|
|
646
|
+
notify();
|
|
647
|
+
}
|
|
648
|
+
else {
|
|
649
|
+
openSettled += 1;
|
|
567
650
|
record(offset);
|
|
651
|
+
}
|
|
568
652
|
}
|
|
569
653
|
else {
|
|
654
|
+
settle(offset, "school");
|
|
570
655
|
if (!missed.length) {
|
|
571
656
|
log(`[批量] 开放来源没有找到 ${id(offset)},机构下载同时开始`);
|
|
572
657
|
ledger?.phase("机构下载开始,开放来源同时进行");
|
|
@@ -590,26 +675,109 @@ async function downloadTwoPhase(searchers, options, backend, log, createTiers, m
|
|
|
590
675
|
ledger?.phase(`开放来源查完:${missed.length} 篇转机构下载`);
|
|
591
676
|
}
|
|
592
677
|
};
|
|
678
|
+
/**
|
|
679
|
+
* The browser's part of an open-access paper: its supplementary files (the visit also
|
|
680
|
+
* saves the page when the Markdown is wanted), then its Markdown.
|
|
681
|
+
*/
|
|
682
|
+
const finishOpenItem = async (offset) => {
|
|
683
|
+
finishing.delete(offset);
|
|
684
|
+
const done = settledOk() + failed;
|
|
685
|
+
const request = { ...requests[offset], batch: { id: batchId, index: done + 1, total, done, succeeded: settledOk(), failed },
|
|
686
|
+
...(away ? { shortUserWait: true } : {}) };
|
|
687
|
+
const item = results[offset];
|
|
688
|
+
log(`[批量] ${wantsFiles ? (wantsMarkdown ? "补充材料和 Markdown" : "补充材料") : "Markdown"}(PDF 已从开放来源取得):${id(offset)}`);
|
|
689
|
+
let extra;
|
|
690
|
+
/** Where the visit for the Markdown's page ended its wait on a school login (trace.loginWaitPage). */
|
|
691
|
+
let pageWait;
|
|
692
|
+
let markdownFrom = item.attempts.length;
|
|
693
|
+
try {
|
|
694
|
+
extra = await filesPastNetworkLoss(item, recorded(request, ledger, entries[offset]), backend, searchers, watch);
|
|
695
|
+
markdownFrom = item.attempts.length;
|
|
696
|
+
if (wantsMarkdown && !stoppedByUser(item)) {
|
|
697
|
+
await markdownPastNetworkLoss(item, recorded(request, ledger, entries[offset]), searchers, pageVisit(backend, request, log, pause, (trace) => { pageWait = trace?.loginWaitPage; learnPublisher(offset, trace?.publisher); }), watch);
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
catch (error) {
|
|
701
|
+
log(`[批量] 补充材料或 Markdown 出错(${id(offset)}):${error instanceof Error ? error.message : String(error)}`);
|
|
702
|
+
}
|
|
703
|
+
// Its full text read on the publisher's page in the browser: the school's login worked for
|
|
704
|
+
// this publisher in this batch, as a PDF through it shows (OAC, 2026-11-17: the login
|
|
705
|
+
// lapsed at 02:39 before any of its PDFs had come through the school, and 44 papers each
|
|
706
|
+
// waited it out until the user signed in again at 08:05).
|
|
707
|
+
if (item.markdown?.status === "ok" && item.markdown.source === "publisher_page")
|
|
708
|
+
cameThrough(offset);
|
|
709
|
+
if (item.markdown?.code === LOGIN_LAPSED_CODE) {
|
|
710
|
+
if (!away) {
|
|
711
|
+
away = true;
|
|
712
|
+
log(AWAY_NOTICE);
|
|
713
|
+
}
|
|
714
|
+
// Its page stopped at the school's own sign-in page: held with its publisher, its Markdown
|
|
715
|
+
// fetched again when the user goes on (the files it got stand).
|
|
716
|
+
if (pageWait === SCHOOL_SIGN_IN_PAGE && wentThrough(offset) && !stoppedByUser(item) && await canHold()) {
|
|
717
|
+
item.attempts.length = markdownFrom;
|
|
718
|
+
delete item.markdown;
|
|
719
|
+
finishing.add(offset);
|
|
720
|
+
if (extra)
|
|
721
|
+
await reportBatchItem(request, extra, backend);
|
|
722
|
+
hold(offset);
|
|
723
|
+
settle(offset);
|
|
724
|
+
await sendPapers();
|
|
725
|
+
return;
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
openSettled += 1;
|
|
729
|
+
if (extra)
|
|
730
|
+
await reportBatchItem(request, extra, backend);
|
|
731
|
+
record(offset);
|
|
732
|
+
// The window's 失败 list shows a missing supplementary file as it happens (user, 2026-11-11).
|
|
733
|
+
settle(offset);
|
|
734
|
+
if (stoppedByUser(item)) {
|
|
735
|
+
stopped = true;
|
|
736
|
+
return;
|
|
737
|
+
}
|
|
738
|
+
if (openRunning || queue.length)
|
|
739
|
+
await reportProgress("");
|
|
740
|
+
await sendPapers();
|
|
741
|
+
};
|
|
593
742
|
// A publisher whose school login stops working mid-batch (its papers came through the
|
|
594
|
-
// school, then one stops at the school's own sign-in page): its papers wait,
|
|
595
|
-
//
|
|
596
|
-
//
|
|
597
|
-
// the
|
|
743
|
+
// school, then one stops at the school's own sign-in page): its papers wait, their PDF, supplementary files
|
|
744
|
+
// and Markdown alike, the others go on, and they go on when the user presses 登录并继续 in
|
|
745
|
+
// the window (the user, 2026-11-15: Science's session lapsed after 84 articles and a
|
|
746
|
+
// misread login page failed the other 540). Publishers by name (user, 2026-11-17: a publisher's
|
|
747
|
+
// journals of other DOI prefixes, Elsevier's 10.1053/ and ARD's 10.1136/ beside 10.1016/, wait
|
|
748
|
+
// with it), each paper's as its school visit named it, else its DOI prefix's as learned so far,
|
|
749
|
+
// else the prefix itself.
|
|
750
|
+
/** Where the school's login worked in this batch: each such paper's publisher and DOI prefix. */
|
|
598
751
|
const viaSchool = new Set();
|
|
752
|
+
/** Each held publisher's papers, open-access ones still to be finished among them. */
|
|
599
753
|
const held = new Map();
|
|
600
754
|
/** Where each paper's wait on a school login ended, as the backend said (trace.loginWaitPage). */
|
|
601
755
|
const waitEnded = new Map();
|
|
602
756
|
const prefixOf = (offset) => (/^10\.\d{4,9}\//.exec(requests[offset].doi.toLowerCase()) ?? [""])[0];
|
|
603
|
-
/**
|
|
604
|
-
const
|
|
757
|
+
/** Each paper's publisher as its own school visit named it. */
|
|
758
|
+
const paperPublishers = new Map();
|
|
759
|
+
/** A paper's publisher: its own visit's, else its DOI prefix's as learned so far, else the prefix. */
|
|
760
|
+
const publisherOf = (offset) => paperPublishers.get(offset) ?? publishers.get(prefixOf(offset)) ?? prefixOf(offset);
|
|
761
|
+
const learnPublisher = (offset, name) => {
|
|
762
|
+
if (typeof name !== "string" || !name)
|
|
763
|
+
return;
|
|
764
|
+
paperPublishers.set(offset, name);
|
|
765
|
+
if (prefixOf(offset))
|
|
766
|
+
publishers.set(prefixOf(offset), name);
|
|
767
|
+
};
|
|
768
|
+
const cameThrough = (offset) => {
|
|
769
|
+
if (prefixOf(offset))
|
|
770
|
+
viaSchool.add(prefixOf(offset));
|
|
771
|
+
viaSchool.add(publisherOf(offset));
|
|
772
|
+
};
|
|
773
|
+
const wentThrough = (offset) => viaSchool.has(publisherOf(offset)) || (!!prefixOf(offset) && viaSchool.has(prefixOf(offset)));
|
|
605
774
|
// Held only where the window can show it with its button; else they fail as before.
|
|
606
775
|
let holdOk;
|
|
607
776
|
const canHold = async () => (holdOk ??= await backend?.holdSupported?.().catch(() => false) ?? false);
|
|
608
|
-
/** Each
|
|
777
|
+
/** Each DOI prefix's publisher as the school's stages named it ("Science"); the last one named. */
|
|
609
778
|
const publishers = new Map();
|
|
610
|
-
const heldList = () => [...
|
|
611
|
-
key, name: publishers.get(key) ?? key,
|
|
612
|
-
count: (held.get(key)?.length ?? 0) + (heldFiles.get(key)?.length ?? 0),
|
|
779
|
+
const heldList = () => [...held.entries()].map(([key, offsets]) => ({
|
|
780
|
+
key, name: publishers.get(key) ?? key, count: offsets.length,
|
|
613
781
|
}));
|
|
614
782
|
/** The window's line and button for the held publishers (none: cleared). */
|
|
615
783
|
const reportHeld = (waiting = false) => {
|
|
@@ -620,6 +788,19 @@ async function downloadTwoPhase(searchers, options, backend, log, createTiers, m
|
|
|
620
788
|
reports = reports.then(() => backend.reportBatchProgress(update)).catch(() => false);
|
|
621
789
|
return reports;
|
|
622
790
|
};
|
|
791
|
+
/** ``offset`` stopped at the school's sign-in page: its publisher's papers wait for the user. */
|
|
792
|
+
const hold = (offset) => {
|
|
793
|
+
const key = publisherOf(offset);
|
|
794
|
+
if (held.has(key)) {
|
|
795
|
+
held.get(key).push(offset);
|
|
796
|
+
return;
|
|
797
|
+
}
|
|
798
|
+
held.set(key, [offset]);
|
|
799
|
+
log(`[批量] ${key} 的文章前面经学校登录下到了,这一篇停在学校登录页没有完成登录:` +
|
|
800
|
+
"这家出版社的篇目先暂停,其他照常下载;回来后在进度窗口点“登录并继续”");
|
|
801
|
+
ledger?.phase(`暂停 ${key}:学校登录中途失效`);
|
|
802
|
+
void reportHeld();
|
|
803
|
+
};
|
|
623
804
|
/** The user pressed 登录并继续 (or 终止) in the window: held papers go on first. */
|
|
624
805
|
const takeRequests = () => {
|
|
625
806
|
const asked = backend?.takeBatchRequests?.(batchId);
|
|
@@ -641,17 +822,33 @@ async function downloadTwoPhase(searchers, options, backend, log, createTiers, m
|
|
|
641
822
|
notify();
|
|
642
823
|
}
|
|
643
824
|
};
|
|
825
|
+
/** The held papers end as paused (the batch stopped): returns them, no longer held. */
|
|
826
|
+
const markPaused = () => {
|
|
827
|
+
const paused = [...held.values()].flat();
|
|
828
|
+
for (const offset of paused) {
|
|
829
|
+
const item = results[offset];
|
|
830
|
+
if (finishing.has(offset)) {
|
|
831
|
+
// Its PDF stands; its browser's part waited for the login.
|
|
832
|
+
if (wantsFiles)
|
|
833
|
+
item.supplements = [{ status: "skipped", label: "", reason: "batch_stopped" }];
|
|
834
|
+
}
|
|
835
|
+
else {
|
|
836
|
+
results[offset] = itemResult({ ...item, status: "error", attempts: [...item.attempts,
|
|
837
|
+
{ stage: "entitled_access", status: "error", ...schoolAttemptDetails("login_paused") }] }, offset + 1, requests[offset]);
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
held.clear();
|
|
841
|
+
return paused;
|
|
842
|
+
};
|
|
644
843
|
/**
|
|
645
|
-
* The request, its school stage also naming
|
|
844
|
+
* The request, its school stage also naming its publisher (``learnPublisher``)
|
|
646
845
|
* and where its wait on a school login ended (``waitEnded``).
|
|
647
846
|
*/
|
|
648
|
-
const watchingSchool = (request,
|
|
847
|
+
const watchingSchool = (request, offset) => {
|
|
649
848
|
const forward = request.onStage;
|
|
650
849
|
return { ...request, onStage: (record) => {
|
|
651
850
|
if (record.stage === "entitled_access") {
|
|
652
|
-
|
|
653
|
-
if (prefix && typeof name === "string" && name)
|
|
654
|
-
publishers.set(prefix, name);
|
|
851
|
+
learnPublisher(offset, record.trace?.publisher);
|
|
655
852
|
const page = record.trace?.loginWaitPage;
|
|
656
853
|
if (typeof page === "string")
|
|
657
854
|
waitEnded.set(offset, page);
|
|
@@ -668,9 +865,17 @@ async function downloadTwoPhase(searchers, options, backend, log, createTiers, m
|
|
|
668
865
|
const offset = stopped ? undefined : queue.shift();
|
|
669
866
|
if (offset === undefined)
|
|
670
867
|
return;
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
868
|
+
if (held.has(publisherOf(offset))) {
|
|
869
|
+
held.get(publisherOf(offset)).push(offset);
|
|
870
|
+
continue;
|
|
871
|
+
}
|
|
872
|
+
if (finishing.has(offset)) {
|
|
873
|
+
await finishOpenItem(offset);
|
|
874
|
+
if (stopped)
|
|
875
|
+
return;
|
|
876
|
+
if (held.size)
|
|
877
|
+
await reportHeld();
|
|
878
|
+
takeRequests();
|
|
674
879
|
continue;
|
|
675
880
|
}
|
|
676
881
|
const request = requests[offset];
|
|
@@ -682,7 +887,7 @@ async function downloadTwoPhase(searchers, options, backend, log, createTiers, m
|
|
|
682
887
|
const batch = { id: batchId, index: done + 1, total, done, succeeded: settledOk(), failed };
|
|
683
888
|
let result;
|
|
684
889
|
try {
|
|
685
|
-
result = await pastNetworkLoss(() => pastHourlyLimit(() => downloadBatchItem(searchers, watchingSchool(recorded({ ...request, batch, ...(away ? { shortUserWait: true } : {}) }, ledger, entries[offset]),
|
|
890
|
+
result = await pastNetworkLoss(() => pastHourlyLimit(() => downloadBatchItem(searchers, watchingSchool(recorded({ ...request, batch, ...(away ? { shortUserWait: true } : {}) }, ledger, entries[offset]), offset), createTiers(backend).filter((tier) => tier.stage === "entitled_access" || mode !== "entitled_only" && tier.stage === "preprint"), backend), log, pause, backend), watch);
|
|
686
891
|
}
|
|
687
892
|
catch (error) {
|
|
688
893
|
result = laneError("entitled_access", error);
|
|
@@ -701,21 +906,22 @@ async function downloadTwoPhase(searchers, options, backend, log, createTiers, m
|
|
|
701
906
|
...(result.review ?? open.review ? { review: result.review ?? open.review } : {}),
|
|
702
907
|
}, offset + 1, request);
|
|
703
908
|
const school = result.attempts.find((attempt) => attempt.stage === "entitled_access");
|
|
704
|
-
const
|
|
909
|
+
const holding = result.status !== "ok" && wentThrough(offset) && school?.code === LOGIN_LAPSED_CODE
|
|
705
910
|
&& waitEnded.get(offset) === SCHOOL_SIGN_IN_PAGE && !stoppedByUser(result) && await canHold();
|
|
911
|
+
// Its Markdown now, from the page this visit saved, or the open sources (only these
|
|
912
|
+
// while its school login is in doubt).
|
|
913
|
+
if (wantsMarkdown && !stoppedByUser(result)) {
|
|
914
|
+
await markdownPastNetworkLoss(results[offset], recorded({ ...request, batch }, ledger, entries[offset]), searchers, holding ? undefined : pageVisit(backend, { ...request, batch, ...(away ? { shortUserWait: true } : {}) }, log, pause), watch);
|
|
915
|
+
}
|
|
706
916
|
if (result.status === "ok") {
|
|
707
917
|
succeeded += 1;
|
|
708
918
|
record(offset);
|
|
709
919
|
settle(offset);
|
|
710
|
-
if (school?.status === "ok"
|
|
711
|
-
|
|
920
|
+
if (school?.status === "ok")
|
|
921
|
+
cameThrough(offset);
|
|
712
922
|
}
|
|
713
|
-
else if (
|
|
714
|
-
|
|
715
|
-
log(`[批量] ${prefix} 的文章前面经学校登录下到了,这一篇停在学校登录页没有完成登录:` +
|
|
716
|
-
"这家出版社的篇目先暂停,其他照常下载;回来后在进度窗口点“登录并继续”");
|
|
717
|
-
ledger?.phase(`暂停 ${prefix}:学校登录中途失效`);
|
|
718
|
-
void reportHeld();
|
|
923
|
+
else if (holding) {
|
|
924
|
+
hold(offset);
|
|
719
925
|
}
|
|
720
926
|
else {
|
|
721
927
|
failed += 1;
|
|
@@ -750,35 +956,35 @@ async function downloadTwoPhase(searchers, options, backend, log, createTiers, m
|
|
|
750
956
|
ledger?.phase(`开放来源 ${total} 篇`);
|
|
751
957
|
void sendPapers();
|
|
752
958
|
await Promise.all([mode === "entitled_only" ? undefined : openLane(), entitledLane()]);
|
|
753
|
-
|
|
754
|
-
//
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
959
|
+
// The held publishers wait for the user as long as it takes (user, 2026-11-15): the
|
|
960
|
+
// window shows 登录并继续 and 终止. 登录并继续 downloads them, the school's login asking
|
|
961
|
+
// the user where it lapsed; held again, the wait starts over. 终止 ends them as paused.
|
|
962
|
+
if (held.size && !stopped) {
|
|
963
|
+
const waiting = [...held.values()].reduce((sum, offsets) => sum + offsets.length, 0);
|
|
964
|
+
log(`[批量] 其他篇目已完成,暂停的 ${waiting} 篇等你回来:在进度窗口点“登录并继续”,或点“终止”结束`);
|
|
965
|
+
ledger?.phase(`等你回来:暂停的 ${waiting} 篇`);
|
|
966
|
+
}
|
|
967
|
+
while (held.size && !stopped) {
|
|
968
|
+
await reportHeld(true);
|
|
969
|
+
await pause(HOLD_POLL_MS);
|
|
970
|
+
takeRequests();
|
|
971
|
+
if (queue.length && !stopped) {
|
|
972
|
+
await entitledLane();
|
|
766
973
|
}
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
// items not reached end as not downloaded, the held as paused.
|
|
772
|
-
let endedStopped = false;
|
|
773
|
-
const endStopped = () => {
|
|
774
|
-
if (endedStopped)
|
|
775
|
-
return;
|
|
776
|
-
endedStopped = true;
|
|
974
|
+
}
|
|
975
|
+
await reports;
|
|
976
|
+
// Stopped in the window: the items neither lane reached end as not downloaded, the held as paused.
|
|
977
|
+
if (stopped) {
|
|
777
978
|
markPaused();
|
|
778
979
|
for (const [offset, request] of requests.entries()) {
|
|
779
980
|
const item = results[offset];
|
|
780
981
|
if (!item)
|
|
781
982
|
results[offset] = itemResult({ status: "error", attempts: [notReached()] }, offset + 1, request);
|
|
983
|
+
else if (finishing.has(offset)) {
|
|
984
|
+
// Its PDF stands; its browser's part was not reached.
|
|
985
|
+
if (wantsFiles)
|
|
986
|
+
item.supplements = [{ status: "skipped", label: "", reason: "batch_stopped" }];
|
|
987
|
+
}
|
|
782
988
|
else if (queue.includes(offset)) {
|
|
783
989
|
results[offset] = itemResult({ ...item, status: "error", attempts: [...item.attempts, notReached()] }, offset + 1, request);
|
|
784
990
|
}
|
|
@@ -788,86 +994,9 @@ async function downloadTwoPhase(searchers, options, backend, log, createTiers, m
|
|
|
788
994
|
record(offset);
|
|
789
995
|
}
|
|
790
996
|
log(STOP_NOTICE);
|
|
791
|
-
}
|
|
792
|
-
if (stopped)
|
|
793
|
-
endStopped();
|
|
997
|
+
}
|
|
794
998
|
const items = results;
|
|
795
999
|
const remaining = missed.length;
|
|
796
|
-
// Then supplementary files for the items the open stages already got.
|
|
797
|
-
if (options.content === "both" && !stopped) {
|
|
798
|
-
const open = requests.map((_, offset) => offset).filter((offset) => !missed.includes(offset));
|
|
799
|
-
if (open.length)
|
|
800
|
-
ledger?.phase(`补充材料 ${open.length} 篇`);
|
|
801
|
-
let supplementsSucceeded = 0;
|
|
802
|
-
let supplementsFailed = 0;
|
|
803
|
-
for (const [step, offset] of open.entries()) {
|
|
804
|
-
const prefix = prefixOf(offset);
|
|
805
|
-
if (prefix && held.has(prefix)) {
|
|
806
|
-
heldFiles.set(prefix, [...(heldFiles.get(prefix) ?? []), offset]);
|
|
807
|
-
continue;
|
|
808
|
-
}
|
|
809
|
-
log(`[批量] 补充材料 ${step + 1}/${open.length}:${id(offset)}`);
|
|
810
|
-
// Every item of the entitled lane has settled; these come after them.
|
|
811
|
-
const batch = { id: batchId, index: remaining + step + 1, total, done: remaining + step,
|
|
812
|
-
succeeded: succeeded + supplementsSucceeded, failed: failed + supplementsFailed };
|
|
813
|
-
const request = { ...requests[offset], batch };
|
|
814
|
-
const extra = await filesPastNetworkLoss(items[offset], recorded(request, ledger, entries[offset]), backend, searchers, watch);
|
|
815
|
-
if (extra) {
|
|
816
|
-
await reportBatchItem(request, extra, backend);
|
|
817
|
-
if (extra.status === "ok")
|
|
818
|
-
supplementsSucceeded += 1;
|
|
819
|
-
else
|
|
820
|
-
supplementsFailed += 1;
|
|
821
|
-
}
|
|
822
|
-
record(offset);
|
|
823
|
-
// The window's 失败 list shows a missing supplementary file as it happens (user, 2026-11-11).
|
|
824
|
-
settle(offset);
|
|
825
|
-
await sendPapers();
|
|
826
|
-
if (stoppedByUser(items[offset])) {
|
|
827
|
-
stopped = true; // the rest of them end as not reached, below
|
|
828
|
-
break;
|
|
829
|
-
}
|
|
830
|
-
}
|
|
831
|
-
}
|
|
832
|
-
// The held publishers wait for the user as long as it takes (user, 2026-11-15): the
|
|
833
|
-
// window shows 登录并继续 and 终止. 登录并继续 downloads them, the school's login asking
|
|
834
|
-
// the user where it lapsed; held again, the wait starts over. 终止 ends them as paused.
|
|
835
|
-
if ((held.size || heldFiles.size) && !stopped) {
|
|
836
|
-
const waiting = [...held.values(), ...heldFiles.values()].reduce((sum, offsets) => sum + offsets.length, 0);
|
|
837
|
-
log(`[批量] 其他篇目已完成,暂停的 ${waiting} 篇等你回来:在进度窗口点“登录并继续”,或点“终止”结束`);
|
|
838
|
-
ledger?.phase(`等你回来:暂停的 ${waiting} 篇`);
|
|
839
|
-
}
|
|
840
|
-
while ((held.size || heldFiles.size) && !stopped) {
|
|
841
|
-
await reportHeld(true);
|
|
842
|
-
await pause(HOLD_POLL_MS);
|
|
843
|
-
takeRequests();
|
|
844
|
-
if (queue.length && !stopped) {
|
|
845
|
-
await entitledLane();
|
|
846
|
-
}
|
|
847
|
-
// A publisher gone on with: its open-access papers' files too.
|
|
848
|
-
for (const [key, offsets] of [...heldFiles.entries()]) {
|
|
849
|
-
if (held.has(key) || stopped)
|
|
850
|
-
continue;
|
|
851
|
-
heldFiles.delete(key);
|
|
852
|
-
for (const offset of offsets) {
|
|
853
|
-
if (stopped)
|
|
854
|
-
break;
|
|
855
|
-
log(`[批量] 补充材料:${id(offset)}`);
|
|
856
|
-
const done = settledOk() + failed;
|
|
857
|
-
const request = { ...requests[offset], batch: { id: batchId, index: done + 1, total, done, succeeded: settledOk(), failed } };
|
|
858
|
-
const extra = await filesPastNetworkLoss(items[offset], recorded(request, ledger, entries[offset]), backend, searchers, watch);
|
|
859
|
-
if (extra)
|
|
860
|
-
await reportBatchItem(request, extra, backend);
|
|
861
|
-
record(offset);
|
|
862
|
-
settle(offset);
|
|
863
|
-
await sendPapers();
|
|
864
|
-
if (stoppedByUser(items[offset]))
|
|
865
|
-
stopped = true;
|
|
866
|
-
}
|
|
867
|
-
}
|
|
868
|
-
}
|
|
869
|
-
if (stopped)
|
|
870
|
-
endStopped();
|
|
871
1000
|
// Every paper as it ended, before the window's finished card.
|
|
872
1001
|
requests.forEach((_, offset) => settle(offset));
|
|
873
1002
|
await sendPapers(true);
|
|
@@ -876,6 +1005,7 @@ async function downloadTwoPhase(searchers, options, backend, log, createTiers, m
|
|
|
876
1005
|
content: options.content ?? "main",
|
|
877
1006
|
entitledAccessItems: remaining,
|
|
878
1007
|
...(ledger ? { runLog: ledger.dir } : {}),
|
|
1008
|
+
...(stopped ? { stopped: true } : {}),
|
|
879
1009
|
});
|
|
880
1010
|
}
|
|
881
1011
|
//# sourceMappingURL=batch.js.map
|