papersearch 0.6.1 → 0.6.3
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/README.en.md +10 -3
- package/README.md +10 -3
- package/dist/capabilities/pdf-discovery/batch.d.ts +6 -0
- package/dist/capabilities/pdf-discovery/batch.d.ts.map +1 -1
- package/dist/capabilities/pdf-discovery/batch.js +20 -5
- package/dist/capabilities/pdf-discovery/batch.js.map +1 -1
- package/dist/capabilities/pdf-discovery/school/SchoolMcpClient.d.ts +7 -0
- package/dist/capabilities/pdf-discovery/school/SchoolMcpClient.d.ts.map +1 -1
- package/dist/capabilities/pdf-discovery/school/SchoolMcpClient.js +39 -1
- package/dist/capabilities/pdf-discovery/school/SchoolMcpClient.js.map +1 -1
- package/dist/capabilities/pdf-discovery/school/SchoolReadiness.d.ts +2 -0
- package/dist/capabilities/pdf-discovery/school/SchoolReadiness.d.ts.map +1 -1
- package/dist/capabilities/pdf-discovery/school/SchoolReadiness.js +3 -0
- package/dist/capabilities/pdf-discovery/school/SchoolReadiness.js.map +1 -1
- package/dist/capabilities/pdf-discovery/school/types.d.ts +7 -0
- package/dist/capabilities/pdf-discovery/school/types.d.ts.map +1 -1
- package/dist/infrastructure/pdf/PdfIdentity.d.ts +4 -2
- package/dist/infrastructure/pdf/PdfIdentity.d.ts.map +1 -1
- package/dist/infrastructure/pdf/PdfIdentity.js +93 -18
- package/dist/infrastructure/pdf/PdfIdentity.js.map +1 -1
- package/dist/management/school/autoUpdate.d.ts.map +1 -1
- package/dist/management/school/autoUpdate.js +2 -0
- 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 +1 -0
- package/dist/management/school/cliProgress.js.map +1 -1
- package/package.json +1 -1
- package/school/paper_search_school/assets/capsule.html +25 -12
- package/school/paper_search_school/assets/capsule_en.json +26 -1
- package/school/paper_search_school/browser/batch_session.py +81 -0
- package/school/paper_search_school/engine/batch.py +2 -0
- package/school/paper_search_school/engine/batch_institution.py +114 -1
- package/school/paper_search_school/engine/batch_login.py +27 -2
- package/school/paper_search_school/engine/bridge.py +5 -2
- package/school/paper_search_school/engine/pdf_guard.py +93 -14
- package/school/paper_search_school/federations/builtin/incommon.json +11 -0
- package/school/paper_search_school/federations/builtin/infed.json +11 -0
- package/school/paper_search_school/federations/builtin/liaf.json +11 -0
- package/school/paper_search_school/federations/builtin/omren.json +11 -0
- package/school/paper_search_school/federations/builtin/pkifed.json +11 -0
- package/school/paper_search_school/federations/builtin/tigerfed.json +11 -0
- package/school/paper_search_school/federations/builtin/yetkim.json +11 -0
- package/school/paper_search_school/federations/schools.py +53 -12
- package/school/paper_search_school/progress_reporter.py +15 -3
- package/school/paper_search_school/progress_view.py +39 -2
- package/school/paper_search_school/rate_limit.py +30 -16
- package/school/paper_search_school/server.py +16 -1
- package/skills/paper-search/SKILL.md +2 -1
- package/skills/paper-search/references/federation-support.md +19 -3
- package/skills/paper-search/references/school-setup.md +2 -2
|
@@ -155,8 +155,10 @@ def institutional_configured(config: dict[str, Any]) -> bool:
|
|
|
155
155
|
# --------------------------------------------------------------------------- finding
|
|
156
156
|
|
|
157
157
|
def _key(text: str) -> str:
|
|
158
|
-
"""Case, spaces, hyphens, punctuation and a leading "The" do not count
|
|
159
|
-
|
|
158
|
+
"""Case, spaces, hyphens, punctuation and a leading "The" do not count; "&"
|
|
159
|
+
is "and" (a school listed as "Science & Technology", 2026-11-12)."""
|
|
160
|
+
text = re.sub(r"^the\s+", "", str(text or "").casefold().strip())
|
|
161
|
+
return re.sub(r"[\W_]+", "", text.replace("&", " and "))
|
|
160
162
|
|
|
161
163
|
|
|
162
164
|
def _host(text: str) -> str:
|
|
@@ -180,13 +182,11 @@ class _Found:
|
|
|
180
182
|
self.rows[school.entity_id] = (school, exact)
|
|
181
183
|
|
|
182
184
|
def _primary(self) -> None:
|
|
183
|
-
"""A school also listed in a secondary route (OpenAthens)
|
|
184
|
-
|
|
185
|
+
"""A school also listed in a secondary route (OpenAthens) signs in through
|
|
186
|
+
its federation: that entry goes (``_same_school``)."""
|
|
185
187
|
primary = [s for s, _ in self.rows.values() if not _secondary(s)]
|
|
186
|
-
domains = {d for s in primary for d in s.scopes}
|
|
187
|
-
names = {_key(s.name_en) for s in primary}
|
|
188
188
|
for entity, (school, _) in list(self.rows.items()):
|
|
189
|
-
if _secondary(school) and (
|
|
189
|
+
if _secondary(school) and any(_same_school(school, p) for p in primary):
|
|
190
190
|
del self.rows[entity]
|
|
191
191
|
|
|
192
192
|
def decide(self) -> tuple[School | None, list[School]]:
|
|
@@ -203,6 +203,20 @@ class _Found:
|
|
|
203
203
|
return None, sorted(partial, key=lambda s: (len(s.name), s.name))
|
|
204
204
|
|
|
205
205
|
|
|
206
|
+
def _same_school(other: School, school: School) -> bool:
|
|
207
|
+
"""``other`` is ``school`` listed again: under its domain or a host of it (its
|
|
208
|
+
library's), or under its name, an abbreviation in brackets aside, with a domain
|
|
209
|
+
of the same country (2026-11-12: two countries' universities share a name)."""
|
|
210
|
+
if any(o == d or o.endswith("." + d) for o in other.scopes for d in school.scopes):
|
|
211
|
+
return True
|
|
212
|
+
name = _key(_BRACKET.sub(" ", other.name_en))
|
|
213
|
+
if not name or name != _key(_BRACKET.sub(" ", school.name_en)):
|
|
214
|
+
return False
|
|
215
|
+
if not (other.scopes and school.scopes):
|
|
216
|
+
return True
|
|
217
|
+
return bool({d.rsplit(".", 1)[-1] for d in other.scopes} & {d.rsplit(".", 1)[-1] for d in school.scopes})
|
|
218
|
+
|
|
219
|
+
|
|
206
220
|
def _secondary(school: School) -> bool:
|
|
207
221
|
federation = by_code(school.federation)
|
|
208
222
|
return bool(federation and federation.secondary)
|
|
@@ -213,24 +227,50 @@ _RETIRED = re.compile(r"\bdo not use\b|\btest\b|\blegacy\b", re.I)
|
|
|
213
227
|
|
|
214
228
|
|
|
215
229
|
_PARTS = re.compile(r"\s+[-\u2013\u2014]\s+")
|
|
216
|
-
|
|
230
|
+
_BRACKET = re.compile(r"\(([^()]+)\)")
|
|
231
|
+
# Chinese, Japanese and Korean writing, beside a name in Latin letters.
|
|
232
|
+
_CJK = re.compile(r"[\u3040-\u30ff\u3400-\u9fff\uac00-\ud7af][\u3040-\u30ff\u3400-\u9fff\uac00-\ud7af\s・·]*")
|
|
217
233
|
|
|
218
234
|
|
|
219
235
|
def _names(titles: Iterable[str]) -> list[str]:
|
|
220
236
|
"""The names a school is listed under, and their parts: "NHU - National
|
|
221
237
|
Harbour University" (an abbreviation before the name), "北大学 (Kita
|
|
222
|
-
University) – OpenAthens" (a second name in brackets, the route after a dash)
|
|
238
|
+
University) – OpenAthens" (a second name in brackets, the route after a dash),
|
|
239
|
+
"National Harbour Bay University (NHBU) 海灣大學" (brackets inside, and a name in
|
|
240
|
+
another script beside the English one: OpenAthens in Taiwan, 2026-11-12)."""
|
|
223
241
|
names = [str(t).strip() for t in titles if str(t or "").strip()]
|
|
224
242
|
found = list(names)
|
|
225
243
|
for name in names:
|
|
226
244
|
for part in _PARTS.split(name):
|
|
227
|
-
|
|
228
|
-
|
|
245
|
+
part = part.strip()
|
|
246
|
+
outside = re.sub(r"\s+", " ", _BRACKET.sub(" ", part)).strip()
|
|
247
|
+
found += [part, outside, *(m.strip() for m in _BRACKET.findall(part))]
|
|
248
|
+
if _CJK.search(outside) and re.search(r"[A-Za-z]{2}", _CJK.sub(" ", outside)):
|
|
249
|
+
found += [m.strip() for m in _CJK.findall(outside)] + [re.sub(r"\s+", " ", _CJK.sub(" ", outside)).strip()]
|
|
229
250
|
return list(dict.fromkeys(n for n in found if n))
|
|
230
251
|
|
|
231
252
|
|
|
253
|
+
def _words(text: str) -> list[str]:
|
|
254
|
+
"""The words of a name, as ``_key`` compares them."""
|
|
255
|
+
words = [w for w in re.split(r"[\W_]+", str(text or "").casefold().replace("&", " and ")) if w]
|
|
256
|
+
return words[1:] if words[:1] == ["the"] else words
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
def _listed_inside(text: str, listed_names: Iterable[str]) -> bool:
|
|
260
|
+
"""A listed name of two words or more found word for word in what was given:
|
|
261
|
+
a school listed shorter than its full name ("Kita Bay" for "Kita Bay
|
|
262
|
+
University", 2026-11-12), only ever asked about."""
|
|
263
|
+
given = _words(text)
|
|
264
|
+
for name in listed_names:
|
|
265
|
+
part = _words(name)
|
|
266
|
+
if len(part) >= 2 and any(given[i:i + len(part)] == part for i in range(len(given) - len(part) + 1)):
|
|
267
|
+
return True
|
|
268
|
+
return False
|
|
269
|
+
|
|
270
|
+
|
|
232
271
|
def _matches(given: Iterable[str], listed_names: Iterable[str], scopes: Iterable[str], entity: str) -> tuple[bool, bool]:
|
|
233
272
|
"""(exact, partial) for what was given against one listed school."""
|
|
273
|
+
listed_names = list(listed_names)
|
|
234
274
|
keys = {_key(n) for n in listed_names} - {""}
|
|
235
275
|
hosts = {s.lower() for s in scopes if s}
|
|
236
276
|
exact = partial = False
|
|
@@ -240,7 +280,8 @@ def _matches(given: Iterable[str], listed_names: Iterable[str], scopes: Iterable
|
|
|
240
280
|
continue
|
|
241
281
|
if text == entity or key in keys or host in hosts:
|
|
242
282
|
exact = True
|
|
243
|
-
elif any(key in k for k in keys) or any(host and host in h for h in hosts)
|
|
283
|
+
elif (any(key in k for k in keys) or any(host and host in h for h in hosts)
|
|
284
|
+
or _listed_inside(text, listed_names)):
|
|
244
285
|
partial = True
|
|
245
286
|
return exact, partial and not exact
|
|
246
287
|
|
|
@@ -558,7 +558,9 @@ def tracked_download(current: str, output_dir: Any = None, batch: BatchContext |
|
|
|
558
558
|
``content`` (main / supplements / both) is shown as a small label.
|
|
559
559
|
``outcome["paused"]`` (a phase text) means the article has not run yet and
|
|
560
560
|
the batch tries it again later (publisher's hourly limit): nothing is
|
|
561
|
-
counted and the window stays open
|
|
561
|
+
counted and the window stays open; ``outcome["hourly_wait"]`` (publisher,
|
|
562
|
+
limit, until) keeps the window saying so until then, whatever the batch's
|
|
563
|
+
other lane reports meanwhile. The next article clears it.
|
|
562
564
|
"""
|
|
563
565
|
if batch is None:
|
|
564
566
|
start_task("机构 PDF 下载", total=1, current=current, phase="进入机构访问")
|
|
@@ -568,6 +570,8 @@ def tracked_download(current: str, output_dir: Any = None, batch: BatchContext |
|
|
|
568
570
|
current=current, stage="starting", channel="",
|
|
569
571
|
phase=f"第 {batch.index}/{batch.total} 篇:进入机构访问" if batch.total > 1 else "进入机构访问")
|
|
570
572
|
_notify_stage("starting", current)
|
|
573
|
+
with _LOCK:
|
|
574
|
+
_STATE.pop("hourly_wait", None) # this article runs: no longer held by the hourly limit
|
|
571
575
|
update(content=content if content in ("main", "supplements", "both") else "main")
|
|
572
576
|
if output_dir:
|
|
573
577
|
set_output_dir(output_dir)
|
|
@@ -578,7 +582,8 @@ def tracked_download(current: str, output_dir: Any = None, batch: BatchContext |
|
|
|
578
582
|
if outcome.get("paused") and batch is not None:
|
|
579
583
|
with _LOCK:
|
|
580
584
|
if _STATE:
|
|
581
|
-
_STATE.update(awaiting_next=True, phase=str(outcome["paused"])
|
|
585
|
+
_STATE.update(awaiting_next=True, phase=str(outcome["paused"]),
|
|
586
|
+
**({"hourly_wait": outcome["hourly_wait"]} if outcome.get("hourly_wait") else {}))
|
|
582
587
|
_write_state()
|
|
583
588
|
else:
|
|
584
589
|
_finish_download(outcome, current, batch, content)
|
|
@@ -840,12 +845,19 @@ def read_snapshot() -> tuple[dict[str, Any] | None, str]:
|
|
|
840
845
|
return None, "invalid_state"
|
|
841
846
|
if state.get("status") == "running" and state.get("awaiting_next") is True:
|
|
842
847
|
# Between batch items no process owns the task; only time ends the wait.
|
|
848
|
+
allowed = BATCH_WAIT_STALE_SECONDS
|
|
843
849
|
try:
|
|
844
850
|
ts = datetime.fromisoformat(str(state.get("updated_at")))
|
|
845
851
|
waited = (datetime.now(ts.tzinfo) - ts).total_seconds()
|
|
852
|
+
# Held by the hourly limit the user set: the wait lasts until its time (up
|
|
853
|
+
# to an hour; read as stopped after 30 minutes, Windows 2026-11-13).
|
|
854
|
+
hold = state.get("hourly_wait")
|
|
855
|
+
until = hold.get("until") if isinstance(hold, dict) else None
|
|
856
|
+
if isinstance(until, (int, float)) and not isinstance(until, bool):
|
|
857
|
+
allowed = max(allowed, until - ts.timestamp() + BATCH_WAIT_STALE_SECONDS)
|
|
846
858
|
except Exception:
|
|
847
859
|
waited = 0.0
|
|
848
|
-
if waited >
|
|
860
|
+
if waited > allowed:
|
|
849
861
|
return {**state, "status": "interrupted", "stage": "interrupted", "awaiting_next": False,
|
|
850
862
|
"phase": "批量下载已停止,结果未确认", "attention": {}}, "available"
|
|
851
863
|
return state, "available"
|
|
@@ -10,6 +10,7 @@ from __future__ import annotations
|
|
|
10
10
|
import os
|
|
11
11
|
import re
|
|
12
12
|
import sys
|
|
13
|
+
import time
|
|
13
14
|
from datetime import datetime
|
|
14
15
|
from typing import Any
|
|
15
16
|
|
|
@@ -283,6 +284,24 @@ def paper_lists(listed: Any, state: dict[str, Any] | None) -> dict[str, Any]:
|
|
|
283
284
|
return {"ok": first_open(saved), "failed": missing, "left": first_open(left)}
|
|
284
285
|
|
|
285
286
|
|
|
287
|
+
# The longest publisher name the hourly-limit notice keeps on one line, in zh and en,
|
|
288
|
+
# with a limit of 1000 and 23:59 (measured in the capsule: "Copernicus", 2026-11-12).
|
|
289
|
+
HOLD_NAME_MAX = 10
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
def _hourly_hold(state: dict[str, Any], now: float) -> tuple[str, int | None, str] | None:
|
|
293
|
+
"""The hourly limit the user set per publisher holding the school's downloads:
|
|
294
|
+
(publisher, limit, "HH:MM" it goes on), until that time (2026-11-12)."""
|
|
295
|
+
raw = state.get("hourly_wait")
|
|
296
|
+
if not isinstance(raw, dict):
|
|
297
|
+
return None
|
|
298
|
+
until, limit = raw.get("until"), raw.get("limit")
|
|
299
|
+
if not isinstance(until, (int, float)) or isinstance(until, bool) or until <= now:
|
|
300
|
+
return None
|
|
301
|
+
limit = limit if isinstance(limit, int) and not isinstance(limit, bool) and limit > 0 else None
|
|
302
|
+
return str(raw.get("publisher") or ""), limit, time.strftime("%H:%M", time.localtime(until))
|
|
303
|
+
|
|
304
|
+
|
|
286
305
|
def view(state: dict[str, Any] | None, now: float) -> dict[str, Any]:
|
|
287
306
|
"""Everything the capsule shows for one snapshot of the progress file.
|
|
288
307
|
|
|
@@ -364,6 +383,24 @@ def view(state: dict[str, Any] | None, now: float) -> dict[str, Any]:
|
|
|
364
383
|
notice = str(raw.get("text") or "")
|
|
365
384
|
except (TypeError, ValueError):
|
|
366
385
|
pass
|
|
386
|
+
# Held by the hourly limit the user set: the capsule and the card say so, and that
|
|
387
|
+
# it is the user's setting, not the publisher's (2026-11-12).
|
|
388
|
+
line = status_text(state, running) if running else ""
|
|
389
|
+
hold = _hourly_hold(state, now) if running and not attention else None
|
|
390
|
+
if hold:
|
|
391
|
+
name, limit, resume = hold
|
|
392
|
+
# The phase recorded with the hold says it again below the notice; a line of
|
|
393
|
+
# the other lane (open download) stays (2026-11-13).
|
|
394
|
+
if line == str(state["hourly_wait"].get("phase") or ""):
|
|
395
|
+
line = ""
|
|
396
|
+
part, publisher = "已达每小时上限", f"{resume} 继续"
|
|
397
|
+
# One line on the card in either language: a longer publisher name (or a site's
|
|
398
|
+
# host) is left out; the status line above already says what holds.
|
|
399
|
+
name = name if len(name) <= HOLD_NAME_MAX else ""
|
|
400
|
+
# The hour is over then and the count starts again (2026-11-13).
|
|
401
|
+
notice = (f"{name} 已达设置的每小时 {limit} 篇,{resume} 重新计数" if name and limit
|
|
402
|
+
else f"已达设置的每小时 {limit} 篇,{resume} 重新计数" if limit
|
|
403
|
+
else f"已达设置的每小时上限,{resume} 重新计数")
|
|
367
404
|
|
|
368
405
|
return {
|
|
369
406
|
"mode": mode, "tone": tone, "headline": headline,
|
|
@@ -375,8 +412,8 @@ def view(state: dict[str, Any] | None, now: float) -> dict[str, Any]:
|
|
|
375
412
|
"where": " · ".join(v for v in (journal, publisher) if v),
|
|
376
413
|
"title": str(state.get("title") or ""), "current": current,
|
|
377
414
|
"run_id": str(state.get("run_id") or ""),
|
|
378
|
-
"step": step, "steps": list(STEPS), "line":
|
|
379
|
-
"elapsed": elapsed, "attention": prompt, "notice": notice,
|
|
415
|
+
"step": step, "steps": list(STEPS), "line": line,
|
|
416
|
+
"elapsed": elapsed, "attention": prompt, "notice": notice, "hold": bool(hold),
|
|
380
417
|
"completion_detail": str(state.get("phase") or "")
|
|
381
418
|
if not running and state.get("stage") == "supplements_checked" else "",
|
|
382
419
|
"summary": summary_view(state.get("results")) if mode == "done" else None,
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
"""At most ``publisher_hourly_limit`` articles per publisher in
|
|
1
|
+
"""At most ``publisher_hourly_limit`` articles per publisher in each hour (default 100).
|
|
2
2
|
|
|
3
3
|
Libraries count more than about a hundred downloads an hour as abuse, and
|
|
4
4
|
publishers suspend the school's access for it (dependencies section 6, state L).
|
|
5
|
-
|
|
6
|
-
``<data dir>/publisher_rate.json
|
|
7
|
-
the
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
A publisher's hour starts with the first article opened on its site, and
|
|
6
|
+
``<data dir>/publisher_rate.json`` keeps when it started and how many it has
|
|
7
|
+
opened. Once the hour has its limit, the next article waits until the hour is
|
|
8
|
+
over; the count then starts again with that article. (Counted over any 60
|
|
9
|
+
minutes, a batch went on one article at a time as each of the last hour's aged
|
|
10
|
+
out, which read as stopping again and again: the user, 2026-11-13.) The backend
|
|
11
|
+
answers ``rate_limited`` with the seconds to wait, and psc's batch waits and tries
|
|
12
|
+
the same article again.
|
|
10
13
|
"""
|
|
11
14
|
from __future__ import annotations
|
|
12
15
|
|
|
@@ -23,10 +26,20 @@ def ledger_path() -> Path:
|
|
|
23
26
|
return _data_dir() / "publisher_rate.json"
|
|
24
27
|
|
|
25
28
|
|
|
26
|
-
def
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
def _hour(data: dict, key: str, now: float) -> tuple[float, int] | None:
|
|
30
|
+
"""(start, count) of ``key``'s hour still running at ``now``; None when none is."""
|
|
31
|
+
entry = data.get(key)
|
|
32
|
+
if isinstance(entry, list):
|
|
33
|
+
# Written before 0.6.3, the times of the articles opened: their hour starts with the oldest of the last hour.
|
|
34
|
+
times = sorted(t for t in entry if isinstance(t, (int, float)) and now - HOUR < t <= now)
|
|
35
|
+
entry = {"start": times[0], "count": len(times)} if times else None
|
|
36
|
+
if not isinstance(entry, dict):
|
|
37
|
+
return None
|
|
38
|
+
start, count = entry.get("start"), entry.get("count")
|
|
39
|
+
if (not isinstance(start, (int, float)) or isinstance(start, bool)
|
|
40
|
+
or not isinstance(count, int) or isinstance(count, bool) or not now - HOUR < start <= now):
|
|
41
|
+
return None
|
|
42
|
+
return float(start), count
|
|
30
43
|
|
|
31
44
|
|
|
32
45
|
def wait_seconds(key: str, limit: int, now: float | None = None) -> int:
|
|
@@ -34,18 +47,19 @@ def wait_seconds(key: str, limit: int, now: float | None = None) -> int:
|
|
|
34
47
|
if limit <= 0 or not key:
|
|
35
48
|
return 0
|
|
36
49
|
now = time.time() if now is None else now
|
|
37
|
-
|
|
38
|
-
if
|
|
50
|
+
hour = _hour(_read_json(ledger_path()), key, now)
|
|
51
|
+
if hour is None or hour[1] < limit:
|
|
39
52
|
return 0
|
|
40
|
-
return int(
|
|
53
|
+
return int(hour[0] + HOUR - now) + 1
|
|
41
54
|
|
|
42
55
|
|
|
43
56
|
def record(key: str, now: float | None = None) -> None:
|
|
44
|
-
"""Count one article opened on ``key``'s site;
|
|
57
|
+
"""Count one article opened on ``key``'s site, in its hour or in a new one; hours over are dropped."""
|
|
45
58
|
if not key:
|
|
46
59
|
return
|
|
47
60
|
now = time.time() if now is None else now
|
|
48
61
|
data = _read_json(ledger_path())
|
|
49
|
-
kept = {name:
|
|
50
|
-
kept.
|
|
62
|
+
kept = {name: {"start": hour[0], "count": hour[1]} for name in data if (hour := _hour(data, name, now))}
|
|
63
|
+
current = kept.get(key, {"start": now, "count": 0})
|
|
64
|
+
kept[key] = {"start": current["start"], "count": current["count"] + 1}
|
|
51
65
|
_write_json(ledger_path(), kept)
|
|
@@ -123,9 +123,14 @@ def school_download(
|
|
|
123
123
|
if result.get("error_type") == "access_blocked":
|
|
124
124
|
outcome["failure_phase"] = "网站已阻止当前访问,未取得 PDF"
|
|
125
125
|
if result.get("error_type") == "rate_limited":
|
|
126
|
-
|
|
126
|
+
until = time.time() + int(result.get("retry_after_sec") or 0)
|
|
127
|
+
resume = time.strftime("%H:%M", time.localtime(until))
|
|
127
128
|
outcome["paused"] = outcome["failure_phase"] = (
|
|
128
129
|
f"{result.get('publisher')} 一小时内已打开 {result.get('limit')} 篇(每小时上限),{resume} 继续这一篇")
|
|
130
|
+
# The window says so until then, beside the other lane's lines (2026-11-12).
|
|
131
|
+
outcome["hourly_wait"] = {"publisher": str(result.get("publisher") or ""),
|
|
132
|
+
"limit": result.get("limit"), "until": until,
|
|
133
|
+
"phase": outcome["paused"]}
|
|
129
134
|
if result.get("error_type") == "paywall" or result.get("action") == "login_required":
|
|
130
135
|
result["agent_hint"] = (
|
|
131
136
|
"此论文需要机构登录。请让用户在弹出的下载浏览器窗口里完成登录或人工验证后重试;"
|
|
@@ -201,6 +206,16 @@ async def school_close_batch_browser() -> str:
|
|
|
201
206
|
return json.dumps({"closed": True})
|
|
202
207
|
|
|
203
208
|
|
|
209
|
+
@mcp_app.tool()
|
|
210
|
+
async def school_keep_session() -> str:
|
|
211
|
+
"""While a serial batch waits (the publisher's hourly limit the user set), load the
|
|
212
|
+
last paper's article page again in the batch's window, so the publisher's
|
|
213
|
+
institutional session does not lapse. Opens no browser; does nothing after a paper
|
|
214
|
+
that did not save its PDF. Answers {"kept": true} or {"kept": false, "reason": ...}."""
|
|
215
|
+
result = await asyncio.get_running_loop().run_in_executor(_batch_worker, _batch_browser.keep_session)
|
|
216
|
+
return json.dumps(result)
|
|
217
|
+
|
|
218
|
+
|
|
204
219
|
@mcp_app.tool()
|
|
205
220
|
def school_batch_progress(
|
|
206
221
|
batch_id: str,
|
|
@@ -4,7 +4,7 @@ description: |
|
|
|
4
4
|
用本机 paper-search 命令做文献工作:检索论文、核对 DOI/PMID、搜正文片段(找方法和结果的原文)、查期刊影响因子与分区、查施引和参考文献、下载全文和补充材料。
|
|
5
5
|
用户要找文献、查期刊、下载论文,或说“请开始配置”时使用;英文请求(literature search、journal metrics、paper download、start setup)同样适用。
|
|
6
6
|
metadata:
|
|
7
|
-
version: "0.6.
|
|
7
|
+
version: "0.6.3"
|
|
8
8
|
---
|
|
9
9
|
|
|
10
10
|
# 文献检索与下载(paper-search)
|
|
@@ -13,6 +13,7 @@ metadata:
|
|
|
13
13
|
|
|
14
14
|
## 回复用户
|
|
15
15
|
|
|
16
|
+
- 用用户提问的语言回复。本 Skill 用中文写成,引号里的问法只表达意思,按用户的语言说;命令输出和程序提示里的中文说明,翻成用户的语言再转述。论文标题、正文原句、DOI、期刊名、命令和文件路径保持原样。
|
|
16
17
|
- 只说结果和下一步,几句话说完;安装、配置的汇报不用表格。
|
|
17
18
|
- 命令输出里的安装路径、版本号、依赖数、哈希、配置细节不复述,用户问起或排障时再说。
|
|
18
19
|
- 只做用户要的事和本 Skill 写明的步骤,不额外跑测试、查包信息或翻找文件。
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# 学校订阅下载:各学术身份联盟支持情况
|
|
2
2
|
|
|
3
|
-
本表说明学校订阅下载能经哪些学术身份联盟登录(截至 2026-11-
|
|
3
|
+
本表说明学校订阅下载能经哪些学术身份联盟登录(截至 2026-11-12)。“支持”是说:用户说出学校名称,程序能查出学校所属的联盟,并在出版社网站上自动选好联盟和学校,走到学校的登录页。登录之后能否下到全文,取决于学校的订阅,以及出版社是否给这所学校开通了学校账号登录。
|
|
4
4
|
|
|
5
5
|
各国的学术身份联盟通过 eduGAIN 互联,出版社借此认可各国学校的账号;OpenAthens 是跨国的机构登录服务,没有加入本国联盟的学校不少经它登录。
|
|
6
6
|
|
|
@@ -21,11 +21,27 @@
|
|
|
21
21
|
| 日本 | GakuNin(学認) | 学術認証フェデレーション(Academic Access Management Federation in Japan) | 约 170 | ✓ | 东京大学、大阪大学、东北大学、庆应义塾大学、早稻田大学 |
|
|
22
22
|
| 韩国 | KAFE | Korean Access Federation | 27 | ✓ | KAIST、延世大学、浦项工科大学、成均馆大学 |
|
|
23
23
|
| 马来西亚 | SIFULAN | SIFULAN Malaysian Access Federation | 约 150 | ✓ | 马来西亚理科大学、博特拉大学 |
|
|
24
|
-
|
|
|
24
|
+
| 印度 | INFED | INFLIBNET Access Management Federation | 约 390 | ✓ | 印度理工学院德里分校 |
|
|
25
|
+
| 土耳其 | YETKİM | YETKİM Identity Federation | 约 170 | ✓ | 哈杰泰佩大学、中东技术大学、海峡大学、伊斯坦布尔大学 |
|
|
26
|
+
| 斯里兰卡 | LIAF | LEARN Identity Access Federation | 31 | ✓ | 科伦坡大学 |
|
|
27
|
+
| 孟加拉 | TIGERfed | Trust, Identity and Group management for Education and Research Federation | 30 | ✓ | 孟加拉工程技术大学 |
|
|
28
|
+
| 巴基斯坦 | PKIFED | Pakistan Identity Federation | 8 | ✓ | COMSATS 大学伊斯兰堡分校、巴基斯坦国立科技大学、真纳大学 |
|
|
29
|
+
| 阿曼 | OMREN | OMREN Identity Federation | 约 30 | ○ | — |
|
|
30
|
+
| 跨地区 | OpenAthens | OpenAthens 机构登录服务 | — | ✓ | 马来亚大学、朱拉隆功大学、菲律宾大学 Diliman、名古屋大学、台湾大学、阳明交通大学、台湾师范大学 |
|
|
25
31
|
|
|
26
32
|
- 联盟内学校数取自 eduGAIN 登记的身份提供方数量,一所学校可能登记不止一个。
|
|
27
33
|
- OpenAthens 不是某个国家的联盟,是跨国的机构登录服务;学校同时有本国联盟入口时,程序优先用联盟的。
|
|
34
|
+
- 台湾没有加入 eduGAIN 的联盟,台湾的学校经 OpenAthens 登录;没有接入 OpenAthens 的台湾学校暂时无法使用。
|
|
35
|
+
- 巴基斯坦有一百多所学校经 PERN 全国共用入口登录,联盟名单里只有它们的域名:按校名查不到时,用学校官网域名配置。
|
|
36
|
+
- 阿曼 OMREN 交给 eduGAIN 的学校名单目前已过期,阿曼的学校暂时查不到;名单恢复后无需改动即可使用。
|
|
37
|
+
- 学校登录服务器连不上,或学校认证服务器拒绝出版社的登录请求时,程序立即结束并说明“学校登录系统出错”;这类情况要由学校处理。
|
|
38
|
+
|
|
39
|
+
## 美洲
|
|
40
|
+
|
|
41
|
+
| 地区 | 联盟 | 全称 | 联盟内学校数 | 状态 | 已实测的学校 |
|
|
42
|
+
| --- | --- | --- | --- | --- | --- |
|
|
43
|
+
| 美国 | InCommon | InCommon Federation | 约 590 | ✓ | 斯坦福大学、麻省理工学院、耶鲁大学、普林斯顿大学、哥伦比亚大学、加州大学伯克利分校、加州大学洛杉矶分校、加州大学旧金山分校、密歇根大学、宾夕法尼亚大学、杜克大学、华盛顿大学、纽约大学、康奈尔大学、约翰斯·霍普金斯大学 |
|
|
28
44
|
|
|
29
45
|
## 计划中
|
|
30
46
|
|
|
31
|
-
|
|
47
|
+
英国(UK federation)、澳大利亚(AAF)、欧洲各国联盟,之后是 eduGAIN 里的其他国家。
|
|
@@ -53,8 +53,8 @@ paper-search school login --doi <学校订阅的一篇文章的 DOI>
|
|
|
53
53
|
paper-search-school setup --institution "用户说的校名" [--also-name "学校的英文正式名称"]
|
|
54
54
|
```
|
|
55
55
|
|
|
56
|
-
- 目前支持中国内地和澳门(CARSI)、香港(HKAF)、新加坡(SGAF)、日本(GakuNin)、韩国(KAFE)、马来西亚(SIFULAN)的学术身份联盟,以及只经 OpenAthens 登录的学校。`--institution` 可以是校名(任何语言)、学校域名或 entityID;后端在各联盟的学校名单里查,确定是哪一所才保存,并保存它所属的联盟。
|
|
57
|
-
-
|
|
56
|
+
- 目前支持中国内地和澳门(CARSI)、香港(HKAF)、新加坡(SGAF)、日本(GakuNin)、韩国(KAFE)、马来西亚(SIFULAN)、印度(INFED)、土耳其(YETKİM)、斯里兰卡(LIAF)、孟加拉(TIGERfed)、巴基斯坦(PKIFED)、阿曼(OMREN)、美国(InCommon)的学术身份联盟,以及只经 OpenAthens 登录的学校。`--institution` 可以是校名(任何语言)、学校域名或 entityID;后端在各联盟的学校名单里查,确定是哪一所才保存,并保存它所属的联盟。
|
|
57
|
+
- 联盟名单里的校名是当地语言和英文(中国内地、澳门有中文,日本有日文,土耳其有土耳其文,香港、韩国、新加坡、马来西亚、南亚和美国多只有英文)。用户说的校名不是这两种时,加 `--also-name` 给出学校的英文正式名称;不确定英文名就不加。
|
|
58
58
|
- 返回 `school_ambiguous` 时,把 `candidates`(含学校名、联盟、域名)列给用户选,再用所选学校的 `entity_id` 作为 `--institution` 重新运行;只有一个候选也要问,那是名字不完全一致的学校。`school_not_found` 时请用户换成学校正式名称、英文名或学校域名,仍找不到就按回复里的 `reasons` 如实说明:这所学校可能没有接入学术身份联盟或 OpenAthens,学校订阅下载无法为它登录;`federation_not_supported` 是找到了学校但它所属的联盟还不支持,如实告诉用户;`school_list_unavailable` 是名单取不到,稍后重试。
|
|
59
59
|
- `--carsi --institution` 只在 CARSI 名单里查(错误码 `carsi_school_*`);查 CARSI 名单:`paper-search-school setup --list-carsi-schools 关键词`。
|
|
60
60
|
- `setup --check` 的 `school` 项为 `missing` 时,说明只存了学校名,按提示重新运行上面的命令。
|