papersearch 0.5.14 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +28 -9
- package/README.md +28 -9
- package/carsi/paper_search_carsi/adapters/base.py +10 -0
- package/carsi/paper_search_carsi/adapters/elsevier/__init__.py +23 -3
- package/carsi/paper_search_carsi/adapters/ieee/__init__.py +1 -1
- package/carsi/paper_search_carsi/adapters/platforms/atypon/__init__.py +14 -11
- package/carsi/paper_search_carsi/adapters/platforms/figshare/__init__.py +8 -2
- package/carsi/paper_search_carsi/adapters/sage/__init__.py +2 -4
- package/carsi/paper_search_carsi/adapters/thieme/__init__.py +12 -10
- package/carsi/paper_search_carsi/adapters/world_scientific/__init__.py +2 -1
- package/carsi/paper_search_carsi/assets/capsule.html +0 -1
- package/carsi/paper_search_carsi/cli.py +65 -22
- package/carsi/paper_search_carsi/cold_start.py +3 -1
- package/carsi/paper_search_carsi/config.py +10 -3
- package/carsi/paper_search_carsi/download_diagnostics.py +1 -1
- package/carsi/paper_search_carsi/engine/batch.py +13 -3
- package/carsi/paper_search_carsi/engine/batch_access.py +3 -2
- package/carsi/paper_search_carsi/engine/batch_diagnostics.py +1 -1
- package/carsi/paper_search_carsi/engine/batch_institution.py +199 -79
- package/carsi/paper_search_carsi/engine/batch_login.py +39 -24
- package/carsi/paper_search_carsi/engine/batch_waits.py +2 -1
- package/carsi/paper_search_carsi/engine/bridge.py +31 -30
- package/carsi/paper_search_carsi/engine/login_wait.py +25 -3
- package/carsi/paper_search_carsi/engine/page_supplements.py +67 -0
- package/carsi/paper_search_carsi/federations/__init__.py +155 -0
- package/carsi/paper_search_carsi/federations/builtin/carsi.json +22 -0
- package/carsi/paper_search_carsi/federations/builtin/gakunin.json +11 -0
- package/carsi/paper_search_carsi/federations/builtin/hkaf.json +12 -0
- package/carsi/paper_search_carsi/federations/builtin/kafe.json +11 -0
- package/carsi/paper_search_carsi/federations/builtin/openathens.json +21 -0
- package/carsi/paper_search_carsi/federations/builtin/sgaf.json +11 -0
- package/carsi/paper_search_carsi/federations/builtin/sifulan.json +11 -0
- package/carsi/paper_search_carsi/federations/schools.py +393 -0
- package/carsi/paper_search_carsi/progress_view.py +0 -2
- package/carsi/paper_search_carsi/report_sanitizer.py +15 -0
- package/carsi/pyproject.toml +1 -1
- package/dist/capabilities/pdf-discovery/carsi/CarsiMcpClient.js +1 -1
- package/dist/capabilities/pdf-discovery/carsi/CarsiMcpClient.js.map +1 -1
- package/dist/management/carsi/installer.d.ts.map +1 -1
- package/dist/management/carsi/installer.js +23 -16
- package/dist/management/carsi/installer.js.map +1 -1
- package/package.json +1 -1
- package/skills/paper-search/SKILL.md +4 -3
- package/skills/paper-search/references/browser-download.md +1 -1
- package/skills/paper-search/references/carsi-setup.md +9 -8
- package/skills/paper-search/references/cli-contract.md +2 -2
- package/skills/paper-search/references/federation-support.md +31 -0
- package/skills/paper-search/references/publisher-support.md +2 -2
- package/skills/paper-search/references/setup.md +1 -1
package/README.en.md
CHANGED
|
@@ -13,7 +13,7 @@ One sentence and your AI searches, verifies and downloads full texts and supplem
|
|
|
13
13
|
<a href="https://www.npmjs.com/package/papersearch"><img src="https://img.shields.io/npm/v/papersearch?style=flat-square" alt="npm"></a>
|
|
14
14
|
<a href="https://github.com/dr-dumpling/PaperSearch/actions/workflows/publish.yml"><img src="https://img.shields.io/github/actions/workflow/status/dr-dumpling/PaperSearch/publish.yml?style=flat-square&label=publish" alt="Publish workflow status"></a>
|
|
15
15
|
<a href="https://nodejs.org/"><img src="https://img.shields.io/node/v/papersearch?style=flat-square" alt="Required Node.js version"></a>
|
|
16
|
-
<a href="#1-school-subscription-downloads
|
|
16
|
+
<a href="#1-school-subscription-downloads"><img src="https://img.shields.io/badge/school%20login-Asia%20(6%20federations%20%2B%20OpenAthens)-7284CE?style=flat-square" alt="School subscription downloads: six academic identity federations in Asia and OpenAthens"></a>
|
|
17
17
|
<a href="docs/guide.en.md#agent-skill"><img src="https://img.shields.io/badge/Agent%20Skill-bundled-D97757?style=flat-square" alt="Bundled Agent Skill"></a>
|
|
18
18
|
<a href="#quick-start"><img src="https://img.shields.io/badge/platform-macOS%20%7C%20Windows-555555?style=flat-square" alt="Runs on macOS and Windows"></a>
|
|
19
19
|
<a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-2F9E44?style=flat-square" alt="MIT license"></a>
|
|
@@ -21,7 +21,7 @@ One sentence and your AI searches, verifies and downloads full texts and supplem
|
|
|
21
21
|
</p>
|
|
22
22
|
|
|
23
23
|
<p align="center">
|
|
24
|
-
<a href="#demo-video">Demo video</a> · <a href="#quick-start">Quick start</a> · <a href="#1-school-subscription-downloads
|
|
24
|
+
<a href="#demo-video">Demo video</a> · <a href="#quick-start">Quick start</a> · <a href="#1-school-subscription-downloads">School subscription downloads</a> · <a href="#2-api-keys">API keys</a> · <a href="docs/guide.en.md">Guide</a> · <a href="docs/ARCHITECTURE.zh.md">Architecture</a> · <a href="docs/ROADMAP.zh.md">Roadmap</a> · <a href="https://github.com/dr-dumpling/PaperSearch/issues/new/choose">Report an issue</a>
|
|
25
25
|
</p>
|
|
26
26
|
|
|
27
27
|
PaperSearch provides the `paper-search` command and a bundled Skill. Once installed, Claude Code, Codex, DeepSeek, GLM, Kimi Code, Qwen Code, CodeBuddy and other AI tools that can run local commands can do this for you:
|
|
@@ -32,7 +32,7 @@ PaperSearch provides the `paper-search` command and a bundled Skill. Once instal
|
|
|
32
32
|
- **Look up citations and references**: from one paper, find the studies that cite it and the works it cites.
|
|
33
33
|
- **Download full texts and supplementary files**:
|
|
34
34
|
- Open-access papers: downloaded directly.
|
|
35
|
-
- Subscription papers: through "[school subscription downloads
|
|
35
|
+
- Subscription papers: through "[school subscription downloads](#1-school-subscription-downloads)" (recommended) or [API keys](#2-api-keys).
|
|
36
36
|
|
|
37
37
|
<p align="center"><img src="assets/overview.en.png" width="840" alt="What PaperSearch does: search papers, full-text snippets, journal metrics, citations and references, full texts and supplementary files"></p>
|
|
38
38
|
|
|
@@ -66,13 +66,13 @@ Once it is installed, mention the Skill and send:
|
|
|
66
66
|
/paper-search Start setup
|
|
67
67
|
```
|
|
68
68
|
|
|
69
|
-
Your AI first asks whether to install the PaperSearch command-line program; once you agree, it installs it and then walks you through school subscription downloads
|
|
69
|
+
Your AI first asks whether to install the PaperSearch command-line program; once you agree, it installs it and then walks you through school subscription downloads and API keys.
|
|
70
70
|
|
|
71
71
|
<p align="center"><img src="assets/install.en.webp" width="840" alt="Install demo: send your AI one sentence and it installs the Skill; mention the Skill and say Start setup, and it asks before installing the command-line program, lists what works, and goes on to setup"></p>
|
|
72
72
|
|
|
73
73
|
### 2. Add school subscription downloads during setup
|
|
74
74
|
|
|
75
|
-
After "Start setup", your AI first asks whether to add [school subscription downloads
|
|
75
|
+
After "Start setup", your AI first asks whether to add [school subscription downloads](#1-school-subscription-downloads): full texts and supplementary files of subscription papers through your school account; it needs Chrome (installed too if missing) and downloads about 0.5 GB. It installs only after you agree, then asks for your school, sets it, and opens the settings window.
|
|
76
76
|
|
|
77
77
|
- Don't want it? Say so and it is skipped for good; searching and open-access downloads work as before.
|
|
78
78
|
- Servers without a screen are not asked.
|
|
@@ -111,7 +111,7 @@ Once set up, mention the PaperSearch Skill and say what you want to search for,
|
|
|
111
111
|
|
|
112
112
|
Feature comparison:
|
|
113
113
|
|
|
114
|
-
| | Works once installed | API keys | School subscription downloads
|
|
114
|
+
| | Works once installed | API keys | School subscription downloads |
|
|
115
115
|
|---|:---:|:---:|:---:|
|
|
116
116
|
| **Search** | | | |
|
|
117
117
|
|  Search papers, citations and references | ✅ | — | — |
|
|
@@ -126,9 +126,28 @@ Feature comparison:
|
|
|
126
126
|
| **You need** | Node.js 22 or later | Keys from each provider | Google Chrome, a school account |
|
|
127
127
|
| **How to turn it on** | Quick start step 1 | Settings window or terminal | Agree during setup |
|
|
128
128
|
|
|
129
|
-
### 1. School subscription downloads
|
|
129
|
+
### 1. School subscription downloads
|
|
130
130
|
|
|
131
|
-
Papers the open channels cannot get can come through your school's subscriptions
|
|
131
|
+
Papers the open channels cannot get can come through your school's subscriptions: the program signs in to the publishers through the academic identity federation your school belongs to, with your school account. At setup you only name your school (in Chinese, English or its own language); the program finds out which federation it belongs to.
|
|
132
|
+
|
|
133
|
+
The academic identity federations of different countries are interconnected through [eduGAIN](https://edugain.org/), which is how publishers accept school accounts from many countries; many schools in no national federation use the [OpenAthens](https://www.openathens.net/) institutional sign-in service, and the program signs in through it too.
|
|
134
|
+
|
|
135
|
+
**Supported academic identity federations** (first stage: Asia)
|
|
136
|
+
|
|
137
|
+
| Region | Federation | Full name |
|
|
138
|
+
|---|---|---|
|
|
139
|
+
| Chinese mainland, Macau | CARSI | CERNET Authentication and Resource Sharing Infrastructure |
|
|
140
|
+
| Hong Kong | HKAF | Hong Kong Access Federation |
|
|
141
|
+
| Singapore | SGAF | Singapore Access Federation |
|
|
142
|
+
| Japan | GakuNin | Academic Access Management Federation in Japan |
|
|
143
|
+
| South Korea | KAFE | Korean Access Federation |
|
|
144
|
+
| Malaysia | SIFULAN | SIFULAN Malaysian Access Federation |
|
|
145
|
+
| Schools in no national federation (most universities in Southeast Asia and others) | OpenAthens | OpenAthens institutional sign-in |
|
|
146
|
+
|
|
147
|
+
- What each federation supports and which schools have been tested: [federation support table](skills/paper-search/references/federation-support.md) (Chinese).
|
|
148
|
+
- Planned: the US (InCommon), the UK (UK federation), Australia (AAF) and the federations of European countries, then the other countries in eduGAIN; see the [roadmap](docs/ROADMAP.zh.md) (Chinese).
|
|
149
|
+
- A school in no federation and not on OpenAthens (reached only from the campus network, a VPN or a library proxy) cannot be used yet.
|
|
150
|
+
- Whether a given paper comes through still depends on your school's subscriptions and on whether the publisher lets your school sign in with school accounts; when it does not, the program says so.
|
|
132
151
|
|
|
133
152
|
- **Your school account is enough**: no keys to apply for; publisher API keys only cover Elsevier and Springer.
|
|
134
153
|
- **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:
|
|
@@ -220,7 +239,7 @@ Next on the list:
|
|
|
220
239
|
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.
|
|
221
240
|
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.
|
|
222
241
|
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.
|
|
223
|
-
4. **
|
|
242
|
+
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.
|
|
224
243
|
5. **Better paper search and full-text snippets**: learn from similar tools and improve how papers and passages are found.
|
|
225
244
|
|
|
226
245
|
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 [carsi/CONTRIBUTING.md](carsi/CONTRIBUTING.md).
|
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
<a href="https://www.npmjs.com/package/papersearch"><img src="https://img.shields.io/npm/v/papersearch?style=flat-square" alt="npm"></a>
|
|
14
14
|
<a href="https://github.com/dr-dumpling/PaperSearch/actions/workflows/publish.yml"><img src="https://img.shields.io/github/actions/workflow/status/dr-dumpling/PaperSearch/publish.yml?style=flat-square&label=publish" alt="发布工作流状态"></a>
|
|
15
15
|
<a href="https://nodejs.org/"><img src="https://img.shields.io/node/v/papersearch?style=flat-square" alt="Node.js 版本要求"></a>
|
|
16
|
-
<a href="#1-学校订阅下载
|
|
16
|
+
<a href="#1-学校订阅下载"><img src="https://img.shields.io/badge/school%20login-Asia%20(6%20federations%20%2B%20OpenAthens)-7284CE?style=flat-square" alt="学校订阅下载:亚洲 6 个学术身份联盟和 OpenAthens"></a>
|
|
17
17
|
<a href="docs/guide.zh.md#agent-skill"><img src="https://img.shields.io/badge/Agent%20Skill-bundled-D97757?style=flat-square" alt="随包 Agent Skill"></a>
|
|
18
18
|
<a href="#快速开始"><img src="https://img.shields.io/badge/platform-macOS%20%7C%20Windows-555555?style=flat-square" alt="支持 macOS 和 Windows"></a>
|
|
19
19
|
<a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-2F9E44?style=flat-square" alt="MIT 许可证"></a>
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
</p>
|
|
22
22
|
|
|
23
23
|
<p align="center">
|
|
24
|
-
<a href="#演示视频">演示视频</a> · <a href="#快速开始">快速开始</a> · <a href="#1-学校订阅下载
|
|
24
|
+
<a href="#演示视频">演示视频</a> · <a href="#快速开始">快速开始</a> · <a href="#1-学校订阅下载">学校订阅下载</a> · <a href="#2-api-key">API key</a> · <a href="docs/guide.zh.md">使用说明</a> · <a href="docs/ARCHITECTURE.zh.md">架构说明</a> · <a href="docs/ROADMAP.zh.md">路线图</a> · <a href="https://github.com/dr-dumpling/PaperSearch/issues/new/choose">反馈问题</a>
|
|
25
25
|
</p>
|
|
26
26
|
|
|
27
27
|
PaperSearch 提供 `paper-search` 命令和一份随包 Skill。装好后,Claude Code、Codex、DeepSeek、GLM、Kimi Code、Qwen Code、CodeBuddy 等支持本机命令调用的 AI 工具,就能替你:
|
|
@@ -32,7 +32,7 @@ PaperSearch 提供 `paper-search` 命令和一份随包 Skill。装好后,Clau
|
|
|
32
32
|
- **查引文和参考文献**:顺着一篇论文,找出引用它的研究和它引用的文献。
|
|
33
33
|
- **下载全文和补充材料**:
|
|
34
34
|
- OA 文章:直接下载。
|
|
35
|
-
- 非 OA 文章:通过“[
|
|
35
|
+
- 非 OA 文章:通过“[学校订阅下载](#1-学校订阅下载)”(推荐)或 [API key](#2-api-key) 配置。
|
|
36
36
|
|
|
37
37
|
<p align="center"><img src="assets/overview.png" width="840" alt="PaperSearch 能做的事:检索论文、搜正文片段、查期刊 IF 与分区、查引文和参考文献、下载全文和补充材料"></p>
|
|
38
38
|
|
|
@@ -66,13 +66,13 @@ Windows 上这条命令需要 Git,没有的话先装 [Git for Windows](https:/
|
|
|
66
66
|
/paper-search 请开始配置
|
|
67
67
|
```
|
|
68
68
|
|
|
69
|
-
AI 会先问你要不要装 PaperSearch
|
|
69
|
+
AI 会先问你要不要装 PaperSearch 的命令行程序,你同意后装好,再带你配置学校订阅下载和 API key。
|
|
70
70
|
|
|
71
71
|
<p align="center"><img src="assets/install.webp" width="840" alt="安装演示:把一句话发给 AI,它先装好 Skill;引用 Skill 说“请开始配置”,它先问再装命令行程序,列出能用的功能,接着带你配置"></p>
|
|
72
72
|
|
|
73
73
|
### 2. 配置时装上学校订阅下载
|
|
74
74
|
|
|
75
|
-
说了“请开始配置”后,AI 会先问你要不要装[
|
|
75
|
+
说了“请开始配置”后,AI 会先问你要不要装[学校订阅下载](#1-学校订阅下载):用学校账号下载非 OA 文章的全文和补充材料,需要 Chrome(没有的话一起装),下载约 0.5 GB。你同意后它才安装,装完问你的学校并设好,然后弹出设置窗口。
|
|
76
76
|
|
|
77
77
|
- 不要的话说一声就跳过,之后不再提;检索和 OA 文章下载照常能用。
|
|
78
78
|
- 没有图形界面的服务器上不问、不装。
|
|
@@ -111,7 +111,7 @@ AI 会先问你要不要装 PaperSearch 的命令行程序,你同意后装好
|
|
|
111
111
|
|
|
112
112
|
功能对比:
|
|
113
113
|
|
|
114
|
-
| | 装好就能用 | API key |
|
|
114
|
+
| | 装好就能用 | API key | 学校订阅下载 |
|
|
115
115
|
|---|:---:|:---:|:---:|
|
|
116
116
|
| **检索** | | | |
|
|
117
117
|
|  检索论文、查引文和参考文献 | ✅ | — | — |
|
|
@@ -126,9 +126,28 @@ AI 会先问你要不要装 PaperSearch 的命令行程序,你同意后装好
|
|
|
126
126
|
| **需要准备** | Node.js 22 或以上 | 到各家网站申请 key | Google Chrome、学校账号 |
|
|
127
127
|
| **怎么开启** | 快速开始第 1 步 | 设置窗口或终端 | 配置时同意安装 |
|
|
128
128
|
|
|
129
|
-
### 1.
|
|
129
|
+
### 1. 学校订阅下载
|
|
130
130
|
|
|
131
|
-
|
|
131
|
+
开放渠道下不到的论文,可以借你学校的订阅来下:程序经你学校所属的学术身份联盟登录出版社,用学校账号下载。配置时只要说出学校名称(中文、英文或当地语言都行),程序会自己查出学校属于哪个联盟。
|
|
132
|
+
|
|
133
|
+
各国的学术身份联盟通过 [eduGAIN](https://edugain.org/) 互联,出版社借此认可各国学校的账号;没有加入本国联盟的学校,不少接入了 [OpenAthens](https://www.openathens.net/) 机构登录服务,程序也能经它登录。
|
|
134
|
+
|
|
135
|
+
**支持的学术身份联盟**(第一阶段:亚洲)
|
|
136
|
+
|
|
137
|
+
| 地区 | 学术身份联盟 | 全称 |
|
|
138
|
+
|---|---|---|
|
|
139
|
+
| 中国内地、澳门 | CARSI | CERNET 联邦认证与资源共享基础设施(CERNET Authentication and Resource Sharing Infrastructure) |
|
|
140
|
+
| 香港 | HKAF | Hong Kong Access Federation |
|
|
141
|
+
| 新加坡 | SGAF | Singapore Access Federation |
|
|
142
|
+
| 日本 | GakuNin(学認) | 学術認証フェデレーション(Academic Access Management Federation in Japan) |
|
|
143
|
+
| 韩国 | KAFE | Korean Access Federation |
|
|
144
|
+
| 马来西亚 | SIFULAN | SIFULAN Malaysian Access Federation |
|
|
145
|
+
| 未加入本国联盟的学校(东南亚多数大学等) | OpenAthens | OpenAthens 机构登录服务 |
|
|
146
|
+
|
|
147
|
+
- 每个联盟的支持情况和已实测的学校,见 [学术联盟支持表](skills/paper-search/references/federation-support.md)。
|
|
148
|
+
- 计划中:美国(InCommon)、英国(UK federation)、澳大利亚(AAF)、欧洲各国联盟,之后是 eduGAIN 里的其他国家,见 [路线图](docs/ROADMAP.zh.md)。
|
|
149
|
+
- 学校没有加入任何联盟、也没有接入 OpenAthens(只能用校园网、VPN 或图书馆代理)的,暂时用不了。
|
|
150
|
+
- 能不能下到某篇文章,还要看学校有没有订阅、出版社有没有给学校开通学校账号登录;没开通的,程序会写明原因。
|
|
132
151
|
|
|
133
152
|
- **学校账号就能用**:不用另外申请 key;出版社 API key 只覆盖 Elsevier、Springer 两家。
|
|
134
153
|
- **深度适配出版社**:深度优化了下载的通用流程,并且针对 30 多家出版社逐家写了专门规则,机构登录入口在哪、PDF 和补充材料怎么取,都按各自出版社的实际情况来,下载更准、更少漏篇。优化的出版社主要有:
|
|
@@ -220,7 +239,7 @@ paper-search carsi status --format text # 查看是否装好
|
|
|
220
239
|
1. **进度胶囊优化**:提醒时机更准,学校登录页能自动放行时不提前打扰;减少 Windows 上浏览器启动、换页时短暂跳到前台的情况,优化显示效果。
|
|
221
240
|
2. **并行下载**:不同出版社之间并行下载,同时处理多篇,缩短几十上百篇的总耗时;每家出版社仍遵守下载上限。
|
|
222
241
|
3. **Markdown 全文包**:除了 PDF,再交付原始 XML/HTML、Markdown 阅读副本和正文图片,图号、图注和正文引用一一对应,方便直接交给 AI 阅读和引用。
|
|
223
|
-
4.
|
|
242
|
+
4. **全球学校登录**:亚洲的学术身份联盟已支持;接下来是美国、英国、澳大利亚和欧洲各国联盟,之后覆盖 eduGAIN 里的所有国家;有条件的话再接入 WebVPN、EZProxy 等访问方式。
|
|
224
243
|
5. **检索论文、搜正文片段再优化**:参考同类工具的做法,进一步提升检索论文和搜正文片段的效果。
|
|
225
244
|
|
|
226
245
|
完整计划见 [路线图](docs/ROADMAP.zh.md),原理和代码结构见 [架构说明](docs/ARCHITECTURE.zh.md)。还想要什么功能,欢迎提 [Issue](https://github.com/dr-dumpling/PaperSearch/issues/new/choose) 和 PR;下载失败或想支持某家出版社,请用对应的 Issue 模板,想自己加出版社规则见 [carsi/CONTRIBUTING.md](carsi/CONTRIBUTING.md)。
|
|
@@ -16,6 +16,9 @@ class SupplementLink:
|
|
|
16
16
|
label: str = ""
|
|
17
17
|
# Discovery failures are recorded alongside downloaded files.
|
|
18
18
|
error: str = ""
|
|
19
|
+
# Found on the page but not shown to be this article's (a dataset the page
|
|
20
|
+
# only names): recorded with this reason, neither fetched nor counted.
|
|
21
|
+
set_aside: str = ""
|
|
19
22
|
|
|
20
23
|
|
|
21
24
|
class PublisherAdapter:
|
|
@@ -231,6 +234,13 @@ class PublisherAdapter:
|
|
|
231
234
|
school is chosen (``choose_institution``) and nothing else is clicked."""
|
|
232
235
|
return False
|
|
233
236
|
|
|
237
|
+
def institution_entry_signs_in(self, data: str) -> bool | None:
|
|
238
|
+
"""Whether an entry of the publisher's own institution search (its link,
|
|
239
|
+
data attributes and hidden fields, ``data``) signs the school in through
|
|
240
|
+
its identity provider: False = the publisher marks it as another route
|
|
241
|
+
(IP, VPN, a work email), None = no opinion."""
|
|
242
|
+
return None
|
|
243
|
+
|
|
234
244
|
def leave_email_step(self, page: Any, result: Any) -> bool:
|
|
235
245
|
"""The publisher's sign-in asks for the user's work email, not the school:
|
|
236
246
|
go back to its school search before anything is typed; True when clicked."""
|
|
@@ -23,6 +23,10 @@ from ...browser.driver import is_driver_error
|
|
|
23
23
|
from ...engine.router import elsevier_journal_article, extract_elsevier_pii
|
|
24
24
|
from ..base import PublisherAdapter, SupplementLink, register
|
|
25
25
|
from . import journal_site, sciencedirect
|
|
26
|
+
|
|
27
|
+
# An account's sign-in route in Elsevier ID's search results ("entityId": null or "...").
|
|
28
|
+
_ENTITY_ID = re.compile(r'"entityId"\s*:\s*(null|"[^"]*")')
|
|
29
|
+
_IP_OR_VPN_ONLY = re.compile(r"can grant access through either an IP address or a VPN", re.I)
|
|
26
30
|
from .journal_site import JournalSite, _record_pii
|
|
27
31
|
from .sciencedirect import ScienceDirectSite
|
|
28
32
|
|
|
@@ -208,14 +212,14 @@ class ElsevierAdapter(PublisherAdapter):
|
|
|
208
212
|
|
|
209
213
|
def open_institution_entry(self, page: Any, result: Any) -> bool | None:
|
|
210
214
|
clicked = self.click_institution_entry(page, result)
|
|
211
|
-
if self.d.
|
|
215
|
+
if self.d.federation is not None:
|
|
212
216
|
return clicked
|
|
213
217
|
return True if clicked else None # otherwise the generic entries are tried
|
|
214
218
|
|
|
215
219
|
def click_institution_entry(self, page: Any, result: Any) -> bool:
|
|
216
220
|
if self.d._is_human_login_page(page):
|
|
217
221
|
return False
|
|
218
|
-
manual_selection = self.d.
|
|
222
|
+
manual_selection = self.d.federation is not None
|
|
219
223
|
if manual_selection and urlparse(str(page.url)).hostname not in sciencedirect.HOSTS | {"auth.elsevier.com"}:
|
|
220
224
|
return False
|
|
221
225
|
try:
|
|
@@ -233,7 +237,23 @@ class ElsevierAdapter(PublisherAdapter):
|
|
|
233
237
|
|
|
234
238
|
def login_block_reason(self, page: Any, text: str) -> str | None:
|
|
235
239
|
# A remembered school's entry is a continuation, not a block.
|
|
236
|
-
|
|
240
|
+
if self.remembered_institution_entry(text):
|
|
241
|
+
return ""
|
|
242
|
+
# "Instructions from your organization": the school grants access only by
|
|
243
|
+
# IP address or VPN, no sign-in through it (Elsevier ID, 2026-11-11).
|
|
244
|
+
if (self.is_institution_chooser(str(getattr(page, "url", "") or ""))
|
|
245
|
+
and _IP_OR_VPN_ONLY.search(" ".join(text.split()))):
|
|
246
|
+
return "institution_federation_unavailable"
|
|
247
|
+
return None
|
|
248
|
+
|
|
249
|
+
def institution_entry_signs_in(self, data: str) -> bool | None:
|
|
250
|
+
"""Elsevier ID's organization search keeps each entry's account as JSON in a
|
|
251
|
+
hidden field: ``"entityId": null`` is an account without a federated
|
|
252
|
+
sign-in (its IP range, VPN, or a work email: "derivedFlowType": "EIA")."""
|
|
253
|
+
found = _ENTITY_ID.search(data or "")
|
|
254
|
+
if not found:
|
|
255
|
+
return None
|
|
256
|
+
return found.group(1) != "null"
|
|
237
257
|
|
|
238
258
|
def remembered_institution_entry(self, text: str) -> bool:
|
|
239
259
|
"""ScienceDirect shows "Access through <institution>" once an institution is remembered.
|
|
@@ -272,7 +272,7 @@ class IEEEAdapter(PublisherAdapter):
|
|
|
272
272
|
return True
|
|
273
273
|
except Exception:
|
|
274
274
|
continue
|
|
275
|
-
if d.
|
|
275
|
+
if d.federation is not None:
|
|
276
276
|
return False # no text match: never pick the first suggestion for the user
|
|
277
277
|
try:
|
|
278
278
|
input_box.press("ArrowDown", timeout=2_000)
|
|
@@ -23,7 +23,6 @@ from ....engine.batch_common import _is_browser_error, open_page
|
|
|
23
23
|
from ...base import PublisherAdapter, SupplementLink, register
|
|
24
24
|
|
|
25
25
|
_ARTICLE = re.compile(r"/doi/(?:(?:abs|full|pdf|epdf|pdfdirect|reader)/)?(10\.\d{4,9}/[^?#]+)", re.I)
|
|
26
|
-
_CARSI = "China CERNET Federation (CARSI)"
|
|
27
26
|
# Supplement files: /doi/suppl/<DOI>/suppl_file/<name>, with the link text.
|
|
28
27
|
_SUPPLEMENT_ROWS_JS = """() => [...document.querySelectorAll('a[href*="/doi/suppl/"]')].map(a => ({
|
|
29
28
|
href: a.href, label: ((a.textContent || '').trim() || a.getAttribute('title') || '').replace(/\\s+/g, ' ').trim().slice(0, 200)}))"""
|
|
@@ -139,8 +138,7 @@ class AtyponAdapter(PublisherAdapter):
|
|
|
139
138
|
# The access box's link, else the chooser's address: the same page (NEJM).
|
|
140
139
|
target = ((self.institution_link(page, result.doi) or self.chooser_url(str(getattr(page, "url", "") or "")))
|
|
141
140
|
if result is not None else "")
|
|
142
|
-
if not target or (d.
|
|
143
|
-
and not d._manual_institution_target_allowed(target)):
|
|
141
|
+
if not target or (d.federation is not None and not d._manual_institution_target_allowed(target)):
|
|
144
142
|
return None
|
|
145
143
|
# Opened, not clicked: a click soon after the article loaded left the
|
|
146
144
|
# page on the article (Neurological Research, cold start 2026-11-01, twice).
|
|
@@ -152,22 +150,27 @@ class AtyponAdapter(PublisherAdapter):
|
|
|
152
150
|
d = self.d
|
|
153
151
|
if not self._chooser(str(getattr(page, "url", "") or "")):
|
|
154
152
|
return False
|
|
155
|
-
|
|
156
|
-
|
|
153
|
+
ours = d.federation
|
|
154
|
+
chooser = page.locator("select#shib-search--fed")
|
|
155
|
+
if ours is None or not chooser.is_visible():
|
|
157
156
|
return None # a search box only: the engine chooses the school there
|
|
158
|
-
|
|
157
|
+
# The school's federation as this list names it (the federation layer).
|
|
158
|
+
label = ours.option_among(" ".join(text.split()) for text in chooser.locator("option").all_text_contents())
|
|
159
|
+
if label is None:
|
|
160
|
+
return None # not listed: the engine's federation-list rule reports it
|
|
161
|
+
changed = " ".join(chooser.locator("option:checked").inner_text().split()) != label
|
|
159
162
|
if changed:
|
|
160
|
-
# Changed by the user only on the very page where
|
|
163
|
+
# Changed by the user only on the very page where the federation was chosen; a
|
|
161
164
|
# chooser reloaded with its first federation is chosen again (the
|
|
162
165
|
# engine's one rule, review 2026-11-02).
|
|
163
166
|
here = d._federation_choice_page(page, result)
|
|
164
167
|
if here is None:
|
|
165
168
|
return False
|
|
166
|
-
|
|
167
|
-
d._federation_chosen(result, here,
|
|
169
|
+
chooser.select_option(label=label, timeout=5_000)
|
|
170
|
+
d._federation_chosen(result, here, ours.code)
|
|
168
171
|
# The federation is set here; the configured school is then chosen in
|
|
169
172
|
# the school list by the engine's assistance (2026-11-01: the configured
|
|
170
|
-
#
|
|
173
|
+
# school was chosen automatically), else by the user.
|
|
171
174
|
if not any(event["state"] == "institution_selection_required" for event in result.events):
|
|
172
|
-
d._event(result, "institution_selection_required",
|
|
175
|
+
d._event(result, "institution_selection_required", ours.code)
|
|
173
176
|
return changed
|
|
@@ -85,7 +85,8 @@ def _belongs(data: dict, doi: str, *, labelled: bool = False) -> bool:
|
|
|
85
85
|
|
|
86
86
|
|
|
87
87
|
def supplement_links(page: Any, doi: str, *, clock=time.monotonic, pause=time.sleep) -> list[SupplementLink] | None:
|
|
88
|
-
"""None means no Figshare route on this article; failures stay in the manifest.
|
|
88
|
+
"""None means no Figshare route on this article; failures stay in the manifest.
|
|
89
|
+
A resource not shown to be this article's is set aside (``set_aside``)."""
|
|
89
90
|
data = page.evaluate(_PAGE_LINKS)
|
|
90
91
|
if not isinstance(data, dict) or _doi(data.get("doi")) != _doi(doi):
|
|
91
92
|
return None
|
|
@@ -190,5 +191,10 @@ def supplement_links(page: Any, doi: str, *, clock=time.monotonic, pause=time.sl
|
|
|
190
191
|
raise
|
|
191
192
|
except Exception as exc:
|
|
192
193
|
reason = str(exc) if isinstance(exc, ValueError) and str(exc).startswith("figshare_") else "figshare_request_failed"
|
|
193
|
-
|
|
194
|
+
if reason == "figshare_article_mismatch":
|
|
195
|
+
# A dataset the article names (its data availability statement) is
|
|
196
|
+
# not its supplement unless one of them says so (JEM, 2026-11-11).
|
|
197
|
+
links.append(SupplementLink(root, "Figshare resource", set_aside=reason))
|
|
198
|
+
else:
|
|
199
|
+
links.append(SupplementLink(root, "Figshare supplementary material", error=reason))
|
|
194
200
|
return list(dict.fromkeys(links))
|
|
@@ -117,8 +117,7 @@ class SageAdapter(PublisherAdapter):
|
|
|
117
117
|
for value in redirects)
|
|
118
118
|
if (target.scheme == "https" and target.hostname == "journals.sagepub.com"
|
|
119
119
|
and target.path == "/action/ssostart" and result is not None
|
|
120
|
-
and (d.
|
|
121
|
-
or d._manual_institution_target_allowed(target.geturl()))
|
|
120
|
+
and (d.federation is None or d._manual_institution_target_allowed(target.geturl()))
|
|
122
121
|
and redirects and (home or any(d._url_matches_record(value, result.doi) for value in redirects))):
|
|
123
122
|
if home:
|
|
124
123
|
query["redirectUri"] = [article]
|
|
@@ -137,8 +136,7 @@ class SageAdapter(PublisherAdapter):
|
|
|
137
136
|
d = self.d
|
|
138
137
|
article = urlparse(str(page.url))._replace(fragment="").geturl()
|
|
139
138
|
target = f"{SSO_START}?{urlencode({'redirectUri': article})}"
|
|
140
|
-
if result is None or (d.
|
|
141
|
-
and not d._manual_institution_target_allowed(target)):
|
|
139
|
+
if result is None or (d.federation is not None and not d._manual_institution_target_allowed(target)):
|
|
142
140
|
return False
|
|
143
141
|
open_page(page, target, timeout_ms=30_000)
|
|
144
142
|
d._event(result, "sso_entry_clicked", "sage-institution-address")
|
|
@@ -138,29 +138,31 @@ class ThiemeAdapter(PublisherAdapter):
|
|
|
138
138
|
CONTINUE_GAP_SEC = 5
|
|
139
139
|
|
|
140
140
|
def choose_institution(self, page: Any, result: Any) -> bool | None:
|
|
141
|
-
"""On the federation chooser:
|
|
142
|
-
again while the page stays on this step
|
|
141
|
+
"""On the federation chooser: the school's federation as Thieme names it,
|
|
142
|
+
then the form's own Continue, again while the page stays on this step
|
|
143
|
+
(``CONTINUE_TRIES``)."""
|
|
143
144
|
d = self.d
|
|
144
145
|
current = urlparse(str(page.url))
|
|
145
146
|
if (current.scheme != "https" or current.netloc != "profile.thieme.de"
|
|
146
147
|
or current.path != "/HTML/sso/ejournals/shibboleth.htm"):
|
|
147
148
|
return False
|
|
149
|
+
ours = d.federation
|
|
148
150
|
federation = page.locator("select#federation")
|
|
149
|
-
if not federation.is_visible():
|
|
151
|
+
if ours is None or not federation.is_visible():
|
|
150
152
|
return False
|
|
151
|
-
label = "
|
|
152
|
-
if label
|
|
153
|
+
label = ours.option_among(" ".join(text.split()) for text in federation.locator("option").all_text_contents())
|
|
154
|
+
if label is None:
|
|
153
155
|
return False
|
|
154
|
-
changed = federation.locator("option:checked").inner_text() != label
|
|
156
|
+
changed = " ".join(federation.locator("option:checked").inner_text().split()) != label
|
|
155
157
|
if changed:
|
|
156
|
-
# Changed by the user only on the very page where
|
|
158
|
+
# Changed by the user only on the very page where the federation was chosen: Thieme
|
|
157
159
|
# reloads the step with its first federation selected after a Continue
|
|
158
160
|
# (2026-11-02), a new page chosen again (the engine's one rule).
|
|
159
161
|
here = d._federation_choice_page(page, result)
|
|
160
162
|
if here is None:
|
|
161
163
|
return False
|
|
162
164
|
federation.select_option(label=label, timeout=5_000)
|
|
163
|
-
d._federation_chosen(result, here,
|
|
165
|
+
d._federation_chosen(result, here, ours.code)
|
|
164
166
|
# Only the form's own fields: a cookie panel's search box (OneTrust's vendor
|
|
165
167
|
# search on this page, 2026-11-02) is not the page asking for the school.
|
|
166
168
|
school_box = federation.locator("xpath=ancestor::form[1]").locator(
|
|
@@ -178,11 +180,11 @@ class ThiemeAdapter(PublisherAdapter):
|
|
|
178
180
|
if (button.is_visible(timeout=1_500) is True
|
|
179
181
|
and d._click_control(page, button, result, "Thieme federation Continue")):
|
|
180
182
|
result._federation_continue_at = time.time()
|
|
181
|
-
d._event(result, "institution_federation_continue",
|
|
183
|
+
d._event(result, "institution_federation_continue", ours.code)
|
|
182
184
|
return True
|
|
183
185
|
except Exception as exc:
|
|
184
186
|
if not _is_browser_error(exc):
|
|
185
187
|
raise
|
|
186
188
|
if not any(event["state"] == "institution_selection_required" for event in result.events):
|
|
187
|
-
d._event(result, "institution_selection_required",
|
|
189
|
+
d._event(result, "institution_selection_required", ours.code)
|
|
188
190
|
return changed
|
|
@@ -21,8 +21,9 @@ class WorldScientificAdapter(AtyponAdapter):
|
|
|
21
21
|
def chooser_block_reason(self, page: Any, url: str, text: str) -> str | None:
|
|
22
22
|
if "worldscientific.com/action/ssostart" not in url:
|
|
23
23
|
return None
|
|
24
|
+
federation = self.d.federation
|
|
24
25
|
if any(label in text for label in ("find your institution", "type the name of your institution",
|
|
25
26
|
"select your federation", "select your institution",
|
|
26
|
-
|
|
27
|
+
*(f.lower() for f in (federation.chooser_labels if federation else ())))):
|
|
27
28
|
return ""
|
|
28
29
|
return "sso_redirect_stalled"
|
|
@@ -40,10 +40,23 @@ def _data_dir() -> Path:
|
|
|
40
40
|
# setup
|
|
41
41
|
# ---------------------------------------------------------------------------
|
|
42
42
|
|
|
43
|
+
def _federation_code(cfg: dict[str, Any]) -> str:
|
|
44
|
+
"""The configured federation's code; "carsi" for the old switch alone."""
|
|
45
|
+
from .federations import configured
|
|
46
|
+
|
|
47
|
+
federation = configured(cfg)
|
|
48
|
+
return federation.code if federation else ("carsi" if cfg.get("carsi_enabled") else "")
|
|
49
|
+
|
|
50
|
+
|
|
43
51
|
def _institutional_summary(cfg: dict[str, Any]) -> dict[str, Any]:
|
|
52
|
+
from .federations import by_code
|
|
53
|
+
|
|
54
|
+
federation = by_code(_federation_code(cfg))
|
|
44
55
|
return {
|
|
45
56
|
"data_dir": str(_data_dir()),
|
|
46
|
-
"federation":
|
|
57
|
+
"federation": federation.code if federation else "",
|
|
58
|
+
"federation_name": federation.name if federation else "",
|
|
59
|
+
"federation_country": federation.country if federation else "",
|
|
47
60
|
"carsi_enabled": bool(cfg.get("carsi_enabled")),
|
|
48
61
|
"carsi_institution_hint": cfg.get("carsi_idp_name") or "",
|
|
49
62
|
"carsi_institution_en": cfg.get("carsi_idp_name_en") or "",
|
|
@@ -81,14 +94,14 @@ def _environment_check(cfg: dict[str, Any]) -> tuple[bool, list[dict[str, str]],
|
|
|
81
94
|
except Exception as exc: # pragma: no cover - import problems are themselves a finding
|
|
82
95
|
add("browser_backend", False, f"{type(exc).__name__}")
|
|
83
96
|
|
|
84
|
-
federation =
|
|
85
|
-
add("institutional_route", federation
|
|
97
|
+
federation = _federation_code(cfg)
|
|
98
|
+
add("institutional_route", bool(federation), federation or 'none; run: setup --institution "<your school>"')
|
|
86
99
|
school = str(cfg.get("carsi_idp_name") or "").strip()
|
|
87
|
-
if federation
|
|
88
|
-
# A name alone (saved before setup used the
|
|
100
|
+
if federation and school:
|
|
101
|
+
# A name alone (saved before setup used the member lists) is not found in English-only pickers.
|
|
89
102
|
complete = bool(cfg.get("idp_entity_id") and cfg.get("carsi_idp_name_en"))
|
|
90
|
-
add("
|
|
91
|
-
school if complete else f'only the name is saved; run: setup --
|
|
103
|
+
add("school", complete,
|
|
104
|
+
school if complete else f'only the name is saved; run: setup --institution "{school}"')
|
|
92
105
|
for item in ("output_dir", "cache_dir"):
|
|
93
106
|
value = cfg.get(item) or ""
|
|
94
107
|
add(item, bool(value), value)
|
|
@@ -123,10 +136,39 @@ def _set_carsi_school(cfg: dict[str, Any], query: str) -> dict[str, Any] | None:
|
|
|
123
136
|
return {"error": "carsi_school_ambiguous", "query": query, "count": len(candidates),
|
|
124
137
|
"candidates": [s.summary() for s in candidates[:10]],
|
|
125
138
|
"hint": "run again with the full name, the domain or the entityID of one candidate"}
|
|
126
|
-
cfg.update(carsi_idp_name=school.name, carsi_idp_name_en=school.name_en, idp_entity_id=school.entity_id
|
|
139
|
+
cfg.update(carsi_idp_name=school.name, carsi_idp_name_en=school.name_en, idp_entity_id=school.entity_id,
|
|
140
|
+
idp_login_hosts=[], idp_login_pages=[], idp_domains=[school.domain] if school.domain else [])
|
|
127
141
|
return None
|
|
128
142
|
|
|
129
143
|
|
|
144
|
+
def _find_school(cfg: dict[str, Any], query: str, also: list[str]) -> dict[str, Any] | None:
|
|
145
|
+
"""Save the school the user named, any federation (``federations.schools``);
|
|
146
|
+
the problem to report when there is not exactly one."""
|
|
147
|
+
from .federations import schools
|
|
148
|
+
|
|
149
|
+
found = schools.find(query, cfg, _data_dir(), also=also)
|
|
150
|
+
if found.school is not None:
|
|
151
|
+
schools.save(cfg, found.school)
|
|
152
|
+
return None
|
|
153
|
+
if found.candidates:
|
|
154
|
+
return {"error": "school_ambiguous", "query": query, "count": len(found.candidates),
|
|
155
|
+
"candidates": [s.summary() for s in found.candidates],
|
|
156
|
+
"hint": "ask the user which one, then run again with its entity_id as --institution"}
|
|
157
|
+
if found.unsupported:
|
|
158
|
+
return {"error": "federation_not_supported", "query": query,
|
|
159
|
+
"found": [{"name": n, "registration_authority": ra} for n, ra in found.unsupported[:10]],
|
|
160
|
+
"hint": "the school signs in through a federation not supported yet"}
|
|
161
|
+
if found.unavailable:
|
|
162
|
+
return {"error": "school_list_unavailable", "query": query, "sources": found.unavailable,
|
|
163
|
+
"hint": "retry later; `setup --carsi` without --institution leaves the school to the login window"}
|
|
164
|
+
return {"error": "school_not_found", "query": query,
|
|
165
|
+
"reasons": ["the name is written differently from the federations' lists",
|
|
166
|
+
"the school has not joined an identity federation or OpenAthens: it gives access by campus "
|
|
167
|
+
"network, VPN or a library proxy only, and school subscription download cannot sign in for it"],
|
|
168
|
+
"hint": "try the school's official name in its own language or in English (--also-name for another name), "
|
|
169
|
+
"its web domain or its entityID; if it is still not found, tell the user the second reason"}
|
|
170
|
+
|
|
171
|
+
|
|
130
172
|
def _cmd_setup(args: argparse.Namespace) -> int:
|
|
131
173
|
from .config import load_config, save_config
|
|
132
174
|
|
|
@@ -155,16 +197,13 @@ def _cmd_setup(args: argparse.Namespace) -> int:
|
|
|
155
197
|
cfg["carsi_enabled"] = False
|
|
156
198
|
changed = True
|
|
157
199
|
if args.institution:
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
if name != cfg.get("carsi_idp_name"):
|
|
166
|
-
# The English name and entityID belong to the previous school.
|
|
167
|
-
cfg.update(carsi_idp_name=name, carsi_idp_name_en="", idp_entity_id="")
|
|
200
|
+
# With --carsi only CARSI's member list is asked; otherwise every
|
|
201
|
+
# supported federation, and the school's federation is saved with it.
|
|
202
|
+
problem = (_set_carsi_school(cfg, args.institution) if args.carsi
|
|
203
|
+
else _find_school(cfg, args.institution, list(args.also_name or ())))
|
|
204
|
+
if problem:
|
|
205
|
+
print(json.dumps(problem, ensure_ascii=False, indent=2))
|
|
206
|
+
return 1
|
|
168
207
|
changed = True
|
|
169
208
|
|
|
170
209
|
if args.output_dir:
|
|
@@ -246,7 +285,7 @@ def _cmd_login(args: argparse.Namespace) -> int:
|
|
|
246
285
|
return 2
|
|
247
286
|
if not _any_institutional_configured(load_config()):
|
|
248
287
|
print(json.dumps({"success": False, "error": "school_not_configured",
|
|
249
|
-
"hint": 'run: setup --
|
|
288
|
+
"hint": 'run: setup --institution "<your school>"'}, ensure_ascii=False))
|
|
250
289
|
return 2
|
|
251
290
|
import shutil
|
|
252
291
|
import tempfile
|
|
@@ -526,9 +565,13 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
526
565
|
sub.add_parser("run", help="start the MCP stdio server").set_defaults(func=_cmd_run)
|
|
527
566
|
|
|
528
567
|
st = sub.add_parser("setup", help="show or change institutional access settings")
|
|
529
|
-
st.add_argument("--carsi", action="store_true", help="use the CARSI federation;
|
|
530
|
-
st.add_argument("--no-carsi", action="store_true")
|
|
531
|
-
st.add_argument("--institution", help="
|
|
568
|
+
st.add_argument("--carsi", action="store_true", help="use the CARSI federation; with --institution only CARSI's member list is asked; without it the school is chosen in the login window")
|
|
569
|
+
st.add_argument("--no-carsi", action="store_true", help="no federation: the institution is chosen by hand")
|
|
570
|
+
st.add_argument("--institution", help="your school: its name in its own language or English, its domain or its entityID. "
|
|
571
|
+
"It is looked up in the supported federations' member lists; its federation, names, entityID and "
|
|
572
|
+
"login hosts are saved and publisher pickers then select only that school")
|
|
573
|
+
st.add_argument("--also-name", action="append", metavar="NAME",
|
|
574
|
+
help="another name of the same school (its official English name when --institution is in another language); repeatable")
|
|
532
575
|
st.add_argument("--list-carsi-schools", nargs="?", const="", metavar="KEYWORD", help="print CARSI member schools, optionally only those matching KEYWORD")
|
|
533
576
|
st.add_argument("--output-dir")
|
|
534
577
|
st.add_argument("--check", action="store_true", help="environment check; exit 2 when something is missing")
|
|
@@ -29,6 +29,7 @@ import sqlite3
|
|
|
29
29
|
from pathlib import Path
|
|
30
30
|
from typing import Any, Iterable
|
|
31
31
|
|
|
32
|
+
from . import federations
|
|
32
33
|
from .browser.backend import SESSION_COOKIES_FILE, chrome_profile_dir, profile_holder
|
|
33
34
|
from .browser.cookies import _CLOUDFLARE_COOKIE_NAMES, PUBLISHER_DOMAINS
|
|
34
35
|
from .engine.batch_institution import InstitutionMixin, _school_auth_patterns
|
|
@@ -43,7 +44,8 @@ PERSONAL_ACCOUNT_HOSTS = ("id.elsevier.com", "auth.elsevier.com")
|
|
|
43
44
|
# (Elsevier: "id.inst", "id.wayf.result.acct"); that part goes.
|
|
44
45
|
_REMEMBERED_SCHOOL_NAME = re.compile(r"(?:^|[._-])(?:inst|institution|wayf|idp|shib)(?:[._-]|$)", re.I)
|
|
45
46
|
# Services that remember the chosen school or carry the federated login.
|
|
46
|
-
FEDERATION_HOSTS = (
|
|
47
|
+
FEDERATION_HOSTS = (*federations.service_domains(), "openathens.net", "seamlessaccess.org", "sams-sigma.com",
|
|
48
|
+
"iam.atypon.com")
|
|
47
49
|
_CONSENT_NAME = re.compile(r"consent|optanon|cookielaw|gdpr", re.I)
|
|
48
50
|
# Cookie files the engine restores into a browser.
|
|
49
51
|
_CACHE_COOKIE_FILES = ("publisher_cookies.json",)
|