papersearch 0.7.2 → 0.8.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.
Files changed (177) hide show
  1. package/LICENSE-paper-search-mcp-nodejs +24 -0
  2. package/NOTICE +8 -37
  3. package/README.en.md +7 -3
  4. package/README.fr.md +268 -0
  5. package/README.ja.md +268 -0
  6. package/README.ko.md +268 -0
  7. package/README.md +7 -3
  8. package/README.zh-Hant.md +268 -0
  9. package/dist/capabilities/download/batch/batch.d.ts +16 -1
  10. package/dist/capabilities/download/batch/batch.d.ts.map +1 -1
  11. package/dist/capabilities/download/batch/batch.js +669 -53
  12. package/dist/capabilities/download/batch/batch.js.map +1 -1
  13. package/dist/capabilities/download/batch/batchFolder.d.ts.map +1 -1
  14. package/dist/capabilities/download/batch/batchFolder.js +4 -3
  15. package/dist/capabilities/download/batch/batchFolder.js.map +1 -1
  16. package/dist/capabilities/download/batch/batchSummary.js +1 -1
  17. package/dist/capabilities/download/batch/batchSummary.js.map +1 -1
  18. package/dist/capabilities/download/batch/networkLoss.d.ts +12 -3
  19. package/dist/capabilities/download/batch/networkLoss.d.ts.map +1 -1
  20. package/dist/capabilities/download/batch/networkLoss.js +25 -4
  21. package/dist/capabilities/download/batch/networkLoss.js.map +1 -1
  22. package/dist/capabilities/download/batch/resume.d.ts +7 -0
  23. package/dist/capabilities/download/batch/resume.d.ts.map +1 -1
  24. package/dist/capabilities/download/batch/resume.js +50 -9
  25. package/dist/capabilities/download/batch/resume.js.map +1 -1
  26. package/dist/capabilities/download/content/markdown/pro.d.ts +6 -0
  27. package/dist/capabilities/download/content/markdown/pro.d.ts.map +1 -1
  28. package/dist/capabilities/download/content/markdown/pro.js.map +1 -1
  29. package/dist/capabilities/download/content/markdown/shortfall.d.ts +8 -5
  30. package/dist/capabilities/download/content/markdown/shortfall.d.ts.map +1 -1
  31. package/dist/capabilities/download/content/markdown/shortfall.js +27 -15
  32. package/dist/capabilities/download/content/markdown/shortfall.js.map +1 -1
  33. package/dist/capabilities/download/content/markdown/step.d.ts +9 -0
  34. package/dist/capabilities/download/content/markdown/step.d.ts.map +1 -1
  35. package/dist/capabilities/download/content/markdown/step.js +42 -2
  36. package/dist/capabilities/download/content/markdown/step.js.map +1 -1
  37. package/dist/capabilities/download/content/markdown/types.d.ts +10 -1
  38. package/dist/capabilities/download/content/markdown/types.d.ts.map +1 -1
  39. package/dist/capabilities/download/handler.d.ts.map +1 -1
  40. package/dist/capabilities/download/handler.js +13 -5
  41. package/dist/capabilities/download/handler.js.map +1 -1
  42. package/dist/capabilities/download/outputLayout.d.ts.map +1 -1
  43. package/dist/capabilities/download/outputLayout.js +3 -1
  44. package/dist/capabilities/download/outputLayout.js.map +1 -1
  45. package/dist/capabilities/download/tools.js +2 -2
  46. package/dist/capabilities/download/tools.js.map +1 -1
  47. package/dist/capabilities/download/types.d.ts +9 -1
  48. package/dist/capabilities/download/types.d.ts.map +1 -1
  49. package/dist/cli.js +3 -1
  50. package/dist/cli.js.map +1 -1
  51. package/dist/infrastructure/runlog/RunLedger.d.ts +7 -0
  52. package/dist/infrastructure/runlog/RunLedger.d.ts.map +1 -1
  53. package/dist/infrastructure/runlog/RunLedger.js +13 -0
  54. package/dist/infrastructure/runlog/RunLedger.js.map +1 -1
  55. package/dist/infrastructure/runlog/failureClass.d.ts +17 -9
  56. package/dist/infrastructure/runlog/failureClass.d.ts.map +1 -1
  57. package/dist/infrastructure/runlog/failureClass.js +89 -56
  58. package/dist/infrastructure/runlog/failureClass.js.map +1 -1
  59. package/dist/infrastructure/school/SchoolAttempt.d.ts +11 -0
  60. package/dist/infrastructure/school/SchoolAttempt.d.ts.map +1 -1
  61. package/dist/infrastructure/school/SchoolAttempt.js +107 -59
  62. package/dist/infrastructure/school/SchoolAttempt.js.map +1 -1
  63. package/dist/infrastructure/school/SchoolMcpClient.d.ts +7 -2
  64. package/dist/infrastructure/school/SchoolMcpClient.d.ts.map +1 -1
  65. package/dist/infrastructure/school/SchoolMcpClient.js +30 -7
  66. package/dist/infrastructure/school/SchoolMcpClient.js.map +1 -1
  67. package/dist/infrastructure/school/SchoolProgress.d.ts +2 -0
  68. package/dist/infrastructure/school/SchoolProgress.d.ts.map +1 -1
  69. package/dist/infrastructure/school/SchoolProgress.js +2 -0
  70. package/dist/infrastructure/school/SchoolProgress.js.map +1 -1
  71. package/dist/infrastructure/school/SchoolReadiness.d.ts +2 -0
  72. package/dist/infrastructure/school/SchoolReadiness.d.ts.map +1 -1
  73. package/dist/infrastructure/school/SchoolReadiness.js +2 -0
  74. package/dist/infrastructure/school/SchoolReadiness.js.map +1 -1
  75. package/dist/infrastructure/school/SchoolResultNormalizer.d.ts.map +1 -1
  76. package/dist/infrastructure/school/SchoolResultNormalizer.js +4 -0
  77. package/dist/infrastructure/school/SchoolResultNormalizer.js.map +1 -1
  78. package/dist/infrastructure/school/index.d.ts +2 -2
  79. package/dist/infrastructure/school/index.d.ts.map +1 -1
  80. package/dist/infrastructure/school/index.js +1 -1
  81. package/dist/infrastructure/school/index.js.map +1 -1
  82. package/dist/infrastructure/school/types.d.ts +52 -3
  83. package/dist/infrastructure/school/types.d.ts.map +1 -1
  84. package/dist/infrastructure/school/types.js.map +1 -1
  85. package/dist/management/failures/index.d.ts +28 -2
  86. package/dist/management/failures/index.d.ts.map +1 -1
  87. package/dist/management/failures/index.js +83 -21
  88. package/dist/management/failures/index.js.map +1 -1
  89. package/package.json +7 -2
  90. package/school/NOTICE +3 -2
  91. package/school/paper_search_school/adapters/__init__.py +2 -0
  92. package/school/paper_search_school/adapters/aps/__init__.py +3 -6
  93. package/school/paper_search_school/adapters/base.py +18 -0
  94. package/school/paper_search_school/adapters/copernicus/__init__.py +2 -7
  95. package/school/paper_search_school/adapters/elsevier/__init__.py +50 -1
  96. package/school/paper_search_school/adapters/frontiers/__init__.py +41 -2
  97. package/school/paper_search_school/adapters/ieee/__init__.py +6 -4
  98. package/school/paper_search_school/adapters/iop/__init__.py +8 -0
  99. package/school/paper_search_school/adapters/jama/__init__.py +8 -0
  100. package/school/paper_search_school/adapters/lww/__init__.py +14 -6
  101. package/school/paper_search_school/adapters/mdpi/__init__.py +12 -7
  102. package/school/paper_search_school/adapters/neurology/__init__.py +5 -2
  103. package/school/paper_search_school/adapters/optica/__init__.py +2 -9
  104. package/school/paper_search_school/adapters/oup/__init__.py +27 -4
  105. package/school/paper_search_school/adapters/platforms/__init__.py +4 -1
  106. package/school/paper_search_school/adapters/platforms/atypon/__init__.py +8 -0
  107. package/school/paper_search_school/adapters/platforms/jstage/__init__.py +64 -0
  108. package/school/paper_search_school/adapters/sage/__init__.py +4 -1
  109. package/school/paper_search_school/adapters/thieme/__init__.py +6 -11
  110. package/school/paper_search_school/api_keys.py +63 -13
  111. package/school/paper_search_school/assets/api_keys.json +14 -0
  112. package/school/paper_search_school/assets/capsule.html +274 -158
  113. package/school/paper_search_school/assets/capsule_en.json +99 -98
  114. package/school/paper_search_school/assets/capsule_fr.json +100 -99
  115. package/school/paper_search_school/assets/capsule_ja.json +99 -98
  116. package/school/paper_search_school/assets/capsule_ko.json +99 -98
  117. package/school/paper_search_school/assets/capsule_zh-Hant.json +94 -97
  118. package/school/paper_search_school/browser/batch_session.py +1 -1
  119. package/school/paper_search_school/browser/challenge/__init__.py +12 -9
  120. package/school/paper_search_school/browser/challenge/continuation.py +65 -0
  121. package/school/paper_search_school/browser/challenge/handlers/__init__.py +1 -0
  122. package/school/paper_search_school/browser/challenge/handlers/aws_waf.py +260 -0
  123. package/school/paper_search_school/browser/challenge/handlers/recaptcha_hcaptcha.py +167 -0
  124. package/school/paper_search_school/browser/challenge/handlers/text_captcha.py +100 -0
  125. package/school/paper_search_school/browser/challenge/handlers/turnstile.py +174 -0
  126. package/school/paper_search_school/browser/challenge/kinds.py +203 -0
  127. package/school/paper_search_school/browser/challenge/local/__init__.py +1 -0
  128. package/school/paper_search_school/browser/challenge/{interaction.py → local/interaction.py} +94 -13
  129. package/school/paper_search_school/browser/challenge/{pointer.py → local/pointer.py} +2 -2
  130. package/school/paper_search_school/browser/challenge/local/prompt.py +283 -0
  131. package/school/paper_search_school/browser/challenge/local/submission.py +33 -0
  132. package/school/paper_search_school/browser/challenge/services/__init__.py +1 -0
  133. package/school/paper_search_school/browser/challenge/services/solver.py +272 -0
  134. package/school/paper_search_school/cli_config.py +10 -5
  135. package/school/paper_search_school/cold_start.py +22 -11
  136. package/school/paper_search_school/config.py +11 -10
  137. package/school/paper_search_school/download_diagnostics.py +7 -2
  138. package/school/paper_search_school/engine/access_rules.py +15 -5
  139. package/school/paper_search_school/engine/batch.py +55 -15
  140. package/school/paper_search_school/engine/batch_access.py +59 -21
  141. package/school/paper_search_school/engine/batch_capture.py +215 -18
  142. package/school/paper_search_school/engine/batch_common.py +3 -0
  143. package/school/paper_search_school/engine/batch_diagnostics.py +25 -5
  144. package/school/paper_search_school/engine/batch_institution.py +168 -32
  145. package/school/paper_search_school/engine/batch_login.py +223 -16
  146. package/school/paper_search_school/engine/batch_pdf_urls.py +38 -7
  147. package/school/paper_search_school/engine/batch_waits.py +179 -12
  148. package/school/paper_search_school/engine/bridge.py +44 -7
  149. package/school/paper_search_school/engine/fulltext_page.py +45 -7
  150. package/school/paper_search_school/engine/router.py +18 -2
  151. package/school/paper_search_school/entitlements.py +1 -1
  152. package/school/paper_search_school/orchestrator.py +44 -18
  153. package/school/paper_search_school/pdf_utils.py +25 -16
  154. package/school/paper_search_school/progress_capsule.py +36 -6
  155. package/school/paper_search_school/progress_reporter.py +71 -13
  156. package/school/paper_search_school/progress_view.py +64 -44
  157. package/school/paper_search_school/publishers/builtin/iop.json +2 -1
  158. package/school/paper_search_school/publishers/builtin/neurology.json +4 -2
  159. package/school/paper_search_school/publishers/builtin/sage.json +4 -2
  160. package/school/paper_search_school/publishers/builtin/thieme.json +3 -1
  161. package/school/paper_search_school/publishers/site.py +12 -4
  162. package/school/paper_search_school/school_switch.py +34 -52
  163. package/school/paper_search_school/school_test.py +1 -1
  164. package/school/paper_search_school/server.py +24 -11
  165. package/school/paper_search_school/user_settings.py +13 -0
  166. package/school/pyproject.toml +1 -0
  167. package/skills/paper-search/SKILL.md +107 -107
  168. package/skills/paper-search/references/browser-download.md +102 -101
  169. package/skills/paper-search/references/capability-routing.md +89 -89
  170. package/skills/paper-search/references/cli-contract.md +78 -78
  171. package/skills/paper-search/references/federation-support.md +172 -172
  172. package/skills/paper-search/references/management-layer.md +78 -78
  173. package/skills/paper-search/references/publisher-support.md +38 -38
  174. package/skills/paper-search/references/school-setup.md +56 -55
  175. package/skills/paper-search/references/setup.md +20 -20
  176. package/skills/paper-search/references/troubleshooting.md +12 -12
  177. package/school/paper_search_school/browser/challenge/prompt.py +0 -154
@@ -6,14 +6,16 @@
6
6
  "10.1212"
7
7
  ],
8
8
  "base_domains": [
9
- "neurology.org"
9
+ "neurology.org",
10
+ "continuum.aan.com"
10
11
  ],
11
12
  "article_url_template": "https://doi.org/{doi}",
12
13
  "pdf_url_templates": [
13
14
  "https://www.neurology.org/doi/pdf/{doi}"
14
15
  ],
15
16
  "success_url_markers": [
16
- "neurology.org/doi/"
17
+ "neurology.org/doi/",
18
+ "continuum.aan.com/doi/"
17
19
  ],
18
20
  "auth_url_markers": [
19
21
  "/login",
@@ -3,12 +3,14 @@
3
3
  "profile": {
4
4
  "name": "SAGE",
5
5
  "doi_prefixes": [
6
- "10.1177"
6
+ "10.1177",
7
+ "10.1191",
8
+ "10.1258"
7
9
  ],
8
10
  "base_domains": [
9
11
  "sagepub.com"
10
12
  ],
11
- "article_url_template": "https://doi.org/{doi}",
13
+ "article_url_template": "https://journals.sagepub.com/doi/{doi}",
12
14
  "pdf_url_templates": [
13
15
  "https://journals.sagepub.com/doi/pdf/{doi}"
14
16
  ],
@@ -3,7 +3,9 @@
3
3
  "profile": {
4
4
  "name": "Thieme",
5
5
  "doi_prefixes": [
6
- "10.1055"
6
+ "10.1055",
7
+ "10.1160",
8
+ "10.3414"
7
9
  ],
8
10
  "base_domains": [
9
11
  "thieme-connect.com",
@@ -16,7 +16,7 @@ from typing import ClassVar
16
16
  from urllib.parse import urlparse
17
17
 
18
18
  from ..engine.access_rules import registrable_domain
19
- from .model import PublisherProfile
19
+ from .model import PdfSourcePathTemplate, PublisherProfile
20
20
 
21
21
  #: Name prefix of a run-time site profile: ``site:<registrable domain>``.
22
22
  SITE_PREFIX = "site:"
@@ -34,11 +34,17 @@ GENERIC_SUPPLEMENTARY_URL_MARKERS = ("supplementary", "suppl_file", "supporting-
34
34
  # Where a DOI can land that is no publisher's site: doi.org itself, Crossref's
35
35
  # multiple-resolution chooser, the Handle resolver.
36
36
  _NOT_A_SITE = frozenset({"doi.org", "crossref.org", "handle.net"})
37
- # Platforms the engine does not sign in on, whatever DOI leads there: ClinicalKey
38
- # (the Elsevier adapter's unsupported platform) and the databases dropped on
37
+ # Platforms the engine does not sign in on, whatever DOI leads there: ClinicalKey and
38
+ # EM-Consulte (the Elsevier adapter's unsupported platforms) and the databases dropped on
39
39
  # 2026-11-02 (CNKI, Wanfang, VIP).
40
- _UNSUPPORTED_SITES = re.compile(r"clinicalkey\.[a-z]{2,3}(?:\.[a-z]{2})?|cnki\.net|wanfangdata\.com\.cn|cqvip\.com")
40
+ _UNSUPPORTED_SITES = re.compile(
41
+ r"clinicalkey\.[a-z]{2,3}(?:\.[a-z]{2})?|em-consulte\.com|cnki\.net|wanfangdata\.com\.cn|cqvip\.com")
41
42
  _DOI_PREFIX = re.compile(r"10\.\d{4,9}")
43
+ # A platform's PDF address made from the article page's address, by DOI prefix. F1000's open research
44
+ # platforms (F1000Research, Wellcome, Gates, Bioethics Open Research and the others, all 10.12688): the
45
+ # page /articles/<n>-<n>/v<k> plus /pdf, a redirect to the file. The page names no PDF anywhere (its
46
+ # Download button opens a menu), and nothing was tried there (Bioethics Open Research, 2026-11-24).
47
+ _PAGE_PDF_PATHS = {"10.12688": ("/articles/", "{source_path}/pdf")}
42
48
 
43
49
 
44
50
  @dataclass(frozen=True)
@@ -73,6 +79,7 @@ def site_profile(doi: str, landing_url: str) -> SiteProfile | None:
73
79
  domain = registrable_domain(host)
74
80
  if not domain or domain in _NOT_A_SITE or _UNSUPPORTED_SITES.fullmatch(domain):
75
81
  return None
82
+ page_pdf = _PAGE_PDF_PATHS.get(prefix)
76
83
  return SiteProfile(
77
84
  name=SITE_PREFIX + domain,
78
85
  article_url_template="https://doi.org/{doi}",
@@ -82,5 +89,6 @@ def site_profile(doi: str, landing_url: str) -> SiteProfile | None:
82
89
  sso_text_markers=GENERIC_SSO_TEXT_MARKERS,
83
90
  doi_prefixes=(prefix,),
84
91
  base_domains=(domain,),
92
+ pdf_source_path_templates=(PdfSourcePathTemplate(domain, *page_pdf),) if page_pdf else (),
85
93
  supplementary_url_markers=GENERIC_SUPPLEMENTARY_URL_MARKERS,
86
94
  )
@@ -1,11 +1,13 @@
1
1
  """没权限时换下一所学校 (PaperSearch Pro; user, 2026-11-21).
2
2
 
3
- An article the school signed in to but has no access to (its publisher says so) is tried with the next saved school:
3
+ A paper the school has no access to, failed under 没权限 (signed in and refused, the school's sign-in not enabled for
4
+ the publisher, no route for it there, or marked by the user as without access), is tried with the next saved school:
4
5
  one Pro fills the sign-in of, its account saved and its auto sign-in on; the default school first, then the list's
5
- order. A journal one of them got is remembered for the rest of the download task (a batch; a single download is a task
6
- of its own) and tried with it first; a task starts again from the default school. Only "no access" switches: a sign-in
7
- that failed (a wrong password, a code to type, a page that stopped it) is the user's to see, not another account's.
8
- Each switch forgets the sign-in before it (cold_start.before_sign_in), the batch's browser closed first to let go of it.
6
+ order. A download on its own switches at once. A batch switches once at its end (download/batch/batch.ts): its papers
7
+ all with the default school, then those without access together with the next school, and so on (user, 2026-11-22:
8
+ switching to and fro at each paper had a school's login ask for a picture code). Only 没权限 switches: a sign-in that
9
+ failed (a wrong password, a code to type, a page that stopped it) is the user's to see, not another account's. Each
10
+ switch forgets the sign-in before it (cold_start.before_sign_in), the batch's browser closed first to let go of it.
9
11
  """
10
12
  from __future__ import annotations
11
13
 
@@ -14,8 +16,15 @@ from typing import Any
14
16
  #: The switch on the sign-in page (config), on unless turned off.
15
17
  SETTING = "school_switch"
16
18
 
17
- #: (task, journal) -> the entityID of the school that got the journal's article in that task.
18
- _GOT: dict[tuple[str, str], str] = {}
19
+ #: 没权限 besides a refusal after the sign-in (failureClass.ts): the school's sign-in not enabled for the publisher (IEEE
20
+ #: "Your institution may not be enabled", AHA's OpenAthens "restricted by your organization"), the publisher with no route
21
+ #: for it, or the user's mark, made with the default school. Another school may have it (user, 2026-11-22: IEEE was not
22
+ #: tried with the second school; every paper under 没权限 is).
23
+ NOT_THIS_SCHOOL = ("institution_not_registered", "institution_federation_unavailable", "no_entitlement")
24
+
25
+ #: Set on a download's config when its school is not the default one: the user's 没权限 marks were made with the
26
+ #: default school and do not skip another's visit (engine/bridge.py).
27
+ MARKS_OFF = "no_access_marks_off"
19
28
 
20
29
 
21
30
  def enabled(config: dict[str, Any]) -> bool:
@@ -23,9 +32,24 @@ def enabled(config: dict[str, Any]) -> bool:
23
32
 
24
33
 
25
34
  def no_access(result: dict[str, Any] | None) -> bool:
26
- """Signed in, and the publisher has no access for the school to this article (not a sign-in that failed)."""
27
- return bool(result) and not result.get("success") and result.get("error_type") == "paywall" \
28
- and result.get("reason_code") == "institution_pdf_entitlement_missing"
35
+ """The school has no access to this article, a 没权限 failure (not a sign-in that failed)."""
36
+ if not result or result.get("success"):
37
+ return False
38
+ if result.get("error_type") in NOT_THIS_SCHOOL:
39
+ return True
40
+ return result.get("error_type") == "paywall" and result.get("reason_code") == "institution_pdf_entitlement_missing"
41
+
42
+
43
+ #: A failure after one of the school's entries by one name, its next entry to be tried (user, 2026-11-22: "同名学校的话,
44
+ #: 那就直接选一个……如果这个不行的话,再向下一个"): 没权限, or the login not reached or not finished (JAMA's first
45
+ #: entry of a test school was its library proxy, whose sign-in asks for a picture code).
46
+ ENTRY_DID_NOT_DO = ("login_not_reached", "login_timeout", "idp_no_return_to_publisher")
47
+
48
+
49
+ def entry_did_not_do(result: dict[str, Any] | None) -> bool:
50
+ """The download failed after one of several entries by the school's name: the next one may do."""
51
+ return bool(result) and not result.get("success") and int(result.get("same_name_entries") or 0) > 1 and (
52
+ no_access(result) or result.get("error_type") in ENTRY_DID_NOT_DO)
29
53
 
30
54
 
31
55
  def schools(config: dict[str, Any]) -> list[dict[str, Any]]:
@@ -56,47 +80,5 @@ def grouping(config: dict[str, Any]) -> bool:
56
80
  return enabled(config) and len(schools(config)) > 1
57
81
 
58
82
 
59
- def _task() -> str:
60
- from . import progress_reporter
61
-
62
- return progress_reporter.batch_id()
63
-
64
-
65
- def journal(doi: str) -> str:
66
- """The journal's key: its ISSNs (Crossref, kept), else its title; "" when not known."""
67
- from .entitlements import journal_identity
68
-
69
- try:
70
- identity = journal_identity(doi)
71
- except Exception:
72
- return ""
73
- issns = identity.get("issn") or []
74
- return "issn:" + ",".join(sorted(issns)) if issns else str(identity.get("journal") or "").strip().lower()
75
-
76
-
77
- def remembered(doi: str) -> str:
78
- """The school (entityID) that got this article's journal earlier in this task; "" when none or not in a task."""
79
- task = _task()
80
- key = journal(doi) if task else ""
81
- return _GOT.get((task, key), "") if key else ""
82
-
83
-
84
- def remember(doi: str, entity: str) -> None:
85
- task = _task()
86
- key = journal(doi) if task and entity else ""
87
- if key:
88
- _GOT[(task, key)] = entity
89
-
90
-
91
- def order_for(config: dict[str, Any], doi: str) -> list[dict[str, Any]]:
92
- """The schools to try for this article, in turn: its journal's school of this task first, then the default one
93
- and the rest."""
94
- listed = schools(config)
95
- if len(listed) < 2:
96
- return listed # nothing to switch to: no journal looked up
97
- first = remembered(doi)
98
- return sorted(listed, key=lambda entry: str(entry.get("idp_entity_id") or "").strip() != first) if first else listed
99
-
100
-
101
83
  def name(entry: dict[str, Any]) -> str:
102
84
  return str(entry.get("school_name") or entry.get("school_name_en") or entry.get("idp_entity_id") or "")
@@ -188,7 +188,7 @@ def judge(result: dict[str, Any], *, filled: bool, refused: bool) -> dict[str, A
188
188
  else "卡在学校登录这一步;学校的登录页要你自己操作时,在下载浏览器里完成"}
189
189
  if kind == "access_blocked":
190
190
  return {"ok": False, "title": "出版社网站拦住了访问", "detail": "稍后再测,或换一篇"}
191
- if kind == "download_timeout":
191
+ if kind in ("download_timeout", "captcha_required"):
192
192
  return {"ok": False, "title": "没有拿到全文", "detail": "页面或安全验证一直没有完成,换一篇或稍后再测"}
193
193
  if kind == "network_unavailable":
194
194
  return {"ok": False, "title": "网络不通", "detail": "检查网络后再测"}
@@ -244,15 +244,19 @@ async def school_keep_session() -> str:
244
244
 
245
245
  @mcp_app.tool()
246
246
  def school_switch_state() -> str:
247
- """Whether a batch takes one journal's papers one after another (没权限时换下一所学校, school_switch.py): the switch
248
- on and more than one school taking part, so that a school switched to for a journal is not switched away from and
249
- back. Opens no browser. Answers {"on": bool, "schools": n, "group": bool}."""
250
- from . import school_switch
247
+ """The schools a batch's papers without access (没权限) are tried with at its end, one after another
248
+ (没权限时换下一所学校, school_switch.py): the default one first, each named as ``school_download``'s ``school``
249
+ takes it (its entityID); none while the switch is off; and whether the batch takes one journal's papers one after
250
+ another (``group``: on and more than one school); and whether 失败后自动重试 is on (``retry``, user_settings). Opens no
251
+ browser. Answers {"on": bool, "schools": [{"name": ..., "entity_id": ...}, ...], "group": bool, "retry": bool}."""
252
+ from . import school_switch, user_settings
251
253
 
252
254
  config = load_config()
253
- count = len(school_switch.schools(config))
254
255
  on = school_switch.enabled(config)
255
- return json.dumps({"on": on, "schools": count, "group": on and count > 1})
256
+ schools = [{"name": school_switch.name(entry), "entity_id": str(entry.get("idp_entity_id") or "").strip()}
257
+ for entry in school_switch.schools(config)] if on else []
258
+ return json.dumps({"on": on, "schools": schools, "group": on and len(schools) > 1,
259
+ "retry": config.get(user_settings.RETRY_KEY) is True}, ensure_ascii=False)
256
260
 
257
261
 
258
262
  @mcp_app.tool()
@@ -290,6 +294,8 @@ def school_batch_progress(
290
294
  lanes: str = "",
291
295
  held: list[dict[str, Any]] | None = None,
292
296
  held_wait: bool = False,
297
+ later: dict[str, Any] | None = None,
298
+ switch_to: str = "",
293
299
  ) -> str:
294
300
  """Update the progress window of a serial batch without downloading.
295
301
 
@@ -307,12 +313,20 @@ def school_batch_progress(
307
313
  running download of the batch too: then only the counts and this line change.
308
314
 
309
315
  held: the publishers whose papers the caller holds because their school login stopped
310
- working mid-batch, [{key (DOI prefix), name, count}]; the window shows them with a
316
+ working mid-batch, [{key (its name, else its DOI prefix), name, count}]; the window shows them with a
311
317
  button to go on. The answer's "resume" lists those the user asked to go on with since
312
318
  the last report (each once), and "stop" whether the user ended the batch in the window
313
319
  (a batch waiting for the user downloads nothing that would hear of it).
314
320
  held_wait: nothing is left but the held publishers' papers and the batch waits for the
315
321
  user (登录并继续 or 终止); the window says so, collapsed too.
322
+
323
+ later: the papers whose first try failed and that the caller tries again later, by why:
324
+ {no_access (the next saved school at the end), unexplained (once more at the end), blocked
325
+ (their site blocked them; tried again at blocked_at, epoch seconds), login (their school login
326
+ lapsed; waiting for 登录并继续), papers: {each kind: its papers' DOIs}}; the window's ring shows them
327
+ beside the papers done, and its 重试 count and list.
328
+ switch_to: the saved school the caller now tries its papers without access with; the window
329
+ names it for a few seconds.
316
330
  """
317
331
  from . import entitlements, progress_reporter
318
332
 
@@ -320,7 +334,7 @@ def school_batch_progress(
320
334
  updated = progress_reporter.sync_batch(batch_id, total, done, succeeded, failed,
321
335
  current=label, finished=finished, results=results,
322
336
  phase=phase, channel=channel, lanes=lanes, held=held,
323
- held_wait=held_wait)
337
+ held_wait=held_wait, later=later, switch_to=switch_to)
324
338
  stop = entitlements.batch_stop_requested() and (progress_reporter.read_state() or {}).get("batch_id") == batch_id
325
339
  return json.dumps({"updated": updated, "resume": entitlements.take_resumes(batch_id), "stop": bool(stop)})
326
340
 
@@ -334,9 +348,8 @@ def school_batch_papers(batch_id: str, folder: str, papers: list[dict[str, Any]]
334
348
  doi, title, journal, state ("open": open access not checked yet, "school": waiting
335
349
  for or in the institutional download, "ok", "failed"); a saved one adds via
336
350
  (开放下载 or 机构下载), detail (出版社 API, Sci-Hub, 预印本) and path (the PDF,
337
- absolute); a failed one cls (no_access, user_side, school_side, publisher_or_network,
338
- article_or_site, unsupported, unexplained)
339
- and reason}]. folder: the batch's download folder (absolute); the window opens
351
+ absolute); a failed one cls (no_access, user_side, external, unsupported, unexplained; the
352
+ classes before 2026-11-22 are taken as these) and reason}]. folder: the batch's download folder (absolute); the window opens
340
353
  a PDF only from inside it. Never touches the running download's progress.
341
354
  """
342
355
  from . import progress_reporter
@@ -81,6 +81,19 @@ def set_hourly_now(on: bool) -> None:
81
81
  _config.update_config(HOURLY_NOW_KEY, "true" if on else "false")
82
82
 
83
83
 
84
+ RETRY_KEY = "batch_retry_failed"
85
+
86
+
87
+ def retry_enabled() -> bool:
88
+ """失败后自动重试 (the 等待和提醒 page; user, 2026-11-24: off by default): a batch tries its 原因不明 papers once more at
89
+ its end, and a publisher whose site blocked it once more after a pause (download/batch/batch.ts)."""
90
+ return _config.load_config().get(RETRY_KEY) is True
91
+
92
+
93
+ def set_retry(on: bool) -> None:
94
+ _config.update_config(RETRY_KEY, "true" if on else "false")
95
+
96
+
84
97
  LANGUAGE_KEY = "progress_language"
85
98
 
86
99
 
@@ -5,6 +5,7 @@ description = "Institutional (publisher-authorized) PDF and supplementary-file d
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.11"
7
7
  license = "AGPL-3.0-only"
8
+ authors = [{ name = "Yu Xie" }]
8
9
  license-files = ["LICENSE", "LICENSE-scansci-pdf", "NOTICE"]
9
10
  # Ranges below the next major version; the browser driver is pinned (ADR 0013, 0016).
10
11
  dependencies = [