papersearch 0.6.5 → 0.6.7
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 -4
- package/README.md +10 -4
- 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 +201 -17
- package/dist/capabilities/pdf-discovery/batch.js.map +1 -1
- package/dist/capabilities/pdf-discovery/handler.d.ts +3 -1
- package/dist/capabilities/pdf-discovery/handler.d.ts.map +1 -1
- package/dist/capabilities/pdf-discovery/handler.js +27 -1
- package/dist/capabilities/pdf-discovery/handler.js.map +1 -1
- package/dist/capabilities/pdf-discovery/resume.d.ts +22 -0
- package/dist/capabilities/pdf-discovery/resume.d.ts.map +1 -0
- package/dist/capabilities/pdf-discovery/resume.js +114 -0
- package/dist/capabilities/pdf-discovery/resume.js.map +1 -0
- package/dist/capabilities/pdf-discovery/schemas.d.ts +34 -3
- package/dist/capabilities/pdf-discovery/schemas.d.ts.map +1 -1
- package/dist/capabilities/pdf-discovery/schemas.js +6 -3
- package/dist/capabilities/pdf-discovery/schemas.js.map +1 -1
- package/dist/capabilities/pdf-discovery/school/SchoolAttempt.d.ts.map +1 -1
- package/dist/capabilities/pdf-discovery/school/SchoolAttempt.js +2 -0
- package/dist/capabilities/pdf-discovery/school/SchoolAttempt.js.map +1 -1
- package/dist/capabilities/pdf-discovery/school/SchoolMcpClient.d.ts +15 -1
- package/dist/capabilities/pdf-discovery/school/SchoolMcpClient.d.ts.map +1 -1
- package/dist/capabilities/pdf-discovery/school/SchoolMcpClient.js +42 -7
- package/dist/capabilities/pdf-discovery/school/SchoolMcpClient.js.map +1 -1
- package/dist/capabilities/pdf-discovery/school/SchoolReadiness.d.ts +4 -0
- package/dist/capabilities/pdf-discovery/school/SchoolReadiness.d.ts.map +1 -1
- package/dist/capabilities/pdf-discovery/school/SchoolReadiness.js +4 -0
- package/dist/capabilities/pdf-discovery/school/SchoolReadiness.js.map +1 -1
- package/dist/capabilities/pdf-discovery/school/SchoolResultNormalizer.js +7 -1
- package/dist/capabilities/pdf-discovery/school/SchoolResultNormalizer.js.map +1 -1
- package/dist/capabilities/pdf-discovery/school/index.d.ts +2 -2
- package/dist/capabilities/pdf-discovery/school/index.d.ts.map +1 -1
- package/dist/capabilities/pdf-discovery/school/index.js +1 -1
- package/dist/capabilities/pdf-discovery/school/index.js.map +1 -1
- package/dist/capabilities/pdf-discovery/school/types.d.ts +35 -0
- package/dist/capabilities/pdf-discovery/school/types.d.ts.map +1 -1
- package/dist/capabilities/pdf-discovery/tools.d.ts +8 -4
- package/dist/capabilities/pdf-discovery/tools.d.ts.map +1 -1
- package/dist/capabilities/pdf-discovery/tools.js +5 -3
- package/dist/capabilities/pdf-discovery/tools.js.map +1 -1
- package/dist/infrastructure/runlog/RunLedger.d.ts +4 -0
- package/dist/infrastructure/runlog/RunLedger.d.ts.map +1 -1
- package/dist/infrastructure/runlog/RunLedger.js.map +1 -1
- package/dist/infrastructure/runlog/failureClass.d.ts.map +1 -1
- package/dist/infrastructure/runlog/failureClass.js +3 -0
- package/dist/infrastructure/runlog/failureClass.js.map +1 -1
- package/dist/management/failures/exportReport.d.ts.map +1 -1
- package/dist/management/failures/exportReport.js +3 -1
- package/dist/management/failures/exportReport.js.map +1 -1
- package/dist/management/school/autoUpdate.d.ts.map +1 -1
- package/dist/management/school/autoUpdate.js +8 -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 +2 -0
- package/dist/management/school/cliProgress.js.map +1 -1
- package/dist/management/school/host.d.ts.map +1 -1
- package/dist/management/school/host.js +3 -1
- package/dist/management/school/host.js.map +1 -1
- package/dist/management/school/settingsWindow.d.ts +1 -1
- package/dist/management/school/settingsWindow.d.ts.map +1 -1
- package/dist/management/school/settingsWindow.js +4 -2
- package/dist/management/school/settingsWindow.js.map +1 -1
- package/package.json +1 -1
- package/school/paper_search_school/assets/capsule.html +73 -2
- package/school/paper_search_school/assets/capsule_en.json +33 -1
- package/school/paper_search_school/cli.py +15 -0
- package/school/paper_search_school/engine/batch_capture.py +10 -2
- package/school/paper_search_school/engine/batch_institution.py +26 -5
- package/school/paper_search_school/engine/bridge.py +19 -1
- package/school/paper_search_school/entitlements.py +27 -0
- package/school/paper_search_school/federations/builtin/aaf.json +11 -0
- package/school/paper_search_school/federations/builtin/caf.json +11 -0
- package/school/paper_search_school/federations/builtin/cafe.json +11 -0
- package/school/paper_search_school/federations/builtin/cofre.json +11 -0
- package/school/paper_search_school/federations/builtin/colfire.json +11 -0
- package/school/paper_search_school/federations/builtin/eduidbf.json +11 -0
- package/school/paper_search_school/federations/builtin/eduidma.json +11 -0
- package/school/paper_search_school/federations/builtin/eduidtg.json +11 -0
- package/school/paper_search_school/federations/builtin/fenix.json +11 -0
- package/school/paper_search_school/federations/builtin/fidern.json +11 -0
- package/school/paper_search_school/federations/builtin/garnet.json +11 -0
- package/school/paper_search_school/federations/builtin/maren.json +11 -0
- package/school/paper_search_school/federations/builtin/minga.json +11 -0
- package/school/paper_search_school/federations/builtin/ngrenid.json +11 -0
- package/school/paper_search_school/federations/builtin/rafiki.json +11 -0
- package/school/paper_search_school/federations/builtin/rif.json +11 -0
- package/school/paper_search_school/federations/builtin/safire.json +11 -0
- package/school/paper_search_school/federations/builtin/ternet.json +11 -0
- package/school/paper_search_school/federations/builtin/tuakiri.json +11 -0
- package/school/paper_search_school/federations/schools.py +26 -4
- package/school/paper_search_school/progress_capsule.py +10 -1
- package/school/paper_search_school/progress_reporter.py +29 -2
- package/school/paper_search_school/progress_view.py +17 -2
- package/school/paper_search_school/server.py +15 -3
- package/skills/paper-search/SKILL.md +1 -1
- package/skills/paper-search/references/browser-download.md +12 -1
- package/skills/paper-search/references/federation-support.md +57 -5
- package/skills/paper-search/references/school-setup.md +3 -3
|
@@ -36,6 +36,12 @@ from .batch_common import (
|
|
|
36
36
|
)
|
|
37
37
|
|
|
38
38
|
|
|
39
|
+
def _sent_as_attachment(headers: dict[str, str]) -> bool:
|
|
40
|
+
"""The site sends the PDF to be saved, not shown (Content-Disposition: attachment):
|
|
41
|
+
Chrome downloads it besides the capture, which holds it already."""
|
|
42
|
+
return headers.get("content-disposition", "").strip().lower().startswith("attachment")
|
|
43
|
+
|
|
44
|
+
|
|
39
45
|
class CaptureMixin:
|
|
40
46
|
"""Getting the PDF: the article's PDF control, the browser's viewer and downloads, fetching again."""
|
|
41
47
|
|
|
@@ -508,10 +514,12 @@ class CaptureMixin:
|
|
|
508
514
|
else payload["body"].encode("latin-1")
|
|
509
515
|
)
|
|
510
516
|
if self._accept_pdf_body(body, url):
|
|
511
|
-
if self.adapter.keeps_pdf_out_of_downloads:
|
|
517
|
+
if self.adapter.keeps_pdf_out_of_downloads or _sent_as_attachment(headers):
|
|
512
518
|
# We own the validated bytes and save them under the
|
|
513
519
|
# DOI below. Do not also hand the response to Chrome's
|
|
514
|
-
# download manager, which exposes a UUID temp file
|
|
520
|
+
# download manager, which exposes a UUID temp file and,
|
|
521
|
+
# for a PDF sent as an attachment, a full second copy in
|
|
522
|
+
# its download list (Science's ?download=true, 2026-11-15).
|
|
515
523
|
cdp_session.send("Fetch.fulfillRequest", {
|
|
516
524
|
"requestId": request_id, "responseCode": 204,
|
|
517
525
|
"responseHeaders": [], "body": "",
|
|
@@ -4,6 +4,7 @@ Part of ``PublisherBatchDownloader`` (batch.py), which combines the mixins."""
|
|
|
4
4
|
|
|
5
5
|
from __future__ import annotations
|
|
6
6
|
|
|
7
|
+
import hashlib
|
|
7
8
|
import re
|
|
8
9
|
import time
|
|
9
10
|
import unicodedata
|
|
@@ -648,8 +649,14 @@ class InstitutionMixin:
|
|
|
648
649
|
where = str(event.get("detail", "")).split(" @ ", 1)[-1]
|
|
649
650
|
return event["state"] == "auto_institution_search" and self._same_address(where, url)
|
|
650
651
|
|
|
651
|
-
|
|
652
|
+
searches = [index for index, e in enumerate(result.events) if searched_here(e)]
|
|
653
|
+
if not searches:
|
|
652
654
|
return False # nothing searched here: a page's other lists say nothing
|
|
655
|
+
if any(e["state"] == "institution_selected" for e in result.events[searches[-1]:]):
|
|
656
|
+
# Its entry was chosen after that search: the list has the school, and the
|
|
657
|
+
# page is on its way to the school's login (Science sent its login page back,
|
|
658
|
+
# the second choice was still leaving it, 2026-11-15).
|
|
659
|
+
return False
|
|
653
660
|
others = sorted({str(it.get("t") or "")[:80] for score, it in scored if score == 1})
|
|
654
661
|
# A unit of the school (its library, campus, a faculty) may be its way in,
|
|
655
662
|
# unless its publisher marks it as signing in no one (IP, VPN, email).
|
|
@@ -780,10 +787,21 @@ class InstitutionMixin:
|
|
|
780
787
|
raise
|
|
781
788
|
return True # not readable now: nothing concluded from it
|
|
782
789
|
|
|
790
|
+
# The site's own line naming the institution it serves the reader for ("brought to
|
|
791
|
+
# you by <school>" in Science's header, 2026-11-15) is no entry of a list.
|
|
792
|
+
_SESSION_BANNER = re.compile(r"\s*(?:brought to you by|access (?:provided|funded) by)", re.I)
|
|
793
|
+
|
|
794
|
+
def _listed_entries(self, page: Any) -> Any:
|
|
795
|
+
"""The entries a page lists now (``_ENTRIES_JS``), the site's session banner aside."""
|
|
796
|
+
items = page.evaluate(self._ENTRIES_JS, self._ENTRY_SELECTOR)
|
|
797
|
+
if not isinstance(items, list):
|
|
798
|
+
return items
|
|
799
|
+
return [it for it in items if not (isinstance(it, dict) and self._SESSION_BANNER.match(str(it.get("t") or "")))]
|
|
800
|
+
|
|
783
801
|
def _entry_texts(self, page: Any) -> set[str]:
|
|
784
802
|
"""The entries a page lists now, by their text (``_ENTRIES_JS``)."""
|
|
785
803
|
try:
|
|
786
|
-
items =
|
|
804
|
+
items = self._listed_entries(page)
|
|
787
805
|
except Exception as exc:
|
|
788
806
|
if not _is_browser_error(exc):
|
|
789
807
|
raise
|
|
@@ -802,7 +820,7 @@ class InstitutionMixin:
|
|
|
802
820
|
list, 2026-11-01).
|
|
803
821
|
"""
|
|
804
822
|
try:
|
|
805
|
-
items =
|
|
823
|
+
items = self._listed_entries(page)
|
|
806
824
|
except Exception:
|
|
807
825
|
return False
|
|
808
826
|
if not isinstance(items, list):
|
|
@@ -1314,14 +1332,17 @@ class InstitutionMixin:
|
|
|
1314
1332
|
@staticmethod
|
|
1315
1333
|
def _carries_entity_id(text: str, entity_id: str) -> bool:
|
|
1316
1334
|
"""True when ``text`` (an entry's link, data attributes and hidden fields) names
|
|
1317
|
-
exactly ``entity_id``, plain, URL-encoded once or twice, or JSON-escaped
|
|
1335
|
+
exactly ``entity_id``, plain, URL-encoded once or twice, or JSON-escaped, or by
|
|
1336
|
+
its SHA-1 as discovery services write it ("{sha1}<hex>": a chooser listing a
|
|
1337
|
+
school's federation entry and its OpenAthens one under one name, 2026-11-14)."""
|
|
1318
1338
|
if not entity_id or not text:
|
|
1319
1339
|
return False
|
|
1320
1340
|
decoded = [text]
|
|
1321
1341
|
for _ in range(2):
|
|
1322
1342
|
decoded.append(unquote(decoded[-1]))
|
|
1323
1343
|
pattern = re.compile(r"(?<![\w.:/-])" + re.escape(entity_id) + r"(?![\w.:/-])")
|
|
1324
|
-
|
|
1344
|
+
hashed = re.compile(r"\{sha1\}" + hashlib.sha1(entity_id.encode()).hexdigest() + r"(?![0-9a-f])", re.I)
|
|
1345
|
+
return any(pattern.search(t.replace("\\/", "/")) or hashed.search(t) for t in decoded)
|
|
1325
1346
|
|
|
1326
1347
|
def _on_school_login_page(self, url: str) -> bool:
|
|
1327
1348
|
"""The configured school's own login page on a service shared by many
|
|
@@ -376,7 +376,8 @@ def _try_builtin_institutional(
|
|
|
376
376
|
"action": primary["action"], "source_failures": failures}
|
|
377
377
|
if primary["error_type"] == "access_blocked":
|
|
378
378
|
_remember_blocked_journal(doi, identity)
|
|
379
|
-
if primary["error_type"] == "institution_federation_unavailable" and manual_school
|
|
379
|
+
if (primary["error_type"] == "institution_federation_unavailable" and manual_school
|
|
380
|
+
and (primary.get("artifacts") or {}).get("route_missing")):
|
|
380
381
|
_remember_missing_route(publisher_name, config, doi)
|
|
381
382
|
if "reason_code" in primary:
|
|
382
383
|
result["reason_code"] = primary["reason_code"]
|
|
@@ -711,6 +712,11 @@ def _write_exception_diagnostic(run_dir: Path, doi: str, exc: Exception, *,
|
|
|
711
712
|
return str(path)
|
|
712
713
|
|
|
713
714
|
|
|
715
|
+
#: Where a wait on a school login can end (``BatchLoginMixin._login_wait_page``).
|
|
716
|
+
LOGIN_WAIT_PAGES = ("school_login", "school_choice", "institution_chooser", "authentication_redirect",
|
|
717
|
+
"publisher", "other", "closed")
|
|
718
|
+
|
|
719
|
+
|
|
714
720
|
def _browser_artifacts(result: Any, profile: Any) -> dict[str, str]:
|
|
715
721
|
"""Where the browser run left its record (success) or diagnostic packet (failure).
|
|
716
722
|
|
|
@@ -725,6 +731,18 @@ def _browser_artifacts(result: Any, profile: Any) -> dict[str, str]:
|
|
|
725
731
|
"diagnostic": str(getattr(result, "diagnostic_path", "") or ""),
|
|
726
732
|
"state": state if re.fullmatch(r"[a-z0-9_]{1,64}", state) else "",
|
|
727
733
|
}
|
|
734
|
+
# The publisher's list was seen without the school in this run, and the school was
|
|
735
|
+
# chosen nowhere in it: only this is remembered as no route (``login_routes``); an
|
|
736
|
+
# article that ended on the earlier finding, or whose school was chosen, is not.
|
|
737
|
+
events = getattr(result, "events", None) or []
|
|
738
|
+
if getattr(result, "_institution_not_listed", False) is True and not any(
|
|
739
|
+
isinstance(e, dict) and e.get("state") == "institution_selected" for e in events):
|
|
740
|
+
artifacts["route_missing"] = True
|
|
741
|
+
# Where a wait on a school login ended (``_login_wait_page``): a fixed word. The caller
|
|
742
|
+
# holds a publisher only on the school's own sign-in page (2026-11-15).
|
|
743
|
+
wait_page = str(getattr(result, "login_wait_page", "") or "")
|
|
744
|
+
if wait_page in LOGIN_WAIT_PAGES:
|
|
745
|
+
artifacts["login_wait_page"] = wait_page
|
|
728
746
|
# The school's site the login stopped on: a host name only, for the message.
|
|
729
747
|
host = str(getattr(result, "_stopped_host", "") or "").lower()
|
|
730
748
|
if state == "idp_no_return_to_publisher" and re.fullmatch(r"[a-z0-9-]+(?:\.[a-z0-9-]+)+", host) and len(host) <= 253:
|
|
@@ -42,6 +42,8 @@ class UserStoppedBatch(UserMarkedNoEntitlement):
|
|
|
42
42
|
# Not an entitlement decision: nothing is recorded, the batch ends.
|
|
43
43
|
STOP_BATCH = "stop_batch"
|
|
44
44
|
SHOW_BROWSER = "show_browser"
|
|
45
|
+
# The user is back: a publisher the batch held goes on (``resume_path``).
|
|
46
|
+
RESUME_HELD = "resume_held"
|
|
45
47
|
|
|
46
48
|
|
|
47
49
|
SKIP = "skip"
|
|
@@ -204,6 +206,31 @@ def request_action(current: str, action: str, run_id: str = "") -> None:
|
|
|
204
206
|
_write_json(control_path(), data)
|
|
205
207
|
|
|
206
208
|
|
|
209
|
+
def resume_path() -> Path:
|
|
210
|
+
return control_path().with_name("resume.json")
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
def request_resume(key: str, batch_id: str) -> None:
|
|
214
|
+
"""The user asked the batch to go on with a publisher it holds (a DOI prefix)."""
|
|
215
|
+
data = _read_json(resume_path())
|
|
216
|
+
keys = list(data.get("keys") or []) if data.get("batch_id") == batch_id else []
|
|
217
|
+
if key not in keys:
|
|
218
|
+
keys.append(key)
|
|
219
|
+
_write_json(resume_path(), {"batch_id": batch_id, "keys": keys, "at": time.time()})
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
def take_resumes(batch_id: str) -> list[str]:
|
|
223
|
+
"""The publishers the user asked this batch to go on with, once (the caller's next report)."""
|
|
224
|
+
data = _read_json(resume_path())
|
|
225
|
+
if not batch_id or data.get("batch_id") != batch_id:
|
|
226
|
+
return []
|
|
227
|
+
try:
|
|
228
|
+
resume_path().unlink()
|
|
229
|
+
except OSError:
|
|
230
|
+
pass
|
|
231
|
+
return [str(key) for key in data.get("keys") or [] if isinstance(key, str)]
|
|
232
|
+
|
|
233
|
+
|
|
207
234
|
def batch_stop_requested() -> bool:
|
|
208
235
|
"""A durable stop for the current run, including the gap between papers."""
|
|
209
236
|
stop = _read_json(control_path().with_name("stop.json"))
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"code": "aaf",
|
|
3
|
+
"name": "AAF",
|
|
4
|
+
"country": "AU",
|
|
5
|
+
"registration_authorities": ["https://aaf.edu.au"],
|
|
6
|
+
"chooser_labels": ["Australian Access Federation", "AAF"],
|
|
7
|
+
"chooser_pattern": "\\bAustralian\\s+Access\\s+Federation\\b|(?-i:\\bAAF\\b)",
|
|
8
|
+
"discovery_hosts": [],
|
|
9
|
+
"service_domains": ["ds.aaf.edu.au"],
|
|
10
|
+
"metadata_url": "https://md.aaf.edu.au/aaf-edugain-export-metadata.xml"
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"code": "caf",
|
|
3
|
+
"name": "CAF",
|
|
4
|
+
"country": "CA",
|
|
5
|
+
"registration_authorities": ["http://www.canarie.ca"],
|
|
6
|
+
"chooser_labels": ["Canadian Access Federation", "CAF", "Fédération canadienne d'accès"],
|
|
7
|
+
"chooser_pattern": "\\bCanadian\\s+Access\\s+Federation\\b|F[ée]d[ée]ration\\s+canadienne\\s+d.acc[eè]s|(?-i:\\bCAF\\b)",
|
|
8
|
+
"discovery_hosts": [],
|
|
9
|
+
"service_domains": [],
|
|
10
|
+
"metadata_url": "https://caf-shib2ops.ca/CoreServices/edugain_caf_metadata_signed.xml"
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"code": "cafe",
|
|
3
|
+
"name": "CAFe",
|
|
4
|
+
"country": "BR",
|
|
5
|
+
"registration_authorities": ["http://cafe.rnp.br"],
|
|
6
|
+
"chooser_labels": ["CAFe", "Comunidade Acadêmica Federada"],
|
|
7
|
+
"chooser_pattern": "(?-i:\\bCAFe\\b)|\\bComunidade\\s+Acad[eê]mica\\s+Federada\\b",
|
|
8
|
+
"discovery_hosts": [],
|
|
9
|
+
"service_domains": ["ds.cafe.rnp.br"],
|
|
10
|
+
"metadata_url": "https://ds.cafe.rnp.br/metadata/edugain/edugain-metadata.signed.xml"
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"code": "cofre",
|
|
3
|
+
"name": "COFRe",
|
|
4
|
+
"country": "CL",
|
|
5
|
+
"registration_authorities": ["http://cofre.reuna.cl"],
|
|
6
|
+
"chooser_labels": ["COFRe", "Comunidad Federada REUNA"],
|
|
7
|
+
"chooser_pattern": "(?-i:\\bCOFR[Ee]\\b)|\\bComunidad\\s+Federada\\s+REUNA\\b",
|
|
8
|
+
"discovery_hosts": [],
|
|
9
|
+
"service_domains": [],
|
|
10
|
+
"metadata_url": "http://cofre.reuna.cl/edugain/cofre-edugain-metadata-256-v2.xml"
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"code": "colfire",
|
|
3
|
+
"name": "COLFIRE",
|
|
4
|
+
"country": "CO",
|
|
5
|
+
"registration_authorities": ["http://colfire.co"],
|
|
6
|
+
"chooser_labels": ["COLFIRE"],
|
|
7
|
+
"chooser_pattern": "\\bCOLFIRE\\b",
|
|
8
|
+
"discovery_hosts": [],
|
|
9
|
+
"service_domains": [],
|
|
10
|
+
"metadata_url": "http://ds.renata.edu.co/edugain/colfire-edugain.xml"
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"code": "eduidbf",
|
|
3
|
+
"name": "eduID.bf",
|
|
4
|
+
"country": "BF",
|
|
5
|
+
"registration_authorities": ["https://www.eduid.bf"],
|
|
6
|
+
"chooser_labels": ["eduID.bf", "Burkina Faso Identity Federation"],
|
|
7
|
+
"chooser_pattern": "\\beduID\\.bf\\b|\\bBurkina\\s+Faso\\s+Identity\\s+Federation\\b",
|
|
8
|
+
"discovery_hosts": [],
|
|
9
|
+
"service_domains": [],
|
|
10
|
+
"metadata_url": "https://registry.eduid.africa/signedmetadata/federation/FASOREN/metadata.xml"
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"code": "eduidma",
|
|
3
|
+
"name": "eduIDM",
|
|
4
|
+
"country": "MA",
|
|
5
|
+
"registration_authorities": ["https://eduidm.ma"],
|
|
6
|
+
"chooser_labels": ["eduIDM.ma", "eduIDM"],
|
|
7
|
+
"chooser_pattern": "\\beduIDM\\b",
|
|
8
|
+
"discovery_hosts": [],
|
|
9
|
+
"service_domains": [],
|
|
10
|
+
"metadata_url": "https://www.eduidm.ma/metadata/eduidm.xml"
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"code": "eduidtg",
|
|
3
|
+
"name": "eduID.tg",
|
|
4
|
+
"country": "TG",
|
|
5
|
+
"registration_authorities": ["https://www.eduid.tg"],
|
|
6
|
+
"chooser_labels": ["eduID.tg"],
|
|
7
|
+
"chooser_pattern": "\\beduID\\.tg\\b",
|
|
8
|
+
"discovery_hosts": [],
|
|
9
|
+
"service_domains": [],
|
|
10
|
+
"metadata_url": "https://registry.eduid.africa/signedmetadata/federation/eduid_tg/metadata.xml"
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"code": "fenix",
|
|
3
|
+
"name": "FENIX",
|
|
4
|
+
"country": "MX",
|
|
5
|
+
"registration_authorities": ["http://www.fenix.org.mx"],
|
|
6
|
+
"chooser_labels": ["FENIX", "Federación Nacional de Identidades Mexicanas"],
|
|
7
|
+
"chooser_pattern": "(?-i:\\bFENIX\\b)|\\bFederaci[oó]n\\s+Nacional\\s+de\\s+Identidades\\b",
|
|
8
|
+
"discovery_hosts": [],
|
|
9
|
+
"service_domains": ["wayf.fenix.org.mx"],
|
|
10
|
+
"metadata_url": "https://wayf.fenix.org.mx/simplesaml/module.php/aggregator2/get.php?id=FENIX"
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"code": "fidern",
|
|
3
|
+
"name": "FIDERN",
|
|
4
|
+
"country": "ZM",
|
|
5
|
+
"registration_authorities": ["https://fidern.ac.zm"],
|
|
6
|
+
"chooser_labels": ["FIDERN"],
|
|
7
|
+
"chooser_pattern": "\\bFIDERN\\b",
|
|
8
|
+
"discovery_hosts": [],
|
|
9
|
+
"service_domains": [],
|
|
10
|
+
"metadata_url": "https://rr.fidern.ac.zm/signedmetadata/federation/fidern/metadata.xml"
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"code": "garnet",
|
|
3
|
+
"name": "GARNET",
|
|
4
|
+
"country": "GH",
|
|
5
|
+
"registration_authorities": ["https://garnet.edu.gh"],
|
|
6
|
+
"chooser_labels": ["GARNET Identity Federation", "GARNET"],
|
|
7
|
+
"chooser_pattern": "(?-i:\\bGARNET\\b)",
|
|
8
|
+
"discovery_hosts": [],
|
|
9
|
+
"service_domains": [],
|
|
10
|
+
"metadata_url": "https://metareg.garnet.edu.gh/rr3/signedmetadata/federation/GARNET-Identity-Federation/metadata.xml"
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"code": "maren",
|
|
3
|
+
"name": "MAREN",
|
|
4
|
+
"country": "MW",
|
|
5
|
+
"registration_authorities": ["https://maren.ac.mw"],
|
|
6
|
+
"chooser_labels": ["MAREN Identity Federation", "MAREN"],
|
|
7
|
+
"chooser_pattern": "(?-i:\\bMAREN\\b)",
|
|
8
|
+
"discovery_hosts": [],
|
|
9
|
+
"service_domains": [],
|
|
10
|
+
"metadata_url": "http://federation.maren.ac.mw/metadata/national-fede-metadata.xml"
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"code": "minga",
|
|
3
|
+
"name": "MINGA",
|
|
4
|
+
"country": "EC",
|
|
5
|
+
"registration_authorities": ["https://minga.cedia.org.ec"],
|
|
6
|
+
"chooser_labels": ["MINGA"],
|
|
7
|
+
"chooser_pattern": "(?-i:\\bMINGA\\b)",
|
|
8
|
+
"discovery_hosts": [],
|
|
9
|
+
"service_domains": [],
|
|
10
|
+
"metadata_url": "https://minga.cedia.org.ec/metadata/minga-metadata-edugain.xml"
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"code": "ngrenid",
|
|
3
|
+
"name": "NgRENID",
|
|
4
|
+
"country": "NG",
|
|
5
|
+
"registration_authorities": ["https://ngren.edu.ng/"],
|
|
6
|
+
"chooser_labels": ["NgRENID"],
|
|
7
|
+
"chooser_pattern": "\\bNgRENID\\b",
|
|
8
|
+
"discovery_hosts": [],
|
|
9
|
+
"service_domains": [],
|
|
10
|
+
"metadata_url": "https://md.ngrenid.ngren.edu.ng/metadata/ngrenid-edugain-metadata.xml"
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"code": "rafiki",
|
|
3
|
+
"name": "RAFIKI",
|
|
4
|
+
"country": "KE",
|
|
5
|
+
"registration_authorities": ["https://rafiki.ke"],
|
|
6
|
+
"chooser_labels": ["Kenyan Identity Federation - RAFIKI", "RAFIKI"],
|
|
7
|
+
"chooser_pattern": "(?-i:\\bRAFIKI\\b)|\\bKenyan\\s+Identity\\s+Federation\\b",
|
|
8
|
+
"discovery_hosts": [],
|
|
9
|
+
"service_domains": [],
|
|
10
|
+
"metadata_url": "https://rr.rafiki.ke/signedmetadata/federation/rafiki/metadata.xml"
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"code": "rif",
|
|
3
|
+
"name": "RIF",
|
|
4
|
+
"country": "UG",
|
|
5
|
+
"registration_authorities": ["https://www.renu.ac.ug"],
|
|
6
|
+
"chooser_labels": ["RIF", "RENU Identity Federation"],
|
|
7
|
+
"chooser_pattern": "(?-i:\\bRIF\\b)|\\bRENU\\s+Identity\\s+Federation\\b",
|
|
8
|
+
"discovery_hosts": [],
|
|
9
|
+
"service_domains": [],
|
|
10
|
+
"metadata_url": "https://rif.renu.ac.ug/rr/signedmetadata/federation/RIF/metadata.xml"
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"code": "safire",
|
|
3
|
+
"name": "SAFIRE",
|
|
4
|
+
"country": "ZA",
|
|
5
|
+
"registration_authorities": ["https://safire.ac.za"],
|
|
6
|
+
"chooser_labels": ["SAFIRE", "South African Identity Federation"],
|
|
7
|
+
"chooser_pattern": "(?-i:\\bSAFIRE\\b)|\\bSouth\\s+African\\s+Identity\\s+Federation\\b",
|
|
8
|
+
"discovery_hosts": [],
|
|
9
|
+
"service_domains": ["iziko.safire.ac.za", "proxy.safire.ac.za"],
|
|
10
|
+
"metadata_url": "https://metadata.safire.ac.za/safire-edugain.xml"
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"code": "ternet",
|
|
3
|
+
"name": "TERNET IF",
|
|
4
|
+
"country": "TZ",
|
|
5
|
+
"registration_authorities": ["https://tif.ternet.or.tz/"],
|
|
6
|
+
"chooser_labels": ["TERNET Identity Federation", "TERNET IF"],
|
|
7
|
+
"chooser_pattern": "\\bTERNET\\b",
|
|
8
|
+
"discovery_hosts": [],
|
|
9
|
+
"service_domains": [],
|
|
10
|
+
"metadata_url": "https://tif.ternet.or.tz/metadata.xml"
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"code": "tuakiri",
|
|
3
|
+
"name": "Tuakiri",
|
|
4
|
+
"country": "NZ",
|
|
5
|
+
"registration_authorities": ["https://tuakiri.ac.nz/"],
|
|
6
|
+
"chooser_labels": ["Tuakiri New Zealand Access Federation", "Tuakiri"],
|
|
7
|
+
"chooser_pattern": "\\bTuakiri\\b",
|
|
8
|
+
"discovery_hosts": [],
|
|
9
|
+
"service_domains": [],
|
|
10
|
+
"metadata_url": "https://directory.tuakiri.ac.nz/metadata/tuakiri-edugain-export.xml"
|
|
11
|
+
}
|
|
@@ -146,6 +146,12 @@ def save(config: dict[str, Any], school: School) -> None:
|
|
|
146
146
|
pages = [page for template in (federation.school_login_pages if federation else ())
|
|
147
147
|
for page in ([template.replace("{scope}", scope) for scope in scopes] if "{scope}" in template
|
|
148
148
|
else [template])]
|
|
149
|
+
# Its own sign-in page on a login service shared by schools (OpenAthens), named by
|
|
150
|
+
# its domain: a publisher may list only that entry of the school (its library's,
|
|
151
|
+
# 2026-11-14).
|
|
152
|
+
pages += [template.replace("*", scope, 1) for service in all_federations()
|
|
153
|
+
if service.kind == "service" and service is not federation
|
|
154
|
+
for template in service.school_login_pages if "*" in template for scope in scopes if "." in scope]
|
|
149
155
|
config.update(school_name=school.name, school_name_en=school.name_en, school_entry_name=school.entry_name,
|
|
150
156
|
idp_entity_id=school.entity_id, idp_login_hosts=list(school.login_hosts), idp_login_pages=pages,
|
|
151
157
|
idp_domains=[d for d in scopes if "." in d],
|
|
@@ -377,16 +383,19 @@ def _from_seamlessaccess(given: list[str], config: dict[str, Any], found: _Found
|
|
|
377
383
|
if federation.member_list == "carsi" and carsi_listed:
|
|
378
384
|
continue # CARSI's own list is the source for its schools
|
|
379
385
|
english = listed_english = _SERVER_WORD.sub("", str((row.get("title_langs") or {}).get("en") or title)).strip()
|
|
386
|
+
part = ""
|
|
380
387
|
if exact:
|
|
381
388
|
# The English name given, publishers' likelier name for the school, when the
|
|
382
389
|
# list has none of its own: the school only as part of a longer name ("<school>
|
|
383
|
-
# - Staff"), or one name in every language ("Universitat de
|
|
390
|
+
# - Staff", "<ABBR> - <school>"), or one name in every language ("Universitat de
|
|
391
|
+
# Liman", 2026-11-13). The names given beside the first are the English ones;
|
|
392
|
+
# accents allowed ("University of São Liman", 2026-11-14).
|
|
384
393
|
listed = {_key(v) for v in [*(row.get("title_langs") or {}).values(), title] if str(v or "").strip()}
|
|
385
394
|
own = _own_names(given)
|
|
386
|
-
other = [t for t in [*own[1:], *own[:1]] if t.isascii() and _key(t) not in listed]
|
|
387
395
|
parts = {_key(n) for n in titles}
|
|
388
|
-
|
|
389
|
-
|
|
396
|
+
part = next((" ".join(t.split()) for t in own if _key(t) in parts and _key(t) not in listed), "")
|
|
397
|
+
other = [t for t in [*own[1:], *own[:1]] if _plain(t).isascii() and _key(t) not in listed]
|
|
398
|
+
english = other[0] if other and (part or len(listed) == 1) else listed_english
|
|
390
399
|
# The name in the school's own language when that is the one given: publishers
|
|
391
400
|
# may list it so (a French name searched in English found nothing, 2026-11-13).
|
|
392
401
|
# Spaces as written once (a Greek name listed with a trailing space, 2026-11-13).
|
|
@@ -491,6 +500,17 @@ def _named_as_given(school: School, given: list[str]) -> School:
|
|
|
491
500
|
return replace(school, name=own[0], name_en=english, entry_name=school.name)
|
|
492
501
|
|
|
493
502
|
|
|
503
|
+
def _named_by_its_part(school: School, given: list[str]) -> School:
|
|
504
|
+
"""A school listed under a longer name, an abbreviation or code beside the
|
|
505
|
+
school's ("<ABBR> - <school>", "<school> - <code>", 2026-11-14), and found by
|
|
506
|
+
that part: named as given, the name publishers list it under; the listed name
|
|
507
|
+
is its entry's own, searched last."""
|
|
508
|
+
parts = {_key(n) for n in _names([school.name])}
|
|
509
|
+
part = next((" ".join(t.split()) for t in _own_names(given)
|
|
510
|
+
if _key(t) in parts and _key(t) != _key(school.name)), "")
|
|
511
|
+
return replace(school, name=part, entry_name=school.name) if part else school
|
|
512
|
+
|
|
513
|
+
|
|
494
514
|
def find(query: str, config: dict[str, Any], data_dir: Path, *, also: Iterable[str] = ()) -> Lookup:
|
|
495
515
|
"""The school named ``query`` (any language, its domain or entityID), with
|
|
496
516
|
``also`` its other names (the English one, given by the caller)."""
|
|
@@ -505,6 +525,8 @@ def find(query: str, config: dict[str, Any], data_dir: Path, *, also: Iterable[s
|
|
|
505
525
|
school, candidates = found.decide()
|
|
506
526
|
if school is not None and school.entity_id not in found.named:
|
|
507
527
|
school = _named_as_given(school, given)
|
|
528
|
+
elif school is not None:
|
|
529
|
+
school = _named_by_its_part(school, given)
|
|
508
530
|
lookup.school = _with_login_hosts(school, config, data_dir) if school else None
|
|
509
531
|
lookup.candidates = candidates[:10]
|
|
510
532
|
return lookup
|
|
@@ -225,8 +225,17 @@ class Api:
|
|
|
225
225
|
def act(self, action: str, current: str, run_id: str = "") -> str:
|
|
226
226
|
"""Control the running download, including showing its browser on request."""
|
|
227
227
|
try:
|
|
228
|
-
from .entitlements import SHOW_BROWSER, request_action
|
|
228
|
+
from .entitlements import RESUME_HELD, SHOW_BROWSER, request_action, request_resume
|
|
229
229
|
|
|
230
|
+
if action == RESUME_HELD:
|
|
231
|
+
# The user is back: every publisher the batch holds goes on.
|
|
232
|
+
state = read_state() or {}
|
|
233
|
+
held = [str(entry["key"]) for entry in state.get("held") or [] if isinstance(entry, dict) and entry.get("key")]
|
|
234
|
+
if state.get("status") != "running" or str(state.get("run_id") or "") != run_id or not held:
|
|
235
|
+
return "这批下载已没有暂停的篇目"
|
|
236
|
+
for key in held:
|
|
237
|
+
request_resume(key, str(state.get("batch_id") or ""))
|
|
238
|
+
return progress_view.ACTION_FEEDBACK[RESUME_HELD]
|
|
230
239
|
if action == SHOW_BROWSER:
|
|
231
240
|
# Asked for from a reminder, or from the paper on the card at any
|
|
232
241
|
# time while it has a browser (user request, 2026-11-08).
|
|
@@ -295,6 +295,8 @@ def _adopt_batch(batch_id: str, total: int, counts: tuple[int | None, int | None
|
|
|
295
295
|
and not _STATE.get("awaiting_next")):
|
|
296
296
|
done, succeeded, failed = counts
|
|
297
297
|
_STATE.update(total=int(total), lanes=fields.get("lanes", ""),
|
|
298
|
+
**({"held": fields["held"]} if "held" in fields else {}),
|
|
299
|
+
**({"held_wait": fields["held_wait"]} if "held_wait" in fields else {}),
|
|
298
300
|
**({"done": done} if done is not None else {}),
|
|
299
301
|
**({"success": succeeded} if succeeded is not None else {}),
|
|
300
302
|
**({"failed": failed} if failed is not None else {}))
|
|
@@ -335,9 +337,28 @@ def _adopt_batch(batch_id: str, total: int, counts: tuple[int | None, int | None
|
|
|
335
337
|
return True
|
|
336
338
|
|
|
337
339
|
|
|
340
|
+
_HELD_KEY = re.compile(r"10\.\d{4,9}/")
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
def _held(raw: Any) -> list[dict[str, Any]]:
|
|
344
|
+
"""The publishers whose papers the caller holds (their school login stopped working
|
|
345
|
+
mid-batch): [{key (a DOI prefix), name, count}], at most four, checked for the window."""
|
|
346
|
+
held: list[dict[str, Any]] = []
|
|
347
|
+
for entry in raw if isinstance(raw, list) else []:
|
|
348
|
+
if not isinstance(entry, dict) or not _HELD_KEY.fullmatch(str(entry.get("key") or "")):
|
|
349
|
+
continue
|
|
350
|
+
count = entry.get("count")
|
|
351
|
+
if not isinstance(count, int) or isinstance(count, bool) or not 0 < count <= 1_000_000:
|
|
352
|
+
continue
|
|
353
|
+
name = _short_line(entry.get("name"), 40) or entry["key"]
|
|
354
|
+
held.append({"key": entry["key"], "name": name, "count": count})
|
|
355
|
+
return held[:4]
|
|
356
|
+
|
|
357
|
+
|
|
338
358
|
def sync_batch(batch_id: str, total: int, done: int, succeeded: int, failed: int, *,
|
|
339
359
|
current: str = "", finished: bool = False, results: Any = None,
|
|
340
|
-
phase: str = "", channel: str = "", lanes: str = ""
|
|
360
|
+
phase: str = "", channel: str = "", lanes: str = "", held: Any = None,
|
|
361
|
+
held_wait: bool = False) -> bool:
|
|
341
362
|
"""Record batch totals for items finished without the backend, or the batch end.
|
|
342
363
|
|
|
343
364
|
``results`` (the batch end only) is the caller's summary of every item,
|
|
@@ -348,7 +369,10 @@ def sync_batch(batch_id: str, total: int, done: int, succeeded: int, failed: int
|
|
|
348
369
|
short single lines and are dropped at the batch end. ``lanes`` is one line on
|
|
349
370
|
what each lane got in a batch whose open-access checks run beside its downloads;
|
|
350
371
|
it may come while a download of the batch runs, which then keeps its paper,
|
|
351
|
-
stage and prompts (``_adopt_batch``).
|
|
372
|
+
stage and prompts (``_adopt_batch``). ``held``: the publishers the caller holds
|
|
373
|
+
(``_held``), each with a button to go on with them; an empty list clears them.
|
|
374
|
+
``held_wait``: nothing else is left and the batch waits for the user to go on with
|
|
375
|
+
them or end it (each report says it again; any other report, or a download, ends it)."""
|
|
352
376
|
ctx = BatchContext.from_args(batch_id, max(1, min(done, total)), total, done, succeeded, failed)
|
|
353
377
|
if ctx is None or done > total:
|
|
354
378
|
return False
|
|
@@ -361,6 +385,8 @@ def sync_batch(batch_id: str, total: int, done: int, succeeded: int, failed: int
|
|
|
361
385
|
beside_download=bool(lanes) and not finished,
|
|
362
386
|
**({"current": current} if current else {}),
|
|
363
387
|
**({"lanes": lanes} if lanes or finished else {}),
|
|
388
|
+
**({"held": [] if finished else _held(held)} if held is not None or finished else {}),
|
|
389
|
+
held_wait=bool(held_wait) and not finished,
|
|
364
390
|
stage="saved_pending_verification" if finished else "starting",
|
|
365
391
|
channel="" if finished else channel,
|
|
366
392
|
phase=(f"批量下载结束:成功 {succeeded},失败 {failed}" if finished
|
|
@@ -572,6 +598,7 @@ def tracked_download(current: str, output_dir: Any = None, batch: BatchContext |
|
|
|
572
598
|
_notify_stage("starting", current)
|
|
573
599
|
with _LOCK:
|
|
574
600
|
_STATE.pop("hourly_wait", None) # this article runs: no longer held by the hourly limit
|
|
601
|
+
_STATE.pop("held_wait", None) # nor waiting for the user to go on with held publishers
|
|
575
602
|
update(content=content if content in ("main", "supplements", "both") else "main")
|
|
576
603
|
if output_dir:
|
|
577
604
|
set_output_dir(output_dir)
|