papersearch 0.8.0 → 0.8.1
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/NOTICE +1 -1
- package/README.fr.md +5 -8
- package/README.ja.md +5 -8
- package/README.ko.md +5 -8
- package/README.md +148 -151
- package/README.zh-Hant.md +5 -8
- package/README.zh.md +265 -0
- package/dist/capabilities/download/batch/batch.d.ts +4 -0
- package/dist/capabilities/download/batch/batch.d.ts.map +1 -1
- package/dist/capabilities/download/batch/batch.js +714 -198
- package/dist/capabilities/download/batch/batch.js.map +1 -1
- package/dist/capabilities/download/batch/windowPlan.d.ts +96 -0
- package/dist/capabilities/download/batch/windowPlan.d.ts.map +1 -0
- package/dist/capabilities/download/batch/windowPlan.js +196 -0
- package/dist/capabilities/download/batch/windowPlan.js.map +1 -0
- package/dist/capabilities/download/content/markdown/step.d.ts.map +1 -1
- package/dist/capabilities/download/content/markdown/step.js +4 -1
- package/dist/capabilities/download/content/markdown/step.js.map +1 -1
- package/dist/capabilities/download/content/pdf/open/tiers/scihub.d.ts.map +1 -1
- package/dist/capabilities/download/content/pdf/open/tiers/scihub.js +3 -1
- package/dist/capabilities/download/content/pdf/open/tiers/scihub.js.map +1 -1
- package/dist/infrastructure/http/hostGate.d.ts +24 -0
- package/dist/infrastructure/http/hostGate.d.ts.map +1 -0
- package/dist/infrastructure/http/hostGate.js +72 -0
- package/dist/infrastructure/http/hostGate.js.map +1 -0
- package/dist/infrastructure/pdf/PdfDownload.d.ts +1 -0
- package/dist/infrastructure/pdf/PdfDownload.d.ts.map +1 -1
- package/dist/infrastructure/pdf/PdfDownload.js +6 -1
- package/dist/infrastructure/pdf/PdfDownload.js.map +1 -1
- package/dist/infrastructure/runlog/RunLedger.d.ts +7 -0
- package/dist/infrastructure/runlog/RunLedger.d.ts.map +1 -1
- package/dist/infrastructure/runlog/RunLedger.js +17 -4
- package/dist/infrastructure/runlog/RunLedger.js.map +1 -1
- package/dist/infrastructure/school/SchoolMcpClient.d.ts +12 -2
- package/dist/infrastructure/school/SchoolMcpClient.d.ts.map +1 -1
- package/dist/infrastructure/school/SchoolMcpClient.js +122 -11
- package/dist/infrastructure/school/SchoolMcpClient.js.map +1 -1
- package/dist/infrastructure/school/SchoolReadiness.d.ts +7 -0
- package/dist/infrastructure/school/SchoolReadiness.d.ts.map +1 -1
- package/dist/infrastructure/school/SchoolReadiness.js +8 -0
- package/dist/infrastructure/school/SchoolReadiness.js.map +1 -1
- package/dist/infrastructure/school/index.d.ts +1 -1
- package/dist/infrastructure/school/index.d.ts.map +1 -1
- package/dist/infrastructure/school/types.d.ts +31 -1
- package/dist/infrastructure/school/types.d.ts.map +1 -1
- package/dist/infrastructure/school/types.js.map +1 -1
- package/dist/infrastructure/security/SecurityUtils.d.ts.map +1 -1
- package/dist/infrastructure/security/SecurityUtils.js +6 -2
- package/dist/infrastructure/security/SecurityUtils.js.map +1 -1
- 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/school/autoUpdate.d.ts.map +1 -1
- package/dist/management/school/autoUpdate.js +9 -1
- package/dist/management/school/autoUpdate.js.map +1 -1
- package/dist/management/school/cliProgress.d.ts.map +1 -1
- package/dist/management/school/cliProgress.js +3 -1
- package/dist/management/school/cliProgress.js.map +1 -1
- package/package.json +2 -2
- package/school/paper_search_school/adapters/base.py +3 -0
- package/school/paper_search_school/adapters/optica/__init__.py +50 -4
- package/school/paper_search_school/adapters/platforms/atypon/__init__.py +4 -3
- package/school/paper_search_school/adapters/platforms/figshare/__init__.py +23 -4
- package/school/paper_search_school/assets/capsule.html +380 -41
- package/school/paper_search_school/assets/capsule_en.json +72 -4
- package/school/paper_search_school/assets/capsule_fr.json +72 -4
- package/school/paper_search_school/assets/capsule_ja.json +72 -4
- package/school/paper_search_school/assets/capsule_ko.json +72 -4
- package/school/paper_search_school/assets/capsule_zh-Hant.json +66 -3
- package/school/paper_search_school/browser/backend.py +125 -4
- package/school/paper_search_school/browser/batch_session.py +188 -7
- package/school/paper_search_school/browser/challenge/continuation.py +19 -1
- package/school/paper_search_school/browser/challenge/handlers/text_captcha.py +38 -10
- package/school/paper_search_school/browser/challenge/pro.py +24 -0
- package/school/paper_search_school/browser/challenge/services/solver.py +24 -4
- package/school/paper_search_school/browser/engine.py +4 -1
- package/school/paper_search_school/browser/user_turn.py +126 -0
- package/school/paper_search_school/browser/watchdog.py +213 -60
- package/school/paper_search_school/config.py +5 -0
- package/school/paper_search_school/engine/batch.py +9 -7
- package/school/paper_search_school/engine/batch_access.py +27 -7
- package/school/paper_search_school/engine/batch_capture.py +45 -13
- package/school/paper_search_school/engine/batch_institution.py +14 -0
- package/school/paper_search_school/engine/batch_login.py +177 -22
- package/school/paper_search_school/engine/batch_user.py +48 -3
- package/school/paper_search_school/engine/batch_waits.py +42 -2
- package/school/paper_search_school/engine/bridge.py +1 -2
- package/school/paper_search_school/engine/fulltext_page.py +10 -1
- package/school/paper_search_school/engine/supplements.py +7 -1
- package/school/paper_search_school/entitlements.py +28 -0
- package/school/paper_search_school/progress_capsule.py +33 -5
- package/school/paper_search_school/progress_reporter.py +189 -6
- package/school/paper_search_school/progress_view.py +142 -48
- package/school/paper_search_school/rate_limit.py +24 -1
- package/school/paper_search_school/school_login.py +170 -8
- package/school/paper_search_school/server.py +164 -19
- package/school/paper_search_school/user_settings.py +33 -4
- package/skills/paper-search/SKILL.md +1 -1
- package/skills/paper-search/references/browser-download.md +2 -2
- package/LICENSE-paper-search-mcp-nodejs +0 -24
- package/README.en.md +0 -268
|
@@ -92,7 +92,7 @@ def school_status(entity_id: str, pro: Any | None = None) -> str:
|
|
|
92
92
|
# What the settings page reads of each school: the area (a US state, a UK nation) and kind (university, research
|
|
93
93
|
# institute, hospital) split the big countries (Pro 0.3.1; an older Pro has neither, "" there).
|
|
94
94
|
#: key: its entityID (添加学校 adds a school found in this list by it; "" from an older Pro).
|
|
95
|
-
SCHOOL_FIELDS = ("key", "name", "name_en", "country", "province", "area", "kind", "status")
|
|
95
|
+
SCHOOL_FIELDS = ("key", "name", "name_en", "country", "province", "area", "kind", "status", "entry", "app")
|
|
96
96
|
|
|
97
97
|
|
|
98
98
|
def school_list(pro: Any | None = None) -> list[dict[str, Any]]:
|
|
@@ -125,10 +125,30 @@ def school_counts(pro: Any | None = None) -> dict[str, int]:
|
|
|
125
125
|
return {}
|
|
126
126
|
|
|
127
127
|
|
|
128
|
+
def entry_for(entity_id: str, pro: Any | None = None) -> dict:
|
|
129
|
+
"""Optional Pro metadata; older Pro versions retain the existing filling policy."""
|
|
130
|
+
pro = pro if pro is not None else module()
|
|
131
|
+
hook = getattr(pro, "school_entry", None)
|
|
132
|
+
value = hook(entity_id) if callable(hook) else None
|
|
133
|
+
return value if isinstance(value, dict) and value.get("entry") in {"qr_only", "sms_only", "check_first"} else {}
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
def entry_notice(entry: dict) -> str:
|
|
137
|
+
if entry.get("entry") == "sms_only":
|
|
138
|
+
return "学校登录页只能用短信验证码登录,请在浏览器窗口完成。"
|
|
139
|
+
if entry.get("sms_alternative"):
|
|
140
|
+
return "学校登录页需要扫码或短信验证,请在浏览器窗口完成。"
|
|
141
|
+
app = str(entry.get("app") or "学校的 App")
|
|
142
|
+
if app not in {"微信", "企业微信", "钉钉"}:
|
|
143
|
+
app = "学校的 App"
|
|
144
|
+
return f"学校登录页只能用{app}扫码登录,没有账号密码可填,请在浏览器窗口扫码。"
|
|
145
|
+
|
|
146
|
+
|
|
128
147
|
def fills_for(entity_id: str, pro: Any | None = None) -> bool:
|
|
129
|
-
"""Whether Pro fills this school's sign-in in:
|
|
130
|
-
|
|
131
|
-
|
|
148
|
+
"""Whether Pro fills this school's sign-in in: every school once Pro is there, tested or not (user, 2026-11-28:
|
|
149
|
+
a school our tests could not pass may well work from the user's own network; what keeps it from being filled in
|
|
150
|
+
is found on its page and told, not decided in advance by the lists, which now only say whether it was tested)."""
|
|
151
|
+
return pro is not None and bool(str(entity_id or "").strip())
|
|
132
152
|
|
|
133
153
|
|
|
134
154
|
# -- the account ------------------------------------------------------------------------------
|
|
@@ -169,11 +189,27 @@ def save(entity_id: str, username: str, password: str, *, enabled: bool = True)
|
|
|
169
189
|
raise ValueError("请填写密码")
|
|
170
190
|
logins = dict(_logins(current))
|
|
171
191
|
logins[entity_id] = {"username": username, "password": password, "enabled": bool(enabled), "off": "",
|
|
172
|
-
"saved": time.strftime("%Y-%m-%d %H:%M")
|
|
192
|
+
"saved": time.strftime("%Y-%m-%d %H:%M"),
|
|
193
|
+
# The way chosen on its sign-in chooser stays while the school does (set_way).
|
|
194
|
+
**({"way": str(entry["way"])} if entry.get("way") else {})}
|
|
173
195
|
current[CONFIG_KEY] = logins
|
|
174
196
|
cfg.save_config(current)
|
|
175
197
|
|
|
176
198
|
|
|
199
|
+
def set_way(entity_id: str, way: str) -> None:
|
|
200
|
+
"""The way the user chose on the school's sign-in chooser (OpenAthens's "Choose how to sign in", in the progress
|
|
201
|
+
window; user 2026-11-29), pressed again from then on: kept with its account until the school is cleared."""
|
|
202
|
+
from . import config as cfg
|
|
203
|
+
|
|
204
|
+
current = cfg.load_config()
|
|
205
|
+
logins = dict(_logins(current))
|
|
206
|
+
entry = logins.get(entity_id)
|
|
207
|
+
if isinstance(entry, dict) and str(way or "").strip():
|
|
208
|
+
logins[entity_id] = {**entry, "way": str(way).strip()}
|
|
209
|
+
current[CONFIG_KEY] = logins
|
|
210
|
+
cfg.save_config(current)
|
|
211
|
+
|
|
212
|
+
|
|
177
213
|
def clear(entity_id: str) -> None:
|
|
178
214
|
from . import config as cfg
|
|
179
215
|
|
|
@@ -199,15 +235,19 @@ def turn_off(entity_id: str, why: str) -> None:
|
|
|
199
235
|
|
|
200
236
|
# -- where and how often ----------------------------------------------------------------------
|
|
201
237
|
|
|
202
|
-
def may_fill(url: str, config: dict[str, Any], also: tuple[str, ...] = ()) -> bool:
|
|
238
|
+
def may_fill(url: str, config: dict[str, Any], also: tuple[str, ...] = (), plain: tuple[str, ...] = ()) -> bool:
|
|
203
239
|
"""An https page of the school's own: one of its login hosts as its federation lists them,
|
|
204
240
|
or under its own domains. Hosts merely passed through in a batch never count. ``also``: the
|
|
205
241
|
hosts Pro has for this school's login page on another domain of its own (Pro's ``login_hosts``,
|
|
206
|
-
found by its survey: a login system that sends to a login page on a second domain of the school's).
|
|
242
|
+
found by its survey: a login system that sends to a login page on a second domain of the school's).
|
|
243
|
+
``plain``: the hosts Pro has for a login page the school serves on plain http only (Pro's
|
|
244
|
+
``plain_hosts``: its survey filled it in there; user, 2026-11-28): on http, those exact hosts only."""
|
|
207
245
|
from .schools import lookup
|
|
208
246
|
|
|
209
247
|
parsed = urlparse(str(url or ""))
|
|
210
248
|
host = (parsed.hostname or "").lower()
|
|
249
|
+
if parsed.scheme == "http" and host and host in {str(h).strip().lower() for h in plain}:
|
|
250
|
+
return True
|
|
211
251
|
if parsed.scheme != "https" or not host:
|
|
212
252
|
return False
|
|
213
253
|
if host in set(lookup.login_hosts(config)) or host in {str(h).lower() for h in also}:
|
|
@@ -215,6 +255,36 @@ def may_fill(url: str, config: dict[str, Any], also: tuple[str, ...] = ()) -> bo
|
|
|
215
255
|
return any(host == domain or host.endswith("." + domain) for domain in lookup.domains(config))
|
|
216
256
|
|
|
217
257
|
|
|
258
|
+
#: Login services many schools sign in at (user, 2026-11-28): a school's page when, in this sign-in, the hop just before
|
|
259
|
+
#: it was the school's own login server, or a shared service this sign-in already counts as the school's (user,
|
|
260
|
+
#: 2026-11-30: Microsoft's page sending the account on to the school's Okta); never when reached from anywhere else.
|
|
261
|
+
SHARED_LOGIN_HOSTS = ("login.microsoftonline.com", "login.microsoft.com", "accounts.google.com")
|
|
262
|
+
SHARED_LOGIN_SUFFIXES = (".okta.com", ".okta-emea.com")
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
def shared_login_host(url: str) -> str:
|
|
266
|
+
"""The host of ``url`` when it is one of the shared login services on https, else ""."""
|
|
267
|
+
parsed = urlparse(str(url or ""))
|
|
268
|
+
host = (parsed.hostname or "").lower()
|
|
269
|
+
if parsed.scheme == "https" and (host in SHARED_LOGIN_HOSTS or host.endswith(SHARED_LOGIN_SUFFIXES)):
|
|
270
|
+
return host
|
|
271
|
+
return ""
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
def note_shared_login(previous_host: str, url: str, config: dict[str, Any], also: tuple[str, ...], seen: set) -> None:
|
|
275
|
+
"""A main-frame hop to a shared login service (``url``) straight from the school's own login server
|
|
276
|
+
(``previous_host``: one of its registered hosts or domains, ``may_fill``'s), or from a shared service already in
|
|
277
|
+
``seen``: that service's host added to ``seen``, the hosts this sign-in may fill in on too (two schools,
|
|
278
|
+
2026-11-28: their Shibboleth sends to Microsoft's login page; a school, 2026-11-30:
|
|
279
|
+
Microsoft's page sends the account on to the school's Okta)."""
|
|
280
|
+
shared = shared_login_host(url)
|
|
281
|
+
previous = str(previous_host or "").lower()
|
|
282
|
+
if not shared or not previous:
|
|
283
|
+
return
|
|
284
|
+
if previous in seen or (not shared_login_host(f"https://{previous}/") and may_fill(f"https://{previous}/", config, also)):
|
|
285
|
+
seen.add(shared)
|
|
286
|
+
|
|
287
|
+
|
|
218
288
|
def pro_login_hosts(pro: Any, entity_id: str) -> tuple[str, ...]:
|
|
219
289
|
"""Pro's hosts for this school's login page on another domain of its own (``may_fill``'s ``also``);
|
|
220
290
|
none from a Pro without them."""
|
|
@@ -225,6 +295,16 @@ def pro_login_hosts(pro: Any, entity_id: str) -> tuple[str, ...]:
|
|
|
225
295
|
return ()
|
|
226
296
|
|
|
227
297
|
|
|
298
|
+
def pro_plain_hosts(pro: Any, entity_id: str) -> tuple[str, ...]:
|
|
299
|
+
"""Pro's hosts for this school's login page on plain http (``may_fill``'s ``plain``); none from a
|
|
300
|
+
Pro without them."""
|
|
301
|
+
hosts = getattr(pro, "plain_hosts", None)
|
|
302
|
+
try:
|
|
303
|
+
return tuple(str(h).strip().lower() for h in (hosts(entity_id) if callable(hosts) else ()) if str(h).strip())
|
|
304
|
+
except Exception:
|
|
305
|
+
return ()
|
|
306
|
+
|
|
307
|
+
|
|
228
308
|
# -- a login page whose certificate has expired or is not trusted ---------------------------------
|
|
229
309
|
# Some schools' login pages serve a certificate Chrome will not take (one ran out in 2022;
|
|
230
310
|
# others are issued by an authority Chrome does not trust): Chrome stops at its warning. For those
|
|
@@ -250,6 +330,9 @@ def page_certificate(page: Any, wait: float = 2.0) -> tuple[str, str]:
|
|
|
250
330
|
import base64
|
|
251
331
|
import hashlib
|
|
252
332
|
|
|
333
|
+
from .browser import watchdog
|
|
334
|
+
watchdog.install()
|
|
335
|
+
|
|
253
336
|
try:
|
|
254
337
|
session = page.context.new_cdp_session(page)
|
|
255
338
|
except Exception:
|
|
@@ -265,7 +348,12 @@ def page_certificate(page: Any, wait: float = 2.0) -> tuple[str, str]:
|
|
|
265
348
|
return "?", ""
|
|
266
349
|
finally:
|
|
267
350
|
try:
|
|
268
|
-
|
|
351
|
+
# 2026-11-27: CDP detach after a certificate warning can never reply.
|
|
352
|
+
# The certificate was already read; only abandon the optional cleanup.
|
|
353
|
+
with watchdog.call_limit(1.0):
|
|
354
|
+
session.detach()
|
|
355
|
+
except watchdog.CallAbandoned:
|
|
356
|
+
log.warning("Certificate session cleanup timed out; browser context will release it")
|
|
269
357
|
except Exception:
|
|
270
358
|
pass
|
|
271
359
|
if not seen:
|
|
@@ -389,11 +477,85 @@ class Attempt:
|
|
|
389
477
|
#: Set by Pro on ``needs_user``: the kind of check the school's page asks the user for (image_code,
|
|
390
478
|
#: slider, click_select, sms_code, qr_scan, site_check, second_factor), for the note the user reads.
|
|
391
479
|
asks: str = ""
|
|
480
|
+
strict_reply: bool = False
|
|
481
|
+
blocked_entry: dict = field(default_factory=dict)
|
|
482
|
+
#: Transport only: image bytes and task options; Pro owns reading and retry rules.
|
|
483
|
+
ask_code: Callable[..., str] | None = field(default=None, repr=False)
|
|
484
|
+
#: A reCAPTCHA, hCaptcha or Turnstile box on the school's page passed by the publishers' handlers (check_passer);
|
|
485
|
+
#: Pro calls it with the page, True when the box holds its token. None without a verification service.
|
|
486
|
+
pass_check: Callable[[Any], bool] | None = field(default=None, repr=False)
|
|
487
|
+
#: A sign-in chooser on the way (OpenAthens's "Choose how to sign in"; user, 2026-11-29): the way chosen for this
|
|
488
|
+
#: school before (pressed again), the user asked in the progress window (the ways' names and whether the chooser
|
|
489
|
+
#: is still up -> the way's index, -1 once pressed in the browser itself, None when not chosen), the choice kept.
|
|
490
|
+
way: str = ""
|
|
491
|
+
choose_way: Callable[[list[str], Callable[[], bool]], int | None] | None = field(default=None, repr=False)
|
|
492
|
+
remember_way: Callable[[str], None] | None = field(default=None, repr=False)
|
|
392
493
|
|
|
393
494
|
def __repr__(self) -> str: # never the account, not even in a traceback's locals
|
|
394
495
|
return "Attempt(<hidden>)"
|
|
395
496
|
|
|
396
497
|
|
|
498
|
+
#: How long the verification service may take over one box on a school's sign-in page.
|
|
499
|
+
SCHOOL_CHECK_SEC = 90.0
|
|
500
|
+
#: A passed box's token, in the page's form (reCAPTCHA, hCaptcha, Turnstile).
|
|
501
|
+
_CHECK_TOKEN_JS = """() => [...document.querySelectorAll('[name="g-recaptcha-response"], [name="h-captcha-response"], '
|
|
502
|
+
+ '[name="cf-turnstile-response"]')].some(el => (el.value || '').length > 20)"""
|
|
503
|
+
|
|
504
|
+
|
|
505
|
+
def check_passer(config: dict[str, Any], budget: Any, note: Callable[[str], None],
|
|
506
|
+
checkpoint: Callable[[], None] | None = None) -> Callable[[Any], bool] | None:
|
|
507
|
+
"""The publishers' verification handlers for a reCAPTCHA, hCaptcha or Turnstile box on the school's own sign-in
|
|
508
|
+
page (user, 2026-11-28: a school's page passed as a publisher's is): its checkbox pressed, a picture grid read by
|
|
509
|
+
the user's verification service, until the box holds its token or SCHOOL_CHECK_SEC. Pro's sign-in calls it before
|
|
510
|
+
filling in or once pressed. None when the user has no verification service: the box is the user's, told so."""
|
|
511
|
+
from .browser.challenge.continuation import Expired, Limits, resume
|
|
512
|
+
from .browser.challenge.local import interaction
|
|
513
|
+
from .browser.challenge.services import solver
|
|
514
|
+
|
|
515
|
+
if not solver.configured(config):
|
|
516
|
+
return None
|
|
517
|
+
|
|
518
|
+
def holds_token(page: Any) -> bool:
|
|
519
|
+
for frame in list(getattr(page, "frames", []) or []):
|
|
520
|
+
try:
|
|
521
|
+
if frame.evaluate(_CHECK_TOKEN_JS):
|
|
522
|
+
return True
|
|
523
|
+
except Exception:
|
|
524
|
+
continue
|
|
525
|
+
return False
|
|
526
|
+
|
|
527
|
+
def pass_check(page: Any) -> bool:
|
|
528
|
+
from contextlib import ExitStack
|
|
529
|
+
|
|
530
|
+
kind = interaction.challenge_kind(page)
|
|
531
|
+
if kind not in ("recaptcha", "hcaptcha", "turnstile"):
|
|
532
|
+
note(f"{kind or 'unknown'}: not a box the service passes")
|
|
533
|
+
return False
|
|
534
|
+
deadline = time.monotonic() + SCHOOL_CHECK_SEC
|
|
535
|
+
stop = checkpoint or (lambda: None)
|
|
536
|
+
with ExitStack() as cleanup:
|
|
537
|
+
limits = Limits(deadline, budget if budget is not None else solver.Budget(config=config), stop, cleanup)
|
|
538
|
+
try:
|
|
539
|
+
outcome = interaction.click_checkbox(page, timeout_ms=8_000, checkpoint=stop, observation=note)
|
|
540
|
+
note(f"{kind}: box {outcome}")
|
|
541
|
+
for _ in range(6):
|
|
542
|
+
if holds_token(page):
|
|
543
|
+
return True
|
|
544
|
+
page.wait_for_timeout(500)
|
|
545
|
+
resume(page, config, kind=kind, limits=limits, observation=note)
|
|
546
|
+
while time.monotonic() < deadline:
|
|
547
|
+
if holds_token(page):
|
|
548
|
+
return True
|
|
549
|
+
page.wait_for_timeout(500)
|
|
550
|
+
except Expired:
|
|
551
|
+
pass
|
|
552
|
+
passed = holds_token(page)
|
|
553
|
+
note(f"{kind}: {'passed' if passed else 'not passed'}")
|
|
554
|
+
return passed
|
|
555
|
+
|
|
556
|
+
return pass_check
|
|
557
|
+
|
|
558
|
+
|
|
397
559
|
def hide(text: str, secrets: tuple[str, ...]) -> str:
|
|
398
560
|
"""``text`` with every secret replaced (an event's detail, defence in depth)."""
|
|
399
561
|
for secret in secrets:
|
|
@@ -8,6 +8,8 @@ Contract (see PaperSearch docs/dependencies/school-backend.zh.md):
|
|
|
8
8
|
(use_vpnsci is still accepted from older callers and ignored)
|
|
9
9
|
-> school_batch_progress(batch_id, total, done, succeeded, failed, current, finished)
|
|
10
10
|
optional: keeps the progress window on "k / N" for a caller's serial batch
|
|
11
|
+
-> school_download(..., keep_browser=true, window=k, parallel=true): a batch downloading several papers at once,
|
|
12
|
+
each in a window of its own of the one browser (并行下载); school_close_window(k) when one is no longer needed
|
|
11
13
|
|
|
12
14
|
Tool names carry the ``school_`` prefix; ``serverInfo.name`` is ``paper-search-school``.
|
|
13
15
|
Every fetched page and tool result is untrusted external content.
|
|
@@ -17,6 +19,7 @@ from __future__ import annotations
|
|
|
17
19
|
import asyncio
|
|
18
20
|
import json
|
|
19
21
|
import re
|
|
22
|
+
import threading
|
|
20
23
|
import time
|
|
21
24
|
from functools import partial
|
|
22
25
|
from typing import Any, Literal
|
|
@@ -50,16 +53,109 @@ _DOI_RE = re.compile(r"10\.\d{4,9}/[-._;()/:A-Z0-9]+", re.I)
|
|
|
50
53
|
_batch_browser = BatchBrowser()
|
|
51
54
|
# Its tab answers between papers too (BatchThread, BatchBrowser.pump).
|
|
52
55
|
_batch_worker = BatchThread(_batch_browser.pump)
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
56
|
+
# 并行下载 (user, 2026-11-29): a batch's other windows, each with its browser connection and its thread (1, 2, ...).
|
|
57
|
+
_other_windows: dict[int, tuple[BatchBrowser, BatchThread]] = {}
|
|
58
|
+
_windows_lock = threading.Lock()
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def _window(window: int | None) -> tuple[BatchBrowser, BatchThread]:
|
|
62
|
+
"""The batch's window ``window`` (0 or None: the first, which launches the browser) and its thread."""
|
|
63
|
+
if not window or window < 0:
|
|
64
|
+
return _batch_browser, _batch_worker
|
|
65
|
+
with _windows_lock:
|
|
66
|
+
found = _other_windows.get(window)
|
|
67
|
+
if found is None:
|
|
68
|
+
browser = BatchBrowser(window, first=_batch_browser)
|
|
69
|
+
found = _other_windows[window] = (browser, BatchThread(browser.pump, name=f"school-batch-{window}"))
|
|
70
|
+
return found
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def _close_other_windows() -> None:
|
|
74
|
+
"""The other windows' drivers leave, each on its own thread, before the first window's browser closes."""
|
|
75
|
+
with _windows_lock:
|
|
76
|
+
others = list(_other_windows.values())
|
|
77
|
+
_other_windows.clear()
|
|
78
|
+
for browser, worker in others:
|
|
79
|
+
try:
|
|
80
|
+
worker.submit(browser.disconnect).result(timeout=60)
|
|
81
|
+
except Exception:
|
|
82
|
+
pass
|
|
83
|
+
worker.shutdown(wait=False)
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def _close_batch_browser() -> None:
|
|
87
|
+
"""On the first window's thread: every window of the batch closed, its downloads' folder removed."""
|
|
88
|
+
from .browser.batch_session import forget_downloads
|
|
89
|
+
|
|
90
|
+
_close_other_windows()
|
|
91
|
+
downloads = _batch_browser.downloads
|
|
92
|
+
_batch_browser.close()
|
|
93
|
+
_batch_browser.downloads = ""
|
|
94
|
+
_batch_browser.parallel = False
|
|
95
|
+
if downloads:
|
|
96
|
+
forget_downloads(downloads)
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def _parallel_batch(parallel: bool, window_given: bool) -> bool:
|
|
100
|
+
"""Whether a batch beginning runs its papers at once: its client says so, or, its first paper coming in a window
|
|
101
|
+
before the client knows (``window_given``), the settings' 同时下载 says so and the browser can have windows."""
|
|
102
|
+
if parallel:
|
|
103
|
+
return True
|
|
104
|
+
if not window_given:
|
|
105
|
+
return False
|
|
106
|
+
from . import user_settings
|
|
107
|
+
from .browser.backend import supports
|
|
108
|
+
|
|
109
|
+
numbers = user_settings.parallel()
|
|
110
|
+
return numbers["publishers"] * numbers["per_publisher"] > 1 and supports("parallel_windows", load_config())
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def _with_batch_browser(batch_id: str, operation, window: int | None = None, parallel: bool = False,
|
|
114
|
+
window_given: bool = False) -> str:
|
|
115
|
+
"""``operation`` in the batch's window ``window`` (on that window's thread): its browser the one the engine uses
|
|
116
|
+
(``active_batch``), and, for a batch whose papers run at once (decided at its first download, ``_parallel_batch``),
|
|
117
|
+
the window that takes turns asking for the user and keeps its paper on the progress card."""
|
|
118
|
+
from . import progress_reporter
|
|
119
|
+
from .browser import user_turn, watchdog
|
|
120
|
+
|
|
121
|
+
with _windows_lock:
|
|
122
|
+
another = _batch_browser.id != batch_id
|
|
123
|
+
if another:
|
|
124
|
+
# One batch's windows at a time: the next batch's first download closes the last one's (the client
|
|
125
|
+
# closes them at a batch's end, and a batch is one backend process: this is the exception).
|
|
126
|
+
# The last batch's browser, or a window's connection to it, still there. Not this batch's windows taken
|
|
127
|
+
# just now for their threads (school_download, ``_window``): window 1 coming in before window 0 took its
|
|
128
|
+
# own for the last batch's, left the batch not running papers at once and waited on window 0's thread to
|
|
129
|
+
# close it, busy with the first paper. Window 0 then opened Chrome for one paper after another, with no
|
|
130
|
+
# remote-debugging port; windows 2 to 5 waited 180 s to join it and failed (Windows, 2026-11-30).
|
|
131
|
+
open_before = _batch_browser.context is not None or any(
|
|
132
|
+
browser.context is not None for browser, _ in _other_windows.values())
|
|
133
|
+
_batch_browser.id = batch_id
|
|
134
|
+
at_once = _parallel_batch(parallel, window_given)
|
|
135
|
+
if not open_before:
|
|
136
|
+
_batch_browser.parallel = at_once
|
|
137
|
+
if another:
|
|
138
|
+
if open_before:
|
|
139
|
+
if window:
|
|
140
|
+
_batch_worker.submit(_close_batch_browser).result()
|
|
141
|
+
else:
|
|
142
|
+
_close_batch_browser()
|
|
143
|
+
_batch_browser.parallel = at_once
|
|
144
|
+
user_turn.start(at_once)
|
|
145
|
+
browser, _ = _window(window)
|
|
146
|
+
# A call of this window's last paper ran past its time and ended that paper alone (browser/watchdog.py): the
|
|
147
|
+
# next one here starts on a page of its own.
|
|
148
|
+
if watchdog.in_window(_batch_browser.parallel):
|
|
149
|
+
browser.page = None
|
|
150
|
+
token = active_batch.set(browser)
|
|
151
|
+
turn = user_turn.bind(window or 0)
|
|
152
|
+
shown = progress_reporter.bind_window((window or 0) if _batch_browser.parallel else None)
|
|
60
153
|
try:
|
|
61
154
|
return operation()
|
|
62
155
|
finally:
|
|
156
|
+
user_turn.release_all()
|
|
157
|
+
progress_reporter.unbind_window(shown)
|
|
158
|
+
user_turn.unbind(turn)
|
|
63
159
|
active_batch.reset(token)
|
|
64
160
|
|
|
65
161
|
|
|
@@ -173,6 +269,8 @@ async def _school_download_with_progress(
|
|
|
173
269
|
title: str | None = None,
|
|
174
270
|
fulltext: Literal["with", "only"] | None = None,
|
|
175
271
|
school: str | None = None,
|
|
272
|
+
window: int | None = None,
|
|
273
|
+
parallel: bool = False,
|
|
176
274
|
ctx: Context = None,
|
|
177
275
|
) -> str:
|
|
178
276
|
"""Download one paper by DOI through institutional access only.
|
|
@@ -211,6 +309,12 @@ async def _school_download_with_progress(
|
|
|
211
309
|
user_wait: "short" when the user seems away (an earlier article of the batch waited on them
|
|
212
310
|
until its time was up): each wait on the user (school login, human verification) lasts at
|
|
213
311
|
most 60 s, unless someone starts typing on the login page.
|
|
312
|
+
|
|
313
|
+
window, parallel (并行下载): with keep_browser, a batch downloading several papers at once
|
|
314
|
+
(parallel=true on each of its downloads) runs each in its window ``window`` (0, 1, 2 …) of the
|
|
315
|
+
one browser, every window with a driver and a thread of its own; window 0 launches the browser.
|
|
316
|
+
One window at a time asks for the user (school login, a verification to complete); the others
|
|
317
|
+
go on meanwhile. school_close_window closes a window no longer needed.
|
|
214
318
|
"""
|
|
215
319
|
from .mcp_progress import run_with_progress
|
|
216
320
|
|
|
@@ -220,25 +324,47 @@ async def _school_download_with_progress(
|
|
|
220
324
|
batch_failed=batch_failed, supplements=supplements, user_wait=user_wait,
|
|
221
325
|
diagnostics_dir=diagnostics_dir, title=title, fulltext=fulltext, school=school)
|
|
222
326
|
if keep_browser and batch_id:
|
|
223
|
-
|
|
224
|
-
|
|
327
|
+
given = isinstance(window, int) and not isinstance(window, bool)
|
|
328
|
+
number = window if given and window > 0 else 0
|
|
329
|
+
return await run_with_progress(ctx, identifier, partial(_with_batch_browser, batch_id, operation, number,
|
|
330
|
+
bool(parallel), given),
|
|
331
|
+
executor=_window(number)[1])
|
|
225
332
|
return await run_with_progress(ctx, identifier, operation)
|
|
226
333
|
|
|
227
334
|
|
|
228
335
|
@mcp_app.tool()
|
|
229
336
|
async def school_close_batch_browser() -> str:
|
|
230
|
-
"""Close the window retained by this client's serial download batch
|
|
231
|
-
|
|
337
|
+
"""Close the window retained by this client's serial download batch (every window of a batch whose papers ran at
|
|
338
|
+
once)."""
|
|
339
|
+
await asyncio.get_running_loop().run_in_executor(_batch_worker, _close_batch_browser)
|
|
340
|
+
return json.dumps({"closed": True})
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
@mcp_app.tool()
|
|
344
|
+
async def school_close_window(window: int) -> str:
|
|
345
|
+
"""并行下载: close window ``window`` (1, 2 …) of a batch whose papers run at once, no longer needed (fewer
|
|
346
|
+
publishers left than its windows): its pages go, its driver stays until the batch ends. The first window, which
|
|
347
|
+
holds the browser, stays open. Answers {"closed": bool}."""
|
|
348
|
+
if not isinstance(window, int) or isinstance(window, bool) or window <= 0:
|
|
349
|
+
return json.dumps({"closed": False})
|
|
350
|
+
with _windows_lock:
|
|
351
|
+
found = _other_windows.get(window)
|
|
352
|
+
if found is None:
|
|
353
|
+
return json.dumps({"closed": False})
|
|
354
|
+
browser, worker = found
|
|
355
|
+
await asyncio.get_running_loop().run_in_executor(worker, browser.close)
|
|
232
356
|
return json.dumps({"closed": True})
|
|
233
357
|
|
|
234
358
|
|
|
235
359
|
@mcp_app.tool()
|
|
236
|
-
async def school_keep_session() -> str:
|
|
360
|
+
async def school_keep_session(window: int = 0) -> str:
|
|
237
361
|
"""While a serial batch waits (the publisher's hourly limit the user set), load the
|
|
238
|
-
last paper's article page again in the batch's window
|
|
239
|
-
institutional session does not lapse. Opens no
|
|
240
|
-
that did not save its PDF. Answers {"kept": true} or
|
|
241
|
-
|
|
362
|
+
last paper's article page again in the batch's window (``window`` of a batch whose
|
|
363
|
+
papers run at once), so the publisher's institutional session does not lapse. Opens no
|
|
364
|
+
browser; does nothing after a paper that did not save its PDF. Answers {"kept": true} or
|
|
365
|
+
{"kept": false, "reason": ...}."""
|
|
366
|
+
browser, worker = _window(window if isinstance(window, int) and not isinstance(window, bool) else 0)
|
|
367
|
+
result = await asyncio.get_running_loop().run_in_executor(worker, browser.keep_session)
|
|
242
368
|
return json.dumps(result)
|
|
243
369
|
|
|
244
370
|
|
|
@@ -248,7 +374,8 @@ def school_switch_state() -> str:
|
|
|
248
374
|
(没权限时换下一所学校, school_switch.py): the default one first, each named as ``school_download``'s ``school``
|
|
249
375
|
takes it (its entityID); none while the switch is off; and whether the batch takes one journal's papers one after
|
|
250
376
|
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
|
|
377
|
+
browser. Answers {"on": bool, "schools": [{"name": ..., "entity_id": ...}, ...], "group": bool, "retry": bool,
|
|
378
|
+
"parallel": {"publishers": n, "per_publisher": n, "prefixes": {DOI prefix: publisher}}} (同时下载, _parallel_state)."""
|
|
252
379
|
from . import school_switch, user_settings
|
|
253
380
|
|
|
254
381
|
config = load_config()
|
|
@@ -256,7 +383,25 @@ def school_switch_state() -> str:
|
|
|
256
383
|
schools = [{"name": school_switch.name(entry), "entity_id": str(entry.get("idp_entity_id") or "").strip()}
|
|
257
384
|
for entry in school_switch.schools(config)] if on else []
|
|
258
385
|
return json.dumps({"on": on, "schools": schools, "group": on and len(schools) > 1,
|
|
259
|
-
"retry": config.get(user_settings.RETRY_KEY) is True
|
|
386
|
+
"retry": config.get(user_settings.RETRY_KEY) is True, "parallel": _parallel_state(config)},
|
|
387
|
+
ensure_ascii=False)
|
|
388
|
+
|
|
389
|
+
|
|
390
|
+
def _parallel_state(config: dict[str, Any]) -> dict[str, Any]:
|
|
391
|
+
"""同时下载 (the settings' 下载 page): publishers at once and papers of one publisher at once, 1 and 1 when serial
|
|
392
|
+
or when the browser cannot have a window for each (only Chrome launched by the backend can); and each DOI prefix's
|
|
393
|
+
publisher by the backend's table, so that the batch counts one publisher's prefixes as one (Springer Nature's
|
|
394
|
+
10.1007, 10.1038, 10.1186)."""
|
|
395
|
+
from . import user_settings
|
|
396
|
+
from .browser.backend import supports
|
|
397
|
+
from .publishers.profiles import PUBLISHER_PROFILES
|
|
398
|
+
|
|
399
|
+
serial = {"publishers": 1, "per_publisher": 1}
|
|
400
|
+
numbers = user_settings.parallel() if supports("parallel_windows", config) else serial
|
|
401
|
+
if _batch_browser.id and not _batch_browser.parallel:
|
|
402
|
+
numbers = serial # the batch's browser opened for one paper after another: it goes on so
|
|
403
|
+
prefixes = {prefix: profile.name for profile in PUBLISHER_PROFILES.values() for prefix in profile.doi_prefixes}
|
|
404
|
+
return {**numbers, "prefixes": prefixes}
|
|
260
405
|
|
|
261
406
|
|
|
262
407
|
@mcp_app.tool()
|
|
@@ -384,7 +529,7 @@ def main() -> None:
|
|
|
384
529
|
mcp_app.run()
|
|
385
530
|
finally:
|
|
386
531
|
try:
|
|
387
|
-
_batch_worker.submit(
|
|
532
|
+
_batch_worker.submit(_close_batch_browser).result()
|
|
388
533
|
finally:
|
|
389
534
|
_batch_worker.shutdown()
|
|
390
535
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"""The progress window's wait limits, page inactivity reminder delay,
|
|
2
|
-
|
|
1
|
+
"""The progress window's wait limits, page inactivity reminder delay, publisher
|
|
2
|
+
hourly limit and parallel downloads. Saved values apply to subsequent papers."""
|
|
3
3
|
|
|
4
4
|
from __future__ import annotations
|
|
5
5
|
|
|
@@ -15,9 +15,9 @@ class Field:
|
|
|
15
15
|
key: str # the backend's config key
|
|
16
16
|
default: int
|
|
17
17
|
low: int
|
|
18
|
-
high: int
|
|
18
|
+
high: int | None # None: no upper bound
|
|
19
19
|
unit: str
|
|
20
|
-
page: str # the settings page it is on: "download" or "wait"
|
|
20
|
+
page: str # the settings page it is on: "download" or "wait"; "parallel" for 同时下载's two numbers (download page)
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
FIELDS = (
|
|
@@ -25,6 +25,10 @@ FIELDS = (
|
|
|
25
25
|
Field("page", "其他页面最多等", "browser_page_wait_timeout", 60, 10, 600, "秒", "wait"),
|
|
26
26
|
Field("stalled", "提醒你操作前最多等", "browser_stall_notify_after", 30, 1, 600, "秒", "wait"),
|
|
27
27
|
Field("hourly", "每家出版社每小时最多", "publisher_hourly_limit", 100, 0, 1000, "篇", "download"),
|
|
28
|
+
# 同时下载 when parallel (user, 2026-11-29): publishers at once and papers of one publisher at once; at least 1, no
|
|
29
|
+
# upper bound (the user: none set), 1 by default. Shown on the 下载 page under 同时下载, not as rows of their own.
|
|
30
|
+
Field("pubs", "不同出版社", "batch_parallel_publishers", 1, 1, None, "家", "parallel"),
|
|
31
|
+
Field("each", "同一出版社", "batch_parallel_per_publisher", 1, 1, None, "篇", "parallel"),
|
|
28
32
|
)
|
|
29
33
|
|
|
30
34
|
|
|
@@ -40,6 +44,10 @@ def check(field: Field, text: str) -> tuple[int | None, str]:
|
|
|
40
44
|
value = int(str(text).strip())
|
|
41
45
|
except ValueError:
|
|
42
46
|
value = None
|
|
47
|
+
if field.high is None:
|
|
48
|
+
if value is None or value < field.low:
|
|
49
|
+
return None, f"请输入不小于 {field.low} 的整数"
|
|
50
|
+
return value, ""
|
|
43
51
|
if value is None or not field.low <= value <= field.high:
|
|
44
52
|
return None, f"请输入 {field.low} 到 {field.high} 之间的整数"
|
|
45
53
|
return value, ""
|
|
@@ -110,3 +118,24 @@ def set_language(lang: str) -> None:
|
|
|
110
118
|
|
|
111
119
|
_config.update_config(LANGUAGE_KEY, lang if lang in i18n.LANGUAGES else "zh")
|
|
112
120
|
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
PARALLEL_KEY = "batch_parallel"
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
def parallel_enabled() -> bool:
|
|
127
|
+
"""同时下载 (the 下载 page; user, 2026-11-29: serial by default): a batch's browser lane downloads several papers at
|
|
128
|
+
once, each in a window of its own (download/batch/windowPlan.ts), up to the two numbers ``parallel``."""
|
|
129
|
+
return _config.load_config().get(PARALLEL_KEY) is True
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
def set_parallel(on: bool) -> None:
|
|
133
|
+
_config.update_config(PARALLEL_KEY, "true" if on else "false")
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
def parallel() -> dict[str, int]:
|
|
137
|
+
"""What a batch runs at once: ``publishers`` (不同出版社) × ``per_publisher`` (同一出版社); 1 and 1 when serial."""
|
|
138
|
+
if not parallel_enabled():
|
|
139
|
+
return {"publishers": 1, "per_publisher": 1}
|
|
140
|
+
values = current()
|
|
141
|
+
return {"publishers": max(1, values["pubs"]), "per_publisher": max(1, values["each"])}
|
|
@@ -4,7 +4,7 @@ description: |
|
|
|
4
4
|
Literature work with the local paper-search command: search papers, verify DOI/PMID, full-text snippets, journal IF and quartiles, citations and references, download full texts and supplementary files.
|
|
5
5
|
Also for "start setup" and Chinese requests (找文献、查期刊、下载论文、请开始配置).
|
|
6
6
|
metadata:
|
|
7
|
-
version: "0.8.
|
|
7
|
+
version: "0.8.1"
|
|
8
8
|
---
|
|
9
9
|
|
|
10
10
|
# Literature search and download (paper-search)
|
|
@@ -18,8 +18,8 @@ One paper: `paper-search download` or `paper-search run download_with_fallback`;
|
|
|
18
18
|
- When the user says to use only the school download (or to test just the school-access step), set `"mode":"entitled_only"` on `download_batch`: the PDF and supplementary files both go straight to the school download; "go on" (接着下) keeps the batch's mode. It skips available public copies; when the user did not say so, keep the default `two_phase`.
|
|
19
19
|
- Test downloads use the commands above too, keeping the default wait times and data directory. To sign in to the school first, or to test sign-in, use `paper-search school login --doi <DOI>` (see `school-setup.md`).
|
|
20
20
|
- Only one download at a time per data directory. While the command has not finished, do not download or sign in again because the window seems stuck.
|
|
21
|
-
-
|
|
22
|
-
- Each publisher opens at most 100 papers per hour (backend setting `publisher_hourly_limit`; 0 for no limit). At the limit, a batch waits until it can go on and then downloads this paper (the log states the time); a single download returns `rate_limited`: try again later.
|
|
21
|
+
- By default the school download takes one paper at a time, while the open channels check the following papers, three at a time. With "同时下载" (Download mode) set to "并行" (Parallel) on the settings' "下载" (Downloads) page, a batch downloads several papers at once, each in a window of its own of the same download browser (one school sign-in): "不同出版社" (Different publishers) publishers at once × "同一出版社" (Same publisher) papers of each. Only one window at a time asks the user to sign in or verify; the others go on. When a batch is slow and the user asks for it faster, point them to this setting; do not change it for them. At a school login or verification it stops on that paper; once a prompt for manual handling appears, remind the user to act in the download browser. Wait limits: on the school login page (and on pages where no school is configured and the user must choose the school) at most 3 minutes (backend setting `browser_login_timeout`, in seconds); on other pages (human verification, publisher pages, the institution-selection page, waiting for handling while fetching the PDF) the paper ends after more than 1 minute there without a break (`browser_page_wait_timeout`). Both can be changed in the settings (gear) at the top right of the progress window, taking effect from the next paper. After one sign-in through the school's single sign-on, the other papers usually pass automatically. Once a paper has waited its full limit (the log says "这一篇等你登录或验证已到时限" (the wait for your sign-in or verification on this paper ran out)), each following paper waits only 60 seconds; while the user is typing in the login box, it waits as usual.
|
|
22
|
+
- Each publisher opens at most 100 papers per hour (backend setting `publisher_hourly_limit`; 0 for no limit; a batch's windows together). At the limit, a batch waits until it can go on and then downloads this paper (the log states the time); a batch downloading in parallel goes on with other publishers meanwhile and waits only when that publisher alone is left; a single download returns `rate_limited`: try again later.
|
|
23
23
|
- When the publisher's site blocks the current network (`access_blocked`, such as a Cloudflare block page or the publisher's own "IP has been blocked" page), that paper ends; other articles of the same journal are skipped for now (`journal_blocked_earlier`); every 5 minutes one paper tries the site again, and once it opens, downloading goes on as usual (after a network change there is no need to wait half an hour); other journals carry on. Tell the user it may be the site's protection blocking the current network, or a pause because of too many downloads: change networks or try later; for the latter, contact the school library.
|
|
24
24
|
- Human verification not passed within the wait (`captcha_required`), HTTP 429 (too many requests) on supplementary files, and the blocking above all count as "被网站拦截" (Blocked by site). In batch downloads (default and `entitled_only`), that publisher's papers pause first while other publishers carry on; after 10 minutes it tries once more automatically, and the progress window shows "被网站拦截,HH:MM 再试暂停的 N 篇" (blocked by the site; the N paused papers are retried at HH:MM), with nothing for the user to do; when the retry is blocked again, that publisher's remaining papers are not tried again in this batch (`blocked_paused`), and they do not go into the final "原因不明" (Unclear) retry or the school switch. Tell the user the site is blocking, not that there is no access; after a while (or on another network) they can say "go on" (接着下).
|
|
25
25
|
- The backend first waits briefly for automatic verification; on each verification wait it tries clicking a recognizable Turnstile checkbox at most 2 times, at least 3 seconds apart; only when the program asks for manual handling, remind the user to take over in the download browser; do not ask the user to act just because of `checking_access`. When an image recognition service is configured, supported publisher AWS WAF puzzles, reCAPTCHA/hCaptcha grids and standalone character codes continue through that service after local controls, with only images and the question sent. Answers are entered in the same browser. Supported embedded Turnstile widgets can also continue through the configured service: only the public HTTPS site origin, sitekey and optional action are sent, and the answer returns to the original widget callback or associated form. Widgets requiring session data or lacking an unambiguous continuation remain manual. Full-page Cloudflare checks stay local. After the widget acknowledges success, the backend also submits its associated verification form when it has one unambiguous native submit control, regardless of the button label. It observes delayed acknowledgements during the wait; downloading continues only after the publisher page actually clears. Unsupported puzzles, exhausted attempts, school sign-in and two-factor checks remain manual; on school authentication pages, the consent to release information and the terms of use, and the terms confirmation pages during a publisher's login, are accepted by the backend (at most twice per paper each; the user is reminded only when it is still stuck on that page). Never ask for the account, password or verification code; the agent does not open another browser to act for the user.
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
PaperSearch's command line was first adapted from paper-search-mcp-nodejs
|
|
2
|
-
(https://github.com/Dianel555/paper-search-mcp-nodejs), under the MIT License:
|
|
3
|
-
|
|
4
|
-
MIT License
|
|
5
|
-
|
|
6
|
-
Copyright (c) 2025 Dianel555
|
|
7
|
-
|
|
8
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
10
|
-
in the Software without restriction, including without limitation the rights
|
|
11
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
12
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
13
|
-
furnished to do so, subject to the following conditions:
|
|
14
|
-
|
|
15
|
-
The above copyright notice and this permission notice shall be included in all
|
|
16
|
-
copies or substantial portions of the Software.
|
|
17
|
-
|
|
18
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
24
|
-
SOFTWARE.
|