papersearch 0.6.4 → 0.6.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/README.en.md +6 -2
  2. package/README.md +6 -2
  3. package/dist/capabilities/pdf-discovery/school/SchoolMcpClient.js +1 -1
  4. package/package.json +1 -1
  5. package/school/paper_search_school/adapters/sage/__init__.py +9 -1
  6. package/school/paper_search_school/cli.py +1 -1
  7. package/school/paper_search_school/config.py +2 -0
  8. package/school/paper_search_school/engine/batch_institution.py +66 -24
  9. package/school/paper_search_school/engine/batch_login.py +24 -6
  10. package/school/paper_search_school/federations/builtin/aaieduhr.json +11 -0
  11. package/school/paper_search_school/federations/builtin/aaiedumk.json +11 -0
  12. package/school/paper_search_school/federations/builtin/aconet.json +11 -0
  13. package/school/paper_search_school/federations/builtin/arnesaai.json +11 -0
  14. package/school/paper_search_school/federations/builtin/bif.json +11 -0
  15. package/school/paper_search_school/federations/builtin/dfnaai.json +11 -0
  16. package/school/paper_search_school/federations/builtin/eduidcz.json +11 -0
  17. package/school/paper_search_school/federations/builtin/eduidhu.json +11 -0
  18. package/school/paper_search_school/federations/builtin/febas.json +11 -0
  19. package/school/paper_search_school/federations/builtin/feide.json +11 -0
  20. package/school/paper_search_school/federations/builtin/grnet.json +11 -0
  21. package/school/paper_search_school/federations/builtin/haka.json +11 -0
  22. package/school/paper_search_school/federations/builtin/iamres.json +11 -0
  23. package/school/paper_search_school/federations/builtin/idedume.json +11 -0
  24. package/school/paper_search_school/federations/builtin/idem.json +11 -0
  25. package/school/paper_search_school/federations/builtin/laife.json +11 -0
  26. package/school/paper_search_school/federations/builtin/leaf.json +11 -0
  27. package/school/paper_search_school/federations/builtin/litnet.json +11 -0
  28. package/school/paper_search_school/federations/builtin/peano.json +11 -0
  29. package/school/paper_search_school/federations/builtin/pionierid.json +11 -0
  30. package/school/paper_search_school/federations/builtin/rash.json +11 -0
  31. package/school/paper_search_school/federations/builtin/rctsaai.json +11 -0
  32. package/school/paper_search_school/federations/builtin/ricerkanet.json +11 -0
  33. package/school/paper_search_school/federations/builtin/roedunetid.json +11 -0
  34. package/school/paper_search_school/federations/builtin/safeid.json +11 -0
  35. package/school/paper_search_school/federations/builtin/sir.json +11 -0
  36. package/school/paper_search_school/federations/builtin/swamid.json +11 -0
  37. package/school/paper_search_school/federations/builtin/switchaai.json +11 -0
  38. package/school/paper_search_school/federations/builtin/taat.json +11 -0
  39. package/school/paper_search_school/federations/builtin/wayf.json +11 -0
  40. package/school/paper_search_school/federations/schools.py +38 -16
  41. package/school/paper_search_school/login_routes.py +6 -6
  42. package/school/paper_search_school/report_sanitizer.py +1 -1
  43. package/skills/paper-search/SKILL.md +1 -1
  44. package/skills/paper-search/references/federation-support.md +66 -1
  45. package/skills/paper-search/references/school-setup.md +3 -3
package/README.en.md CHANGED
@@ -142,10 +142,14 @@ Papers the open channels cannot get can come through your school's subscriptions
142
142
  | Asia | South Asia | India: INFED; Sri Lanka: LIAF; Bangladesh: TIGERfed; Pakistan: PKIFED |
143
143
  | Asia | West Asia | Turkey: YETKİM; Saudi Arabia: Maeen; Cyprus: CyNet; Israel: IUCC; Iran: IRFED; Azerbaijan: AzScienceNet; Oman: OMREN |
144
144
  | Europe | Western Europe | United Kingdom: UK federation; Ireland: Edugate; France: RENATER; Netherlands: SURFconext; Belgium: Belnet; Luxembourg: eduID Luxembourg |
145
+ | Europe | Northern Europe | Denmark (with Iceland and Greenland): WAYF; Sweden: SWAMID; Finland: Haka; Norway: Feide |
146
+ | Europe | Central Europe | Germany: DFN-AAI; Switzerland: Switch edu-ID; Austria: ACOnet; Poland: PIONIER.Id; Czechia: eduID.cz; Slovakia: safeID; Hungary: eduId.hu |
147
+ | Europe | Southern Europe | Spain: SIR; Portugal: RCTSaai; Italy: IDEM; Greece: GRNET; Malta: RiċerkaNET; Slovenia: ArnesAAI; Croatia: AAI@EduHr; Serbia: iAMRES; Montenegro: IDeduME; North Macedonia: AAIEduMk; Albania: RASH; Bulgaria: BIF; Romania: RoEduNetID |
148
+ | Europe | Eastern Europe | Estonia: TAAT; Latvia: LAIFE; Lithuania: LITNET FEDI; Belarus: FEBAS; Ukraine: PEANO; Moldova: LEAF |
145
149
  | Americas | North America | United States: InCommon |
146
150
 
147
151
  - Full names, school counts and tested schools of each federation: [federation support table](skills/paper-search/references/federation-support.md) (Chinese).
148
- - Planned, in this order: the rest of Europe (Northern, Central, Southern, Eastern), the Americas (Canada, then Latin America and the Caribbean), Oceania, and Africa last; see the [roadmap](docs/ROADMAP.zh.md) (Chinese).
152
+ - Planned, in this order: the Americas (Canada, then Latin America and the Caribbean), Oceania, and Africa last; see the [roadmap](docs/ROADMAP.zh.md) (Chinese).
149
153
 
150
154
  - **Your school account is enough**: no keys to apply for; publisher API keys only cover Elsevier and Springer.
151
155
  - **Deep publisher adaptation**: the general download flow is deeply optimized, and more than 30 publishers have dedicated rules, one by one: where the institutional login is and how to fetch the PDF and supplementary files follow each publisher as it really is, so downloads are more accurate and fewer papers are missed. The main publishers:
@@ -237,7 +241,7 @@ Next on the list:
237
241
  1. **A better progress capsule**: better-timed reminders, with no early prompt when the school login page lets you through by itself; less of the browser briefly jumping to the front on Windows when it starts or changes pages; a cleaner look.
238
242
  2. **Parallel downloads**: papers from different publishers download at the same time, cutting the total time for dozens or hundreds of papers; each publisher's download limits still apply.
239
243
  3. **A Markdown full-text package**: besides the PDF, the original XML/HTML, a Markdown reading copy and the figures, with figure numbers, captions and in-text references matched, ready to hand to an AI for reading and citing.
240
- 4. **School sign-in worldwide**: the academic identity federations of Asia are supported; next come the US, the UK, Australia and the federations of European countries, then every country in eduGAIN; WebVPN, EZProxy and similar where possible.
244
+ 4. **School sign-in worldwide**: the academic identity federations of Asia, Europe and the US are supported; next come Canada, Latin America and the Caribbean, Oceania, and Africa last, covering every country in eduGAIN; WebVPN, EZProxy and similar where possible.
241
245
  5. **Better paper search and full-text snippets**: learn from similar tools and improve how papers and passages are found.
242
246
 
243
247
  The full plan is in the [roadmap](docs/ROADMAP.zh.md) (Chinese); how it works inside is in the [architecture](docs/ARCHITECTURE.zh.md) (Chinese). Feature ideas are welcome as [issues](https://github.com/dr-dumpling/PaperSearch/issues/new/choose) and pull requests; for failed downloads or publisher requests use the matching issue template, and to add publisher rules yourself see [school/CONTRIBUTING.md](school/CONTRIBUTING.md).
package/README.md CHANGED
@@ -142,10 +142,14 @@ AI 会先问你要不要装 PaperSearch 的命令行程序,你同意后装好
142
142
  | 亚洲 | 南亚 | 印度:INFED;斯里兰卡:LIAF;孟加拉:TIGERfed;巴基斯坦:PKIFED |
143
143
  | 亚洲 | 西亚 | 土耳其:YETKİM;沙特阿拉伯:Maeen;塞浦路斯:CyNet;以色列:IUCC;伊朗:IRFED;阿塞拜疆:AzScienceNet;阿曼:OMREN |
144
144
  | 欧洲 | 西欧 | 英国:UK federation;爱尔兰:Edugate;法国:RENATER;荷兰:SURFconext;比利时:Belnet;卢森堡:eduID Luxembourg |
145
+ | 欧洲 | 北欧 | 丹麦(含冰岛、格陵兰):WAYF;瑞典:SWAMID;芬兰:Haka;挪威:Feide |
146
+ | 欧洲 | 中欧 | 德国:DFN-AAI;瑞士:Switch edu-ID;奥地利:ACOnet;波兰:PIONIER.Id;捷克:eduID.cz;斯洛伐克:safeID;匈牙利:eduId.hu |
147
+ | 欧洲 | 南欧 | 西班牙:SIR;葡萄牙:RCTSaai;意大利:IDEM;希腊:GRNET;马耳他:RiċerkaNET;斯洛文尼亚:ArnesAAI;克罗地亚:AAI@EduHr;塞尔维亚:iAMRES;黑山:IDeduME;北马其顿:AAIEduMk;阿尔巴尼亚:RASH;保加利亚:BIF;罗马尼亚:RoEduNetID |
148
+ | 欧洲 | 东欧 | 爱沙尼亚:TAAT;拉脱维亚:LAIFE;立陶宛:LITNET FEDI;白俄罗斯:FEBAS;乌克兰:PEANO;摩尔多瓦:LEAF |
145
149
  | 美洲 | 北美洲 | 美国:InCommon |
146
150
 
147
151
  - 各联盟的全称、学校数和实测过的学校,见 [学术联盟支持表](skills/paper-search/references/federation-support.md)。
148
- - 计划中,按这个顺序推进:欧洲其余地区(北欧、中欧、南欧、东欧)、美洲(加拿大,再拉丁美洲和加勒比)、大洋洲,最后非洲,见 [路线图](docs/ROADMAP.zh.md)。
152
+ - 计划中,按这个顺序推进:美洲(加拿大,再拉丁美洲和加勒比)、大洋洲,最后非洲,见 [路线图](docs/ROADMAP.zh.md)。
149
153
 
150
154
  - **学校账号就能用**:不用另外申请 key;出版社 API key 只覆盖 Elsevier、Springer 两家。
151
155
  - **深度适配出版社**:深度优化了下载的通用流程,并且针对 30 多家出版社逐家写了专门规则,机构登录入口在哪、PDF 和补充材料怎么取,都按各自出版社的实际情况来,下载更准、更少漏篇。优化的出版社主要有:
@@ -237,7 +241,7 @@ paper-search school status --format text # 查看是否装好
237
241
  1. **进度胶囊优化**:提醒时机更准,学校登录页能自动放行时不提前打扰;减少 Windows 上浏览器启动、换页时短暂跳到前台的情况,优化显示效果。
238
242
  2. **并行下载**:不同出版社之间并行下载,同时处理多篇,缩短几十上百篇的总耗时;每家出版社仍遵守下载上限。
239
243
  3. **Markdown 全文包**:除了 PDF,再交付原始 XML/HTML、Markdown 阅读副本和正文图片,图号、图注和正文引用一一对应,方便直接交给 AI 阅读和引用。
240
- 4. **全球学校登录**:亚洲的学术身份联盟已支持;接下来是美国、英国、澳大利亚和欧洲各国联盟,之后覆盖 eduGAIN 里的所有国家;有条件的话再接入 WebVPN、EZProxy 等访问方式。
244
+ 4. **全球学校登录**:亚洲、欧洲和美国的学术身份联盟已支持;接下来是加拿大、拉丁美洲和加勒比、大洋洲,最后非洲,覆盖 eduGAIN 里的所有国家;有条件的话再接入 WebVPN、EZProxy 等访问方式。
241
245
  5. **检索论文、搜正文片段再优化**:参考同类工具的做法,进一步提升检索论文和搜正文片段的效果。
242
246
 
243
247
  完整计划见 [路线图](docs/ROADMAP.zh.md),原理和代码结构见 [架构说明](docs/ARCHITECTURE.zh.md)。还想要什么功能,欢迎提 [Issue](https://github.com/dr-dumpling/PaperSearch/issues/new/choose) 和 PR;下载失败或想支持某家出版社,请用对应的 Issue 模板,想自己加出版社规则见 [school/CONTRIBUTING.md](school/CONTRIBUTING.md)。
@@ -20,7 +20,7 @@ export const SCHOOL_DOWNLOAD_TIMEOUT_MS = 1_200_000;
20
20
  export const SCHOOL_CLEANUP_TIMEOUT_MS = 5_000;
21
21
  const SCHOOL_BACKEND_SOURCE = "school";
22
22
  // MCP clientInfo is informational only; keep in step with package.json on release.
23
- const PAPER_SEARCH_MCP_CLIENT_VERSION = "0.6.4";
23
+ const PAPER_SEARCH_MCP_CLIENT_VERSION = "0.6.5";
24
24
  const NO_BATCH_SUPPORT = {
25
25
  downloadFields: false,
26
26
  supplementsField: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "papersearch",
3
- "version": "0.6.4",
3
+ "version": "0.6.5",
4
4
  "description": "PaperSearch: an agent-friendly command for searching and downloading academic papers from multiple sources.",
5
5
  "main": "dist/cli.js",
6
6
  "type": "module",
@@ -97,8 +97,16 @@ class SageAdapter(PublisherAdapter):
97
97
  and not page.locator('a[href*="/action/ssostart"]').count()):
98
98
  institution = page.get_by_role("button", name="Institution", exact=True)
99
99
  if not institution_opened and institution.count() and institution.first.is_visible():
100
- institution.first.click(timeout=5_000, no_wait_after=True)
101
100
  institution_opened = True
101
+ # Open already: a click would close it, and under an overlay it
102
+ # timed out and ended the article (2026-11-14).
103
+ if institution.first.get_attribute("aria-expanded") != "true":
104
+ try:
105
+ institution.first.click(timeout=5_000, no_wait_after=True)
106
+ except Exception as exc:
107
+ if not _is_browser_error(exc, "TimeoutError"):
108
+ raise
109
+ institution.first.evaluate("el => el.click()") # covered, as above
102
110
  page.wait_for_timeout(500)
103
111
  if not page.locator('a[href*="/action/ssostart"]').count():
104
112
  d._event(result, "sage_institution_link_missing", self._panel_text(page))
@@ -136,7 +136,7 @@ def _set_carsi_school(cfg: dict[str, Any], query: str) -> dict[str, Any] | None:
136
136
  return {"error": "carsi_school_ambiguous", "query": query, "count": len(candidates),
137
137
  "candidates": [s.summary() for s in candidates[:10]],
138
138
  "hint": "run again with the full name, the domain or the entityID of one candidate"}
139
- cfg.update(school_name=school.name, school_name_en=school.name_en, idp_entity_id=school.entity_id,
139
+ cfg.update(school_name=school.name, school_name_en=school.name_en, school_entry_name="", idp_entity_id=school.entity_id,
140
140
  idp_login_hosts=[], idp_login_pages=[], idp_domains=[school.domain] if school.domain else [])
141
141
  return None
142
142
 
@@ -28,6 +28,8 @@ DEFAULT_CONFIG: dict[str, Any] = {
28
28
  # Empty: the user picks in the window.
29
29
  "school_name": "",
30
30
  "school_name_en": "",
31
+ # A shared login entry's own name (a national one), when the school is saved by the user's name.
32
+ "school_entry_name": "",
31
33
  "idp_entity_id": "",
32
34
  "idp_login_hosts": [],
33
35
  # The school's own login pages on a service shared by many schools (OpenAthens).
@@ -6,6 +6,7 @@ from __future__ import annotations
6
6
 
7
7
  import re
8
8
  import time
9
+ import unicodedata
9
10
  from typing import Any
10
11
  from urllib.parse import parse_qs, unquote, urlencode, urljoin, urlparse
11
12
 
@@ -526,6 +527,22 @@ class InstitutionMixin:
526
527
 
527
528
  # CARSI writes some English names with a curly apostrophe ("Xi’an"), publisher lists a straight one.
528
529
  _QUOTES = str.maketrans({"\u2019": "'", "\u2018": "'"})
530
+ _FULL_WIDTH_BRACKETS = str.maketrans({"\uff08": "(", "\uff09": ")"})
531
+
532
+ @classmethod
533
+ def _comparable(cls, text: str) -> str:
534
+ """A name as entries and the school's names are compared: lower case, with
535
+ no accent (Latin, Greek) or punctuation, brackets kept (they hold a school's
536
+ other names). Publishers write names their own way: "Kita University St
537
+ Hanako" for a school listed as 'Kita University "St. Hanako"' (2026-11-13)."""
538
+ text = str(text or "").translate(cls._FULL_WIDTH_BRACKETS).replace("&", " and ")
539
+ text = re.sub(r"[\u0300-\u036f]", "", unicodedata.normalize("NFD", text))
540
+ text = re.sub(r"[^\w\s()]+|_", " ", unicodedata.normalize("NFC", text))
541
+ return " ".join(text.split()).lower()
542
+
543
+ # A login server's words after the school's name ("<entry> Single Sign-On Service",
544
+ # a national entry on Springer Nature's list, 2026-11-14), as ``_comparable`` writes them.
545
+ _LOGIN_SERVER_WORDS = r"(?: (?:idp|sso|identity provider|single sign on(?: service)?|login service))?"
529
546
 
530
547
  def _institution_match_score(self, text: str) -> int:
531
548
  """3 = exactly the configured school, 2 = "<school> University" or "<school>,
@@ -535,7 +552,7 @@ class InstitutionMixin:
535
552
  Parentheses that only repeat the school's other names keep the score of
536
553
  the name before them: Elsevier lists a school as "<Chinese name>(<English
537
554
  name>) (<English name>)", next to other schools whose names contain its own."""
538
- text = " ".join(str(text or "").translate(self._QUOTES).split()).lower().strip(" .,:;")
555
+ text = self._comparable(text)
539
556
  # Long English names fit: "华中科技大学(Huazhong University of Science and Technology) (...)".
540
557
  aliased = re.fullmatch(r"([^()]+?)((?:\s*\([^()]{1,120}\))+)", text)
541
558
  if aliased:
@@ -548,12 +565,13 @@ class InstitutionMixin:
548
565
  if self._name_residue(text) == "":
549
566
  return 3 # only the school's own names ("<Chinese name> <English name>")
550
567
  for name in self._institution_names():
551
- name = re.sub(r"^the ", "", " ".join(name.translate(self._QUOTES).split()).lower())
568
+ name = re.sub(r"^the ", "", self._comparable(name))
552
569
  if not name:
553
570
  continue
554
571
  if text == name:
555
572
  best = max(best, 3)
556
- elif re.fullmatch(re.escape(name) + r"(?: university)?(?:,? (?:the )?librar(?:y|ies))?(?: \([^)]{1,40}\))?", text):
573
+ elif re.fullmatch(re.escape(name) + r"(?: university)?(?:,? (?:the )?librar(?:y|ies))?(?: \([^)]{1,40}\))?"
574
+ + self._LOGIN_SERVER_WORDS, text):
557
575
  best = max(best, 2)
558
576
  elif name in text:
559
577
  best = max(best, 1)
@@ -593,9 +611,9 @@ class InstitutionMixin:
593
611
  def _name_residue(self, text: str) -> str | None:
594
612
  """What is left of ``text`` (lower case) once the school's names are taken
595
613
  out, as words; None when it holds none of them."""
596
- names = sorted({re.sub(r"^the ", "", " ".join(n.translate(self._QUOTES).split()).lower())
597
- for n in self._institution_names()} - {""}, key=len, reverse=True)
598
- rest, found = f" {text} ", False
614
+ names = sorted({re.sub(r"^the ", "", self._comparable(n)) for n in self._institution_names()} - {""},
615
+ key=len, reverse=True)
616
+ rest, found = f" {self._comparable(text)} ", False
599
617
  for name in names:
600
618
  if name in rest:
601
619
  rest, found = rest.replace(name, " "), True
@@ -628,7 +646,7 @@ class InstitutionMixin:
628
646
  def searched_here(event: dict) -> bool:
629
647
  # A record keeps 500 characters: a long address (Elsevier ID's) is cut short in it.
630
648
  where = str(event.get("detail", "")).split(" @ ", 1)[-1]
631
- return event["state"] == "auto_institution_search" and len(where) > 10 and url.startswith(where)
649
+ return event["state"] == "auto_institution_search" and self._same_address(where, url)
632
650
 
633
651
  if not any(searched_here(e) for e in result.events):
634
652
  return False # nothing searched here: a page's other lists say nothing
@@ -637,7 +655,7 @@ class InstitutionMixin:
637
655
  # unless its publisher marks it as signing in no one (IP, VPN, email).
638
656
  may_sign_in = [str(it.get("t") or "") for score, it in scored if score == 1
639
657
  and self.adapter.institution_entry_signs_in(unquote(str(it.get("ids") or ""))) is not False]
640
- residues = [self._name_residue(" ".join(o.translate(self._QUOTES).split()).lower()) for o in may_sign_in]
658
+ residues = [self._name_residue(o) for o in may_sign_in]
641
659
  if any(r is not None and self._OWN_UNIT.match(r) for r in residues):
642
660
  return False # perhaps the school's own library or campus: left to the user
643
661
  settled = self.SEARCH_SETTLED_SEC
@@ -651,7 +669,7 @@ class InstitutionMixin:
651
669
  raise
652
670
  return False
653
671
  baseline = getattr(result, "_search_baseline", None)
654
- before = baseline[1] if isinstance(baseline, tuple) and baseline[0] == url else set()
672
+ before = baseline[1] if isinstance(baseline, tuple) and self._same_address(baseline[0], url) else set()
655
673
  # Only what the search added: the page's own links listed before it are no results
656
674
  # (2026-11-13: "About Elsevier", "Cookie settings" ended four searches still loading).
657
675
  unrelated = sorted({str(it.get("t") or "")[:60] for score, it in scored if score == 0
@@ -667,11 +685,15 @@ class InstitutionMixin:
667
685
  return False # results not shown yet: looked at again next pass
668
686
  now = time.time()
669
687
  seen = getattr(result, "_search_miss", None)
670
- if not seen or seen[0] != url or seen[1] != evidence:
688
+ if not seen or not self._same_address(seen[0], url) or seen[1] != evidence:
671
689
  result._search_miss = (url, evidence, now)
672
690
  return False
673
691
  if now - seen[2] < settled:
674
692
  return False
693
+ # The publisher may list the school by another of its names (2026-11-13: a
694
+ # Swedish name found twenty other schools; the school is listed in English).
695
+ if self._search_again_by_another_name(page, result, url, list(self._institution_names()), settled=True):
696
+ return False
675
697
  self._event(result, "auto_institution_not_found",
676
698
  f"{self.institution_query} (search: {evidence[:160]}) @ {url}")
677
699
  result._institution_not_listed = True
@@ -680,32 +702,51 @@ class InstitutionMixin:
680
702
  # How long a search by one of the school's names may show nothing before the next is typed.
681
703
  SEARCH_RETRY_SEC = 6
682
704
 
705
+ @staticmethod
706
+ def _same_address(recorded: str, url: str) -> bool:
707
+ """``url`` is the page at ``recorded`` (a record may cut a long address
708
+ short), percent-encoding aside: a chooser rewrote its own address without
709
+ it once the school was typed (2026-11-14)."""
710
+ recorded, url = unquote(str(recorded or "")), unquote(str(url or ""))
711
+ return len(recorded) > 10 and url.startswith(recorded)
712
+
683
713
  def _search_queries(self, names: list[str]) -> list[str]:
684
- """The school's names to search by, in Latin letters first (straight apostrophes)."""
714
+ """The school's names to search by (straight apostrophes): its English name
715
+ first, then the others in Latin letters, then the rest, its shared login
716
+ entry's own name last. A school's own language may be written in Latin
717
+ letters with no accent ("Kitan yliopisto", 2026-11-13), and publishers
718
+ list schools in English more often."""
685
719
  typed = [n.translate(self._QUOTES) for n in names]
686
- return list(dict.fromkeys([q for q in typed if q.isascii()] + [q for q in typed if not q.isascii()]))
687
-
688
- def _search_again_by_another_name(self, page: Any, result: DownloadResult, url: str, names: list[str]) -> bool:
720
+ english, entry = (str(self.config.get(key) or "").strip().translate(self._QUOTES)
721
+ for key in ("school_name_en", "school_entry_name"))
722
+ schools_own = [q for q in typed if q != entry]
723
+ return list(dict.fromkeys([q for q in schools_own if q == english] + [q for q in schools_own if q.isascii()]
724
+ + [q for q in schools_own if not q.isascii()] + [q for q in typed if q == entry]))
725
+
726
+ def _search_again_by_another_name(self, page: Any, result: DownloadResult, url: str, names: list[str],
727
+ settled: bool = False) -> bool:
689
728
  """The search by one of the school's names has shown nothing for
690
- ``SEARCH_RETRY_SEC`` (its list closed, or no entry beyond the page's own):
729
+ ``SEARCH_RETRY_SEC`` (its list closed, or no entry beyond the page's own),
730
+ or ``settled`` results without the school (``_search_lists_no_school``):
691
731
  the box is cleared and the next name typed, once each (2026-11-13: a school
692
732
  listed by its French name, searched by its English one, found nothing).
693
733
  A box holding anything but our own query is the user's and stays."""
694
734
  box_at = getattr(result, "_search_box", None)
695
- if (not isinstance(box_at, tuple) or box_at[0] != url
696
- or time.time() - float(getattr(result, "_search_typed_at", 0) or 0) < self.SEARCH_RETRY_SEC):
735
+ if (not isinstance(box_at, tuple) or not self._same_address(box_at[0], url)
736
+ or (not settled and time.time() - float(getattr(result, "_search_typed_at", 0) or 0)
737
+ < self.SEARCH_RETRY_SEC)):
697
738
  return False
698
739
  tried = []
699
740
  for event in result.events:
700
741
  query, _, where = str(event.get("detail", "")).partition(" @ ")
701
- if event["state"] == "auto_institution_search" and len(where) > 10 and url.startswith(where):
742
+ if event["state"] == "auto_institution_search" and self._same_address(where, url):
702
743
  tried.append(query)
703
744
  left = [q for q in self._search_queries(names) if q not in tried]
704
745
  if not left:
705
746
  return False
706
747
  baseline = getattr(result, "_search_baseline", None)
707
- before = baseline[1] if isinstance(baseline, tuple) and baseline[0] == url else set()
708
- if not self._search_list_closed(page, result, url) and self._entry_texts(page) - before:
748
+ before = baseline[1] if isinstance(baseline, tuple) and self._same_address(baseline[0], url) else set()
749
+ if not settled and not self._search_list_closed(page, result, url) and self._entry_texts(page) - before:
709
750
  return False # results shown: they decide
710
751
  box = page.locator(box_at[1]).first
711
752
  try:
@@ -727,7 +768,7 @@ class InstitutionMixin:
727
768
  no results are shown, whatever else the page lists (2026-11-13: a search
728
769
  showing nothing, its page's links taken for results)."""
729
770
  box = getattr(result, "_search_box", None)
730
- if not isinstance(box, tuple) or box[0] != url:
771
+ if not isinstance(box, tuple) or not self._same_address(box[0], url):
731
772
  return False
732
773
  try:
733
774
  return page.evaluate("""(selector) => {
@@ -778,9 +819,10 @@ class InstitutionMixin:
778
819
  if without:
779
820
  scored = [(score, it) for score, it in scored if not any(it is w for w in without)]
780
821
  if not any(score >= 2 for score, _ in scored):
781
- self._event(result, "auto_institution_not_found",
782
- f"{self.institution_query} (listed only without a school sign-in: "
783
- f"{len(without)} entr{'y' if len(without) == 1 else 'ies'}) @ {url}")
822
+ if getattr(result, "_institution_not_listed", False) is not True: # once, not every pass
823
+ self._event(result, "auto_institution_not_found",
824
+ f"{self.institution_query} (listed only without a school sign-in: "
825
+ f"{len(without)} entr{'y' if len(without) == 1 else 'ies'}) @ {url}")
784
826
  result._institution_not_listed = True
785
827
  return False
786
828
  top = max([score for score, _ in scored] or [0])
@@ -704,10 +704,16 @@ class LoginMixin:
704
704
  return f"{name}: {', '.join(label[:40] for label in entries[:6])}"
705
705
  if self._on_publisher_host(str(getattr(page, "url", "") or "")):
706
706
  listing = page.locator(self._FEDERATION_LINK_LIST).first
707
- if listing.is_visible() is True:
708
- entries = [label.strip() for label in listing.get_by_role("link").all_text_contents() if label.strip()]
709
- if len(entries) >= 2 and not any(federation.matches(label) for label in entries):
710
- return f"federation links: {', '.join(label[:40] for label in entries[:6])}"
707
+ try:
708
+ if listing.is_visible() is True:
709
+ entries = [label.strip() for label in listing.get_by_role("link").all_text_contents() if label.strip()]
710
+ if len(entries) >= 2 and not any(federation.matches(label) for label in entries):
711
+ return f"federation links: {', '.join(label[:40] for label in entries[:6])}"
712
+ except Exception as exc:
713
+ # A read the browser could not answer while the page changed (a
714
+ # publisher's chooser, 2026-11-14): settles nothing, looked at again next pass.
715
+ if not _is_browser_error(exc):
716
+ raise
711
717
  return ""
712
718
 
713
719
  def _openathens_lacks_school(self, page: Any) -> bool:
@@ -736,6 +742,7 @@ class LoginMixin:
736
742
  r"|can't find your institution|access to this resource has been restricted by your organization|oa-ap-4032"
737
743
  r"|不支持的请求|does not have access to this resource|message security error|reported an idp error"
738
744
  r"|an error occurred\. contact your administrator|application not authorized to use cas"
745
+ r"|metadata ?not ?found|没有找到元信息"
739
746
  r"|temporarily unavailable|verify you are human|are you a robot|checking your browser|正在进行安全验证", re.I)
740
747
 
741
748
  def _login_block_reason(self, page: Any) -> str:
@@ -838,6 +845,12 @@ class LoginMixin:
838
845
  # ("Application Not Authorized to Use CAS", 2026-11-13).
839
846
  if "application not authorized to use cas" in haystack and self._is_idp_host(urlparse(current_url).netloc):
840
847
  return "institution_not_registered"
848
+ # SimpleSAMLphp as the school's identity provider, the publisher not listed there:
849
+ # "Metadata not found" in the browser's language, its "MetadataNotFound" line in
850
+ # any ("没有找到元信息" on a Chinese browser, 2026-11-13).
851
+ if (re.search(r"metadata ?not ?found|没有找到元信息", haystack)
852
+ and self._is_idp_host(urlparse(current_url).netloc)):
853
+ return "institution_not_registered"
841
854
  if "your institution may not be enabled for this type of authentication" in haystack:
842
855
  return "institution_not_registered"
843
856
  if "can't find your institution" in haystack and "institution sign in" in haystack:
@@ -867,7 +880,10 @@ class LoginMixin:
867
880
  && !el.readOnly && ['text', 'email'].includes(el.type) && (el.type === 'email'
868
881
  || /username|email/i.test(el.autocomplete || '')
869
882
  || /user|login|identifier|account|email|netid|学号|工号|账号|帐号/i.test(`${el.name} ${el.id}`)))
870
- || /扫码|二维码|QR ?code|验证码|verification code/i.test((document.body && document.body.innerText || '').slice(0, 4000)),
883
+ || /扫码|二维码|QR ?code|验证码|verification code/i.test((document.body && document.body.innerText || '').slice(0, 4000))
884
+ // SimpleSAMLphp's page for choosing how to sign in, one box per way (its
885
+ // "multiauth" module; the buttons hidden in the boxes, 2026-11-13).
886
+ || !!document.querySelector('form [name^="sourceChoice["]'),
871
887
  handover: !!document.querySelector('input[name="SAMLResponse"], input[name="SAMLRequest"], input[name="RelayState"]')
872
888
  || /^\s*(?:loading|please wait|redirecting|正在跳转|跳转中|请稍候|处理中)/i.test(document.title || '')})"""
873
889
 
@@ -1456,7 +1472,9 @@ class LoginMixin:
1456
1472
  // account: a school's Okta page, 2026-11-11).
1457
1473
  const button = [...document.querySelectorAll('button,input[type=submit],input[type=button],[role=button]')]
1458
1474
  .some(el => visible(el) && !el.disabled && (el.innerText || el.value || el.getAttribute('aria-label') || '').trim());
1459
- return input || qr || button;
1475
+ // SimpleSAMLphp's choice of ways to sign in: boxes whose buttons are hidden (2026-11-13).
1476
+ const choice = !!document.querySelector('form [name^="sourceChoice["]');
1477
+ return input || qr || button || choice;
1460
1478
  }""") is True
1461
1479
 
1462
1480
  def _login_wait_page(self, page: Any) -> str:
@@ -0,0 +1,11 @@
1
+ {
2
+ "code": "aaieduhr",
3
+ "name": "AAI@EduHr",
4
+ "country": "HR",
5
+ "registration_authorities": ["http://www.srce.hr"],
6
+ "chooser_labels": ["AAI@EduHr"],
7
+ "chooser_pattern": "\\bAAI@Edu\\.?Hr\\b",
8
+ "discovery_hosts": [],
9
+ "service_domains": [],
10
+ "metadata_url": "https://login.aaiedu.hr/edugain/aaieduhr_edugain.xml"
11
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "code": "aaiedumk",
3
+ "name": "AAIEduMk",
4
+ "country": "MK",
5
+ "registration_authorities": ["https://rr.aaiedu.mk"],
6
+ "chooser_labels": ["AAIEduMk"],
7
+ "chooser_pattern": "\\bAAI\\s*Edu\\s*Mk\\b",
8
+ "discovery_hosts": [],
9
+ "service_domains": ["aaiedu.mk"],
10
+ "metadata_url": "http://aaiedu.mk/metadata.aaiedumk.xml"
11
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "code": "aconet",
3
+ "name": "ACOnet",
4
+ "country": "AT",
5
+ "registration_authorities": ["http://eduid.at"],
6
+ "chooser_labels": ["ACOnet Identity Federation"],
7
+ "chooser_pattern": "\\bACOnet\\b",
8
+ "discovery_hosts": [],
9
+ "service_domains": ["eduid.at"],
10
+ "metadata_url": "http://eduid.at/md/upstream-edugain.xml"
11
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "code": "arnesaai",
3
+ "name": "ArnesAAI",
4
+ "country": "SI",
5
+ "registration_authorities": ["http://aai.arnes.si"],
6
+ "chooser_labels": ["ArnesAAI Slovenska izobraževalno raziskovalna federacija"],
7
+ "chooser_pattern": "\\bArnes\\s*AAI\\b",
8
+ "discovery_hosts": [],
9
+ "service_domains": ["ds.aai.arnes.si"],
10
+ "metadata_url": "https://ds.aai.arnes.si/metadata/arnesaai2edugain.signed.xml"
11
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "code": "bif",
3
+ "name": "BIF",
4
+ "country": "BG",
5
+ "registration_authorities": ["https://bif.bren.bg"],
6
+ "chooser_labels": ["BIF"],
7
+ "chooser_pattern": "(?-i:\\bBIF\\b)",
8
+ "discovery_hosts": [],
9
+ "service_domains": ["bif.bren.bg"],
10
+ "metadata_url": "http://metadata.cc.bas.bg/rr3/signedmetadata/federation/BIF-BREN/metadata.xml"
11
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "code": "dfnaai",
3
+ "name": "DFN-AAI",
4
+ "country": "DE",
5
+ "registration_authorities": ["https://www.aai.dfn.de"],
6
+ "chooser_labels": ["DFN-AAI", "DFN AAI"],
7
+ "chooser_pattern": "\\bDFN(?:[- ]AAI)?\\b",
8
+ "discovery_hosts": [],
9
+ "service_domains": ["aai.dfn.de"],
10
+ "metadata_url": "https://www.aai.dfn.de/fileadmin/metadata/dfn-aai-4edugain-metadata.xml"
11
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "code": "eduidcz",
3
+ "name": "eduID.cz",
4
+ "country": "CZ",
5
+ "registration_authorities": ["http://www.eduid.cz/"],
6
+ "chooser_labels": ["eduID.cz"],
7
+ "chooser_pattern": "\\beduID\\.cz\\b",
8
+ "discovery_hosts": [],
9
+ "service_domains": ["eduid.cz"],
10
+ "metadata_url": "https://metadata.eduid.cz/entities/eduid2edugain"
11
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "code": "eduidhu",
3
+ "name": "eduId.hu",
4
+ "country": "HU",
5
+ "registration_authorities": ["http://eduid.hu"],
6
+ "chooser_labels": ["eduId.hu"],
7
+ "chooser_pattern": "\\beduID\\.hu\\b",
8
+ "discovery_hosts": [],
9
+ "service_domains": [],
10
+ "metadata_url": "https://metadata.eduid.hu/2025/href-edugain.xml"
11
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "code": "febas",
3
+ "name": "FEBAS",
4
+ "country": "BY",
5
+ "registration_authorities": ["https://febas.basnet.by"],
6
+ "chooser_labels": ["FEBAS"],
7
+ "chooser_pattern": "\\bFEBAS\\b",
8
+ "discovery_hosts": [],
9
+ "service_domains": [],
10
+ "metadata_url": "https://febas.basnet.by/shared/upload.xml"
11
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "code": "feide",
3
+ "name": "Feide",
4
+ "country": "NO",
5
+ "registration_authorities": ["http://feide.no/"],
6
+ "chooser_labels": ["FEIDE", "Feide"],
7
+ "chooser_pattern": "\\bFeide\\b",
8
+ "discovery_hosts": [],
9
+ "service_domains": [],
10
+ "metadata_url": "https://metadata.feide.no/feide-edugain-metadata.xml"
11
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "code": "grnet",
3
+ "name": "GRNET",
4
+ "country": "GR",
5
+ "registration_authorities": ["http://aai.grnet.gr/"],
6
+ "chooser_labels": ["GRNET"],
7
+ "chooser_pattern": "\\bGRNET\\b",
8
+ "discovery_hosts": [],
9
+ "service_domains": ["aai.grnet.gr"],
10
+ "metadata_url": "http://md.aai.grnet.gr/aggregates/edugain-metadata.xml"
11
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "code": "haka",
3
+ "name": "HAKA",
4
+ "country": "FI",
5
+ "registration_authorities": ["http://www.csc.fi/haka"],
6
+ "chooser_labels": ["HAKA", "Haka Federation"],
7
+ "chooser_pattern": "\\bHaka\\b",
8
+ "discovery_hosts": [],
9
+ "service_domains": ["haka.funet.fi"],
10
+ "metadata_url": "https://haka.funet.fi/metadata/edugain-metadata.xml"
11
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "code": "iamres",
3
+ "name": "iAMRES",
4
+ "country": "RS",
5
+ "registration_authorities": ["https://federacija.iamres.ac.rs/"],
6
+ "chooser_labels": ["iAMRES"],
7
+ "chooser_pattern": "\\biAMRES\\b",
8
+ "discovery_hosts": [],
9
+ "service_domains": ["iamres.ac.rs"],
10
+ "metadata_url": "http://md.iamres.ac.rs/iamres_fed/iamres-edugain-metadata.xml"
11
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "code": "idedume",
3
+ "name": "IDeduME",
4
+ "country": "ME",
5
+ "registration_authorities": ["https://federacija-idedume.ucg.ac.me/"],
6
+ "chooser_labels": ["IDeduME"],
7
+ "chooser_pattern": "\\bIDeduME\\b",
8
+ "discovery_hosts": [],
9
+ "service_domains": [],
10
+ "metadata_url": "https://md-idedume.ucg.ac.me/edugain/idedume-metadata.xml"
11
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "code": "idem",
3
+ "name": "IDEM",
4
+ "country": "IT",
5
+ "registration_authorities": ["http://www.idem.garr.it/"],
6
+ "chooser_labels": ["IDEM", "IDEM GARR AAI"],
7
+ "chooser_pattern": "(?-i:\\bIDEM\\b)",
8
+ "discovery_hosts": [],
9
+ "service_domains": ["idem.garr.it"],
10
+ "metadata_url": "http://md.idem.garr.it/metadata/idem2edugain-metadata-sha256.xml"
11
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "code": "laife",
3
+ "name": "LAIFE",
4
+ "country": "LV",
5
+ "registration_authorities": ["https://idp.laife.lv/"],
6
+ "chooser_labels": ["LAIFE"],
7
+ "chooser_pattern": "\\bLAIFE\\b",
8
+ "discovery_hosts": [],
9
+ "service_domains": [],
10
+ "metadata_url": "https://idp.laife.lv/metadata/laife-2-up.xml"
11
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "code": "leaf",
3
+ "name": "LEAF",
4
+ "country": "MD",
5
+ "registration_authorities": ["http://federations.renam.md/"],
6
+ "chooser_labels": ["LEAF"],
7
+ "chooser_pattern": "(?-i:\\bLEAF\\b)",
8
+ "discovery_hosts": [],
9
+ "service_domains": [],
10
+ "metadata_url": "https://manage.federations.renam.md/signedmetadata/federation/LEAF-MD/metadata.xml"
11
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "code": "litnet",
3
+ "name": "LITNET FEDI",
4
+ "country": "LT",
5
+ "registration_authorities": ["https://fedi.litnet.lt"],
6
+ "chooser_labels": ["LITNET FEDI"],
7
+ "chooser_pattern": "\\bLITNET\\b",
8
+ "discovery_hosts": [],
9
+ "service_domains": ["fedi.litnet.lt"],
10
+ "metadata_url": "https://fedi.litnet.lt/md/metadata.litnet-edugain.xml"
11
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "code": "peano",
3
+ "name": "PEANO",
4
+ "country": "UA",
5
+ "registration_authorities": ["https://peano.uran.ua"],
6
+ "chooser_labels": ["PEANO"],
7
+ "chooser_pattern": "\\bPEANO\\b",
8
+ "discovery_hosts": [],
9
+ "service_domains": ["peano.uran.ua"],
10
+ "metadata_url": "https://idp.uran.ua/rr3/signedmetadata/federation/PEANO/metadata.xml"
11
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "code": "pionierid",
3
+ "name": "PIONIER.Id",
4
+ "country": "PL",
5
+ "registration_authorities": ["https://aai.pionier.net.pl"],
6
+ "chooser_labels": ["PIONIER.Id"],
7
+ "chooser_pattern": "\\bPIONIER\\.?\\s*Id\\b",
8
+ "discovery_hosts": [],
9
+ "service_domains": [],
10
+ "metadata_url": "https://aai.pionier.net.pl/pionier-to-edugain.xml"
11
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "code": "rash",
3
+ "name": "RASH",
4
+ "country": "AL",
5
+ "registration_authorities": ["https://eduid.rash.al"],
6
+ "chooser_labels": ["RASH"],
7
+ "chooser_pattern": "(?-i:\\bRASH\\b)",
8
+ "discovery_hosts": [],
9
+ "service_domains": ["eduid.rash.al"],
10
+ "metadata_url": "https://eduid.rash.al/rash-metadata-agregator.xml"
11
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "code": "rctsaai",
3
+ "name": "RCTSaai",
4
+ "country": "PT",
5
+ "registration_authorities": ["https://www.fccn.pt"],
6
+ "chooser_labels": ["RCTSaai"],
7
+ "chooser_pattern": "\\bRCTS\\s*aai\\b",
8
+ "discovery_hosts": [],
9
+ "service_domains": ["rctsaai.pt"],
10
+ "metadata_url": "https://registry.rctsaai.pt/rr/signedmetadata/federation/edugain/metadata.xml"
11
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "code": "ricerkanet",
3
+ "name": "RiċerkaNET",
4
+ "country": "MT",
5
+ "registration_authorities": ["https://id.ricerka.net.mt"],
6
+ "chooser_labels": ["RiċerkaNET Identity Federation"],
7
+ "chooser_pattern": "\\bRi[cċ]erka\\s*NET\\b",
8
+ "discovery_hosts": [],
9
+ "service_domains": ["ricerka.net.mt"],
10
+ "metadata_url": "https://id.ricerka.net.mt/metadata/edugain-upstream.xml"
11
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "code": "roedunetid",
3
+ "name": "RoEduNetID",
4
+ "country": "RO",
5
+ "registration_authorities": ["http://eduid.roedu.net"],
6
+ "chooser_labels": ["RoEduNetID"],
7
+ "chooser_pattern": "\\bRoEduNet\\s*ID\\b",
8
+ "discovery_hosts": [],
9
+ "service_domains": ["eduid.roedu.net"],
10
+ "metadata_url": "https://sp.roedu.net/roedunetid-metadata-idp-signed.xml"
11
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "code": "safeid",
3
+ "name": "safeID",
4
+ "country": "SK",
5
+ "registration_authorities": ["http://safeid.sk"],
6
+ "chooser_labels": ["safeID"],
7
+ "chooser_pattern": "\\bsafeID\\b",
8
+ "discovery_hosts": [],
9
+ "service_domains": ["safeid.sk"],
10
+ "metadata_url": "https://metadata.safeid.sk/metadata/edugain-upstream.xml"
11
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "code": "sir",
3
+ "name": "SIR",
4
+ "country": "ES",
5
+ "registration_authorities": ["http://www.rediris.es/"],
6
+ "chooser_labels": ["SIR", "SIR (RedIRIS)"],
7
+ "chooser_pattern": "(?-i:\\bSIR\\b)|\\bRedIRIS\\b",
8
+ "discovery_hosts": [],
9
+ "service_domains": ["sir.rediris.es", "sir2.rediris.es"],
10
+ "metadata_url": "https://www.rediris.es/sir/edugain-sir-metadata.xml"
11
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "code": "swamid",
3
+ "name": "SWAMID",
4
+ "country": "SE",
5
+ "registration_authorities": ["http://www.swamid.se/"],
6
+ "chooser_labels": ["SWAMID"],
7
+ "chooser_pattern": "\\bSWAMID\\b",
8
+ "discovery_hosts": [],
9
+ "service_domains": ["swamid.se"],
10
+ "metadata_url": "http://mds.swamid.se/md/swamid-edugain-1.0.xml"
11
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "code": "switchaai",
3
+ "name": "Switch edu-ID",
4
+ "country": "CH",
5
+ "registration_authorities": ["http://rr.aai.switch.ch/"],
6
+ "chooser_labels": ["Switch edu-ID", "SWITCHaai"],
7
+ "chooser_pattern": "\\bSWITCH\\s*aai\\b|\\bSwitch\\s+edu-?ID\\b",
8
+ "discovery_hosts": [],
9
+ "service_domains": ["switch.ch"],
10
+ "metadata_url": "http://metadata.aai.switch.ch/metadata.edugain.xml"
11
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "code": "taat",
3
+ "name": "TAAT",
4
+ "country": "EE",
5
+ "registration_authorities": ["http://taat.edu.ee"],
6
+ "chooser_labels": ["TAAT"],
7
+ "chooser_pattern": "(?-i:\\bTAAT\\b)",
8
+ "discovery_hosts": [],
9
+ "service_domains": ["taat.edu.ee"],
10
+ "metadata_url": "https://taat.ee/metadata/metadata.taat-to-edugain-idp%2Bsp.xml"
11
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "code": "wayf",
3
+ "name": "WAYF",
4
+ "country": "DK",
5
+ "registration_authorities": ["https://www.wayf.dk"],
6
+ "chooser_labels": ["WAYF"],
7
+ "chooser_pattern": "\\bWAYF\\b",
8
+ "discovery_hosts": [],
9
+ "service_domains": ["wayf.dk"],
10
+ "metadata_url": "https://metadata.wayf.dk/wayf-edugain-metadata.xml"
11
+ }
@@ -47,6 +47,9 @@ class School:
47
47
  login_hosts: tuple[str, ...] = ()
48
48
  # Every domain the school's entry is registered for (tells the same school in two routes).
49
49
  scopes: tuple[str, ...] = field(default=(), compare=False)
50
+ # The login entry's own name, when the school is named as the user named it: a
51
+ # shared entry (a national one, "Feide") is listed by it on some choosers.
52
+ entry_name: str = field(default="", compare=False)
50
53
 
51
54
  def summary(self) -> dict[str, str]:
52
55
  federation = by_code(self.federation)
@@ -67,8 +70,10 @@ class Lookup:
67
70
  # --------------------------------------------------------------------------- saved
68
71
 
69
72
  def names(config: dict[str, Any]) -> tuple[str, ...]:
70
- """The saved school's names: as its federation lists it, then in English."""
71
- found = [str(config.get(key) or "").strip() for key in ("school_name", "school_name_en")]
73
+ """The saved school's names: as its federation lists it, then in English, then
74
+ its shared login entry's own name (a publisher's chooser listing login entries
75
+ lists a national one by it, 2026-11-13)."""
76
+ found = [str(config.get(key) or "").strip() for key in ("school_name", "school_name_en", "school_entry_name")]
72
77
  return tuple(dict.fromkeys(n for n in found if n))
73
78
 
74
79
 
@@ -141,8 +146,8 @@ def save(config: dict[str, Any], school: School) -> None:
141
146
  pages = [page for template in (federation.school_login_pages if federation else ())
142
147
  for page in ([template.replace("{scope}", scope) for scope in scopes] if "{scope}" in template
143
148
  else [template])]
144
- config.update(school_name=school.name, school_name_en=school.name_en, idp_entity_id=school.entity_id,
145
- idp_login_hosts=list(school.login_hosts), idp_login_pages=pages,
149
+ config.update(school_name=school.name, school_name_en=school.name_en, school_entry_name=school.entry_name,
150
+ idp_entity_id=school.entity_id, idp_login_hosts=list(school.login_hosts), idp_login_pages=pages,
146
151
  idp_domains=[d for d in scopes if "." in d],
147
152
  publisher_institution_federation=school.federation, carsi_enabled=school.federation == "carsi")
148
153
 
@@ -254,8 +259,8 @@ _PARTS = re.compile(r"\s+[-\u2013\u2014]\s+")
254
259
  _BRACKET = re.compile(r"\(([^()]+)\)")
255
260
  # Chinese, Japanese and Korean writing, beside a name in Latin letters.
256
261
  # A word naming the login server, not the school, at the end of a listed name
257
- # ("<School> IdP", 2026-11-13).
258
- _SERVER_WORD = re.compile(r"\s+(?:IdP|Identity\s+Provider|SSO)$", re.I)
262
+ # ("<School> IdP", "<entry> Single Sign-On Service": 2026-11-13).
263
+ _SERVER_WORD = re.compile(r"\s+(?:IdP|Identity\s+Provider|SSO|Single\s+Sign[- ]?On(?:\s+Service)?)$", re.I)
259
264
  _CJK = re.compile(r"[\u3040-\u30ff\u3400-\u9fff\uac00-\ud7af][\u3040-\u30ff\u3400-\u9fff\uac00-\ud7af\s・·]*")
260
265
 
261
266
 
@@ -371,11 +376,22 @@ def _from_seamlessaccess(given: list[str], config: dict[str, Any], found: _Found
371
376
  continue
372
377
  if federation.member_list == "carsi" and carsi_listed:
373
378
  continue # CARSI's own list is the source for its schools
374
- english = _SERVER_WORD.sub("", str((row.get("title_langs") or {}).get("en") or title)).strip()
379
+ english = listed_english = _SERVER_WORD.sub("", str((row.get("title_langs") or {}).get("en") or title)).strip()
380
+ if exact:
381
+ # The English name given, publishers' likelier name for the school, when the
382
+ # 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 Liman", 2026-11-13).
384
+ listed = {_key(v) for v in [*(row.get("title_langs") or {}).values(), title] if str(v or "").strip()}
385
+ own = _own_names(given)
386
+ other = [t for t in [*own[1:], *own[:1]] if t.isascii() and _key(t) not in listed]
387
+ parts = {_key(n) for n in titles}
388
+ english = next((t for t in other if _key(t) in parts), None) or (
389
+ other[0] if other and len(listed) == 1 else listed_english)
375
390
  # The name in the school's own language when that is the one given: publishers
376
391
  # may list it so (a French name searched in English found nothing, 2026-11-13).
377
- local = next((str(v) for k, v in (row.get("title_langs") or {}).items()
378
- if k != "en" and any(_key(t) == _key(v) for t in given)), english)
392
+ # Spaces as written once (a Greek name listed with a trailing space, 2026-11-13).
393
+ local = next((" ".join(str(v).split()) for k, v in (row.get("title_langs") or {}).items()
394
+ if k != "en" and any(_key(t) == _key(v) for t in given)), listed_english)
379
395
  found.add(School(local, english, entity, federation.code, scopes[0] if scopes else "",
380
396
  scopes=tuple(scopes)), exact, named=_named(given, titles))
381
397
 
@@ -447,8 +463,7 @@ def _with_login_hosts(school: School, config: dict[str, Any], data_dir: Path) ->
447
463
  listed = next((s for s, _, _ in _metadata_schools(federation, root) if s.entity_id == school.entity_id), None)
448
464
  if listed is None:
449
465
  return school
450
- return School(school.name, school.name_en, school.entity_id, school.federation,
451
- school.domain or listed.domain, listed.login_hosts, school.scopes)
466
+ return replace(school, domain=school.domain or listed.domain, login_hosts=listed.login_hosts)
452
467
 
453
468
 
454
469
  def _named(given: Iterable[str], listed_names: Iterable[str]) -> bool:
@@ -457,16 +472,23 @@ def _named(given: Iterable[str], listed_names: Iterable[str]) -> bool:
457
472
  return any(_key(t) in keys for t in given)
458
473
 
459
474
 
475
+ def _own_names(given: Iterable[str]) -> list[str]:
476
+ """What was given as the school's names: no entityID, no domain."""
477
+ return [t for t in given if not _is_entity_id(t) and not re.fullmatch(r"[\w-]+(?:\.[\w-]+)+", t)]
478
+
479
+
460
480
  def _named_as_given(school: School, given: list[str]) -> School:
461
481
  """A school found only by its domain, under a login entry many schools share
462
482
  (a school system's ID, a national entry: 2026-11-13), is named as the user named it: that
463
- name is what publishers' choosers list it under; the user's English name
464
- second when given, else the entry's."""
465
- own = [t for t in given if not _is_entity_id(t) and not re.fullmatch(r"[\w-]+(?:\.[\w-]+)+", t)]
483
+ name is what publishers' choosers list it under. Its English name is the one
484
+ given beside it, accents allowed, else the first name if in Latin letters, else
485
+ the entry's: a name in the school's own language may be ASCII ("Kitan
486
+ yliopisto" beside "Kita University", 2026-11-13)."""
487
+ own = _own_names(given)
466
488
  if not own:
467
489
  return school
468
- english = next((t for t in own if t.isascii()), school.name_en)
469
- return replace(school, name=own[0], name_en=english)
490
+ english = next((t for t in [*own[1:], own[0]] if _plain(t).isascii()), school.name_en)
491
+ return replace(school, name=own[0], name_en=english, entry_name=school.name)
470
492
 
471
493
 
472
494
  def find(query: str, config: dict[str, Any], data_dir: Path, *, also: Iterable[str] = ()) -> Lookup:
@@ -24,12 +24,12 @@ def ledger_path() -> Path:
24
24
 
25
25
 
26
26
  def school_key(config: dict[str, Any]) -> str:
27
- """The configured school: its entityID, else its CARSI name; "" without one."""
28
- for field in ("idp_entity_id", "school_name", "school_name_en"):
29
- value = " ".join(str(config.get(field) or "").split())
30
- if value:
31
- return value.lower()
32
- return ""
27
+ """The configured school: its entityID and its name, else either; "" without
28
+ one. The name keeps apart schools signing in through one shared entry (a
29
+ national one: Norway's, 2026-11-13), whose entityID is the same for all."""
30
+ entity, name, english = (" ".join(str(config.get(field) or "").split())
31
+ for field in ("idp_entity_id", "school_name", "school_name_en"))
32
+ return " | ".join(part for part in (entity, name or english) if part).lower()
33
33
 
34
34
 
35
35
  def _key(publisher: str, school: str) -> str:
@@ -49,7 +49,7 @@ class Redactor:
49
49
  self.terms: set[str] = set()
50
50
  self.school_hosts: set[str] = set()
51
51
  cfg = config or {}
52
- for key in ('school_name', 'school_name_en', 'idp_entity_id', 'institution_domain', 'idp_domain'):
52
+ for key in ('school_name', 'school_name_en', 'school_entry_name', 'idp_entity_id', 'institution_domain', 'idp_domain'):
53
53
  value = str(cfg.get(key) or '').strip()
54
54
  if len(value) > 2:
55
55
  self.terms.add(value)
@@ -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.4"
7
+ version: "0.6.5"
8
8
  ---
9
9
 
10
10
  # 文献检索与下载(paper-search)
@@ -86,7 +86,71 @@
86
86
  - 荷兰的学校都经 SURFconext 的统一中转站登录,程序自动经过。
87
87
  - 法国、荷兰、比利时的学校可以用当地语言的校名配置;出版社按一个名称搜不到时,程序会换学校的其他名称再搜。
88
88
 
89
- 计划中:北欧、中欧、南欧、东欧。
89
+ ### 北欧
90
+
91
+ | 地区 | 联盟 | 全称 | 联盟内学校数 | 状态 | 已实测的学校 |
92
+ | --- | --- | --- | --- | --- | --- |
93
+ | 丹麦(含冰岛、格陵兰) | WAYF | WAYF – Where Are You From | 71 | ✓ | 哥本哈根大学、奥胡斯大学、丹麦技术大学、冰岛大学 |
94
+ | 瑞典 | SWAMID | Swedish Academic Identity Federation | 53 | ✓ | 卡罗林斯卡学院、隆德大学、乌普萨拉大学、瑞典皇家理工学院 |
95
+ | 芬兰 | Haka | Haka Identity Federation | 40 | ✓ | 阿尔托大学、坦佩雷大学 |
96
+ | 挪威 | Feide | Feide | 1 个全国入口 | ○ | — |
97
+
98
+ - 丹麦的学校都经 WAYF 的中转站登录,程序自动经过。
99
+ - 挪威的学校都经 Feide 全国共用入口登录,联盟名单里只有学校的域名:配置时同时给出校名和学校官网域名。Elsevier 只给挪威的大学开了 IP 方式,Springer Nature、牛津大学出版社的机构列表里没有 Feide,程序会写明原因;IOP 经 OpenAthens 列出几条同名的“Feide”入口,由用户自己选。
100
+ - 坦佩雷大学在联盟名单里与坦佩雷应用科学大学合写为“Tampere Universities”,按校名查不到时加上官网域名配置。
101
+
102
+ ### 中欧
103
+
104
+ | 地区 | 联盟 | 全称 | 联盟内学校数 | 状态 | 已实测的学校 |
105
+ | --- | --- | --- | --- | --- | --- |
106
+ | 德国 | DFN-AAI | DFN-AAI(德国科研网身份联盟) | 约 390 | ✓ | 慕尼黑大学、慕尼黑工业大学、海德堡大学、柏林夏里特医学院、柏林洪堡大学 |
107
+ | 瑞士 | Switch edu-ID | Switch edu-ID(SWITCHaai) | 63 | ✓ | 苏黎世联邦理工学院、苏黎世大学、洛桑联邦理工学院、日内瓦大学 |
108
+ | 奥地利 | ACOnet | ACOnet Identity Federation | 84 | ✓ | 维也纳大学、维也纳技术大学 |
109
+ | 波兰 | PIONIER.Id | PIONIER.Id | 93 | ✓ | 华沙大学、雅盖隆大学、华沙理工大学 |
110
+ | 捷克 | eduID.cz | eduID.cz | 约 220 | ✓ | 布拉格查理大学、马萨里克大学、布拉格捷克理工大学 |
111
+ | 斯洛伐克 | safeID | safeID | 33 | ✓ | 布拉迪斯拉发考门斯基大学、斯洛伐克理工大学 |
112
+ | 匈牙利 | eduId.hu | eduId.hu | 81 | ✓ | 罗兰大学、塞梅尔维斯大学、德布勒森大学 |
113
+
114
+ - 瑞士多数学校经 Switch edu-ID 登录,学校登录页在 edu-ID 的网站上,程序照常认出。
115
+
116
+ ### 南欧
117
+
118
+ | 地区 | 联盟 | 全称 | 联盟内学校数 | 状态 | 已实测的学校 |
119
+ | --- | --- | --- | --- | --- | --- |
120
+ | 西班牙 | SIR | Servicio de Identidad de RedIRIS | 约 180 | ✓ | 马德里康普顿斯大学、巴塞罗那大学、马德里自治大学、瓦伦西亚大学 |
121
+ | 葡萄牙 | RCTSaai | RCTSaai | 约 110 | ✓ | 里斯本大学、波尔图大学、科英布拉大学 |
122
+ | 意大利 | IDEM | IDEM GARR AAI | 约 170 | ✓ | 博洛尼亚大学、罗马第一大学、米兰大学、帕多瓦大学 |
123
+ | 希腊 | GRNET | GRNET AAI Federation | 53 | ✓ | 雅典国立卡波迪斯特里亚大学、塞萨洛尼基亚里士多德大学、雅典国立理工大学 |
124
+ | 马耳他 | RiċerkaNET | RiċerkaNET Identity Federation | 1 | ✓ | 马耳他大学(剑桥大学出版社) |
125
+ | 斯洛文尼亚 | ArnesAAI | ArnesAAI | 21 | ✓ | 卢布尔雅那大学、马里博尔大学 |
126
+ | 克罗地亚 | AAI@EduHr | AAI@EduHr | 1 个全国入口 | ✓ | 萨格勒布大学(Springer Nature,经全国入口) |
127
+ | 塞尔维亚 | iAMRES | iAMRES | 19 | ✓ | 诺维萨德大学、贝尔格莱德大学化学学院 |
128
+ | 黑山 | IDeduME | IDeduME | 3 | ✓ | 黑山大学(剑桥大学出版社) |
129
+ | 北马其顿 | AAIEduMk | AAIEduMk | 4 | ✓ | 斯科普里圣西里尔和美多德大学 |
130
+ | 阿尔巴尼亚 | RASH | RASH | 2 | ○ | — |
131
+ | 保加利亚 | BIF | Bulgarian Identity Federation | 21 | ○ | — |
132
+ | 罗马尼亚 | RoEduNetID | RoEduNetID | 24 | ✓ | 布加勒斯特大学、雅西大学 |
133
+
134
+ - 西班牙的学校都经 SIR 的中转站登录,程序自动经过。
135
+ - 克罗地亚的学校都经 AAI@EduHr 全国共用入口登录:配置时同时给出校名和学校官网域名。
136
+ - 贝尔格莱德大学没有全校的登录入口,各学院分别登记;配置时程序会列出各学院请用户选。
137
+ - 马耳他大学、萨格勒布大学、地拉那大学、索非亚大学、索非亚技术大学:Elsevier 只给它们开了 IP 方式,程序会写明原因;黑山大学只有教职工入口登记在 eduGAIN,Elsevier 的机构列表里没有它。马耳他大学、黑山大学在剑桥大学出版社、萨格勒布大学在 Springer Nature 能走到学校登录页。
138
+ - 阿尔巴尼亚、保加利亚:除 Elsevier 外又试了六家出版社,Springer Nature 的机构列表里没有这两国的学校,其他几家在测试电脑上出了人机验证页或没选上学校,尚未走到学校登录页。
139
+
140
+ ### 东欧
141
+
142
+ | 地区 | 联盟 | 全称 | 联盟内学校数 | 状态 | 已实测的学校 |
143
+ | --- | --- | --- | --- | --- | --- |
144
+ | 爱沙尼亚 | TAAT | TAAT | 13 | ✓ | 塔尔图大学、塔林理工大学 |
145
+ | 拉脱维亚 | LAIFE | Latvian Academic Identity Federation | 19 | ✓ | 拉脱维亚大学 |
146
+ | 立陶宛 | LITNET FEDI | LITNET FEDI | 22 | ✓ | 维尔纽斯大学、考纳斯理工大学、立陶宛健康科学大学 |
147
+ | 白俄罗斯 | FEBAS | FEBAS | 3 | ○ | — |
148
+ | 乌克兰 | PEANO | PEANO | 8 | ✓ | 切尔诺夫策国立大学、哈尔科夫理工学院 |
149
+ | 摩尔多瓦 | LEAF | LEAF | 4 | ○ | — |
150
+
151
+ - 拉脱维亚有十几所学校(含里加理工大学、里加斯特拉金什大学)经 LAIFE 共用入口登录:配置时同时给出校名和学校官网域名;Elsevier 只给这两所开了 IP 方式。
152
+ - 塔林理工大学在联盟名单里写作“TalTech”,用这个简称或旧域名 `ttu.ee` 能查到。
153
+ - 白俄罗斯国立大学的登录服务器从境外连不上,程序立即结束并说明学校登录系统出错;摩尔多瓦国立大学在 Elsevier 只开了 IP 方式,在剑桥大学出版社能选中,但测试时选校页没有接受这次选择,尚未走到学校登录页。
90
154
 
91
155
  ## 美洲
92
156
 
@@ -118,3 +182,4 @@
118
182
 
119
183
  - 联盟内学校数取自 eduGAIN 登记的身份提供方数量,一所学校可能登记不止一个。
120
184
  - 学校登录服务器连不上,或学校认证服务器拒绝出版社的登录请求时,程序立即结束并说明“学校登录系统出错”;这类情况要由学校处理。
185
+ - 学校登录服务器没有登记这家出版社时(页面显示 Unsupported Request、Metadata not found 等),程序立即结束并说明学校没有为这家出版社开通。
@@ -53,9 +53,9 @@ 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)、印度(INFED)、土耳其(YETKİM)、斯里兰卡(LIAF)、孟加拉(TIGERfed)、巴基斯坦(PKIFED)、阿曼(OMREN)、中国内地科研机构(CSTCloud)、沙特阿拉伯(Maeen)、塞浦路斯(CyNet)、以色列(IUCC)、伊朗(IRFED)、阿塞拜疆(AzScienceNet)、英国(UK federation)、爱尔兰(Edugate)、法国(RENATER)、荷兰(SURFconext)、比利时(Belnet)、卢森堡(eduID Luxembourg)、美国(InCommon)的学术身份联盟,以及只经 OpenAthens 登录的学校。`--institution` 可以是校名(任何语言)、学校域名或 entityID;后端在各联盟的学校名单里查,确定是哪一所才保存,并保存它所属的联盟。
57
- - 联盟名单里的校名是当地语言和英文(中国内地、澳门有中文,日本有日文,土耳其有土耳其文,法国、荷兰、比利时等欧洲国家多有当地语言名,香港、韩国、新加坡、马来西亚、南亚和美国多只有英文)。用户说的校名不是这两种时,加 `--also-name` 给出学校的英文正式名称;不确定英文名就不加。
58
- - 有些学校经多校共用的登录入口登录(如以色列的大学、中国内地的科研院所、巴基斯坦的部分学校),联盟名单里只有它们的域名:按校名查不到时,用 `--institution <校名> --also-name <学校官网域名>` 再查一次,程序会按域名找到入口,并按所给校名在出版社搜索。
56
+ - 目前支持中国内地和澳门(CARSI)、香港(HKAF)、新加坡(SGAF)、日本(GakuNin)、韩国(KAFE)、马来西亚(SIFULAN)、印度(INFED)、土耳其(YETKİM)、斯里兰卡(LIAF)、孟加拉(TIGERfed)、巴基斯坦(PKIFED)、阿曼(OMREN)、中国内地科研机构(CSTCloud)、沙特阿拉伯(Maeen)、塞浦路斯(CyNet)、以色列(IUCC)、伊朗(IRFED)、阿塞拜疆(AzScienceNet)、英国(UK federation)、爱尔兰(Edugate)、法国(RENATER)、荷兰(SURFconext)、比利时(Belnet)、卢森堡(eduID Luxembourg)、北欧、中欧、南欧和东欧各国(各联盟见 `federation-support.md`)、美国(InCommon)的学术身份联盟,以及只经 OpenAthens 登录的学校。`--institution` 可以是校名(任何语言)、学校域名或 entityID;后端在各联盟的学校名单里查,确定是哪一所才保存,并保存它所属的联盟。
57
+ - 联盟名单里的校名是当地语言和英文(中国内地、澳门有中文,日本有日文,土耳其有土耳其文,欧洲各国多有当地语言名,香港、韩国、新加坡、马来西亚、南亚和美国多只有英文)。用户说的校名不是英文时,加 `--also-name` 给出学校的英文正式名称(出版社多按英文名列学校);不确定英文名就不加。
58
+ - 有些学校经多校共用的登录入口登录(如以色列、挪威、克罗地亚的大学,中国内地的科研院所,巴基斯坦、拉脱维亚的部分学校),联盟名单里只有它们的域名:按校名查不到时,用 `--institution <校名> --also-name <学校官网域名>` 再查一次,程序会按域名找到入口,并按所给校名在出版社搜索。
59
59
  - 返回 `school_ambiguous` 时,把 `candidates`(含学校名、联盟、域名)列给用户选,再用所选学校的 `entity_id` 作为 `--institution` 重新运行;只有一个候选也要问,那是名字不完全一致的学校。`school_not_found` 时请用户换成学校正式名称、英文名或学校域名,仍找不到就按回复里的 `reasons` 如实说明:这所学校可能没有接入学术身份联盟或 OpenAthens,学校订阅下载无法为它登录;`federation_not_supported` 是找到了学校但它所属的联盟还不支持,如实告诉用户;`school_list_unavailable` 是名单取不到,稍后重试。
60
60
  - `--carsi --institution` 只在 CARSI 名单里查(错误码 `carsi_school_*`);查 CARSI 名单:`paper-search-school setup --list-carsi-schools 关键词`。
61
61
  - `setup --check` 的 `school` 项为 `missing` 时,说明只存了学校名,按提示重新运行上面的命令。