papersearch 0.4.10 → 0.4.12
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/LICENSE +1 -1
- package/README.en.md +128 -226
- package/README.md +128 -226
- package/assets/carsi-flow.en.png +0 -0
- package/assets/carsi-flow.png +0 -0
- package/assets/overview.en.png +0 -0
- package/assets/overview.png +0 -0
- package/carsi/README.md +1 -1
- package/carsi/paper_search_carsi/adapters/ams/__init__.py +12 -0
- package/carsi/paper_search_carsi/adapters/elsevier/__init__.py +5 -2
- package/carsi/paper_search_carsi/adapters/elsevier/sciencedirect.py +18 -1
- package/carsi/paper_search_carsi/adapters/iop/__init__.py +19 -4
- package/carsi/paper_search_carsi/adapters/platforms/atypon/__init__.py +24 -14
- package/carsi/paper_search_carsi/adapters/platforms/silverchair/__init__.py +23 -0
- package/carsi/paper_search_carsi/assets/capsule.html +36 -9
- package/carsi/paper_search_carsi/browser/preview.py +16 -3
- package/carsi/paper_search_carsi/browser/watchdog.py +68 -4
- package/carsi/paper_search_carsi/capsule_placement.py +51 -31
- package/carsi/paper_search_carsi/download_diagnostics.py +3 -1
- package/carsi/paper_search_carsi/engine/access_rules.py +11 -0
- package/carsi/paper_search_carsi/engine/batch.py +21 -3
- package/carsi/paper_search_carsi/engine/batch_access.py +3 -0
- package/carsi/paper_search_carsi/engine/batch_capture.py +61 -11
- package/carsi/paper_search_carsi/engine/batch_common.py +4 -0
- package/carsi/paper_search_carsi/engine/batch_diagnostics.py +3 -0
- package/carsi/paper_search_carsi/engine/batch_institution.py +59 -40
- package/carsi/paper_search_carsi/engine/batch_login.py +121 -16
- package/carsi/paper_search_carsi/engine/bridge.py +5 -2
- package/carsi/paper_search_carsi/engine/supplements.py +66 -4
- package/carsi/paper_search_carsi/progress_capsule.py +93 -11
- package/carsi/paper_search_carsi/progress_macos.py +35 -10
- package/carsi/paper_search_carsi/progress_reporter.py +42 -18
- package/carsi/paper_search_carsi/progress_view.py +35 -13
- package/carsi/paper_search_carsi/server.py +7 -1
- package/dist/capabilities/journal-metrics/JournalMetricsService.d.ts.map +1 -1
- package/dist/capabilities/journal-metrics/JournalMetricsService.js +2 -1
- package/dist/capabilities/journal-metrics/JournalMetricsService.js.map +1 -1
- package/dist/capabilities/pdf-discovery/batch.d.ts +2 -0
- package/dist/capabilities/pdf-discovery/batch.d.ts.map +1 -1
- package/dist/capabilities/pdf-discovery/batch.js +45 -10
- package/dist/capabilities/pdf-discovery/batch.js.map +1 -1
- package/dist/capabilities/pdf-discovery/batchSummary.d.ts +7 -1
- package/dist/capabilities/pdf-discovery/batchSummary.d.ts.map +1 -1
- package/dist/capabilities/pdf-discovery/batchSummary.js +24 -0
- package/dist/capabilities/pdf-discovery/batchSummary.js.map +1 -1
- package/dist/capabilities/pdf-discovery/carsi/CarsiAttempt.d.ts.map +1 -1
- package/dist/capabilities/pdf-discovery/carsi/CarsiAttempt.js +6 -0
- package/dist/capabilities/pdf-discovery/carsi/CarsiAttempt.js.map +1 -1
- package/dist/capabilities/pdf-discovery/carsi/CarsiMcpClient.d.ts +3 -0
- package/dist/capabilities/pdf-discovery/carsi/CarsiMcpClient.d.ts.map +1 -1
- package/dist/capabilities/pdf-discovery/carsi/CarsiMcpClient.js +29 -4
- package/dist/capabilities/pdf-discovery/carsi/CarsiMcpClient.js.map +1 -1
- package/dist/capabilities/pdf-discovery/carsi/CarsiReadiness.d.ts +2 -0
- package/dist/capabilities/pdf-discovery/carsi/CarsiReadiness.d.ts.map +1 -1
- package/dist/capabilities/pdf-discovery/carsi/CarsiReadiness.js +2 -0
- package/dist/capabilities/pdf-discovery/carsi/CarsiReadiness.js.map +1 -1
- package/dist/capabilities/pdf-discovery/carsi/types.d.ts +12 -0
- package/dist/capabilities/pdf-discovery/carsi/types.d.ts.map +1 -1
- package/dist/capabilities/pdf-discovery/tiers/publisherApi.d.ts.map +1 -1
- package/dist/capabilities/pdf-discovery/tiers/publisherApi.js +2 -1
- package/dist/capabilities/pdf-discovery/tiers/publisherApi.js.map +1 -1
- package/dist/cli.js +19 -8
- package/dist/cli.js.map +1 -1
- package/dist/config/ConfigService.d.ts.map +1 -1
- package/dist/config/ConfigService.js +28 -2
- package/dist/config/ConfigService.js.map +1 -1
- package/dist/config/apiKeySignup.d.ts +13 -0
- package/dist/config/apiKeySignup.d.ts.map +1 -0
- package/dist/config/apiKeySignup.js +32 -0
- package/dist/config/apiKeySignup.js.map +1 -0
- package/dist/infrastructure/runlog/failureClass.d.ts.map +1 -1
- package/dist/infrastructure/runlog/failureClass.js +6 -0
- package/dist/infrastructure/runlog/failureClass.js.map +1 -1
- package/dist/management/capability-profile/index.d.ts +7 -0
- package/dist/management/capability-profile/index.d.ts.map +1 -1
- package/dist/management/capability-profile/index.js +7 -0
- package/dist/management/capability-profile/index.js.map +1 -1
- package/dist/management/carsi/installer.js +5 -5
- package/dist/management/carsi/installer.js.map +1 -1
- package/dist/management/diagnostics/index.d.ts.map +1 -1
- package/dist/management/diagnostics/index.js +4 -1
- package/dist/management/diagnostics/index.js.map +1 -1
- package/dist/management/failures/exportReport.js +3 -3
- package/dist/management/reports/index.d.ts.map +1 -1
- package/dist/management/reports/index.js +6 -1
- package/dist/management/reports/index.js.map +1 -1
- package/dist/management/updates/index.d.ts +6 -1
- package/dist/management/updates/index.d.ts.map +1 -1
- package/dist/management/updates/index.js +18 -11
- package/dist/management/updates/index.js.map +1 -1
- package/dist/platforms/SemanticScholarSearcher.d.ts.map +1 -1
- package/dist/platforms/SemanticScholarSearcher.js +2 -1
- package/dist/platforms/SemanticScholarSearcher.js.map +1 -1
- package/package.json +2 -3
- package/skills/paper-search/SKILL.md +8 -14
- package/skills/paper-search/references/browser-download.md +7 -6
- package/skills/paper-search/references/capability-routing.md +3 -3
- package/skills/paper-search/references/carsi-setup.md +1 -1
- package/skills/paper-search/references/cli-contract.md +2 -2
- package/skills/paper-search/references/management-layer.md +1 -1
- package/skills/paper-search/references/publisher-support.md +6 -4
- package/skills/paper-search/references/troubleshooting.md +1 -2
- package/carsi/NOTICE +0 -5
|
@@ -59,20 +59,7 @@ class AtyponAdapter(PublisherAdapter):
|
|
|
59
59
|
"""
|
|
60
60
|
landing_path = f"/doi/suppl/{doi.lower()}"
|
|
61
61
|
for attempt in range(2):
|
|
62
|
-
links
|
|
63
|
-
landing = ""
|
|
64
|
-
rows = page.evaluate(_SUPPLEMENT_ROWS_JS)
|
|
65
|
-
for row in rows if isinstance(rows, list) and doi else []:
|
|
66
|
-
target = urlparse(str(row.get("href") or "") if isinstance(row, dict) else "")
|
|
67
|
-
url = target._replace(fragment="").geturl()
|
|
68
|
-
if not self._on_site(url):
|
|
69
|
-
continue
|
|
70
|
-
path = unquote(target.path).lower()
|
|
71
|
-
if path.startswith(landing_path + "/suppl_file/"):
|
|
72
|
-
if url not in {link.url for link in links}:
|
|
73
|
-
links.append(SupplementLink(url, str(row.get("label") or "")))
|
|
74
|
-
elif path.rstrip("/") == landing_path:
|
|
75
|
-
landing = landing or url
|
|
62
|
+
links, landing = self._listed_supplements(page, doi)
|
|
76
63
|
if links or not landing or attempt:
|
|
77
64
|
return links
|
|
78
65
|
if unquote(urlparse(str(page.url)).path).lower().rstrip("/") == landing_path:
|
|
@@ -80,6 +67,29 @@ class AtyponAdapter(PublisherAdapter):
|
|
|
80
67
|
open_page(page, landing, timeout_ms=30_000)
|
|
81
68
|
return []
|
|
82
69
|
|
|
70
|
+
def listed_supplement_links(self, page: Any, doi: str) -> list[SupplementLink]:
|
|
71
|
+
"""The files this page lists itself, read without leaving it."""
|
|
72
|
+
return self._listed_supplements(page, doi)[0]
|
|
73
|
+
|
|
74
|
+
def _listed_supplements(self, page: Any, doi: str) -> tuple[list[SupplementLink], str]:
|
|
75
|
+
"""``(files, landing page)`` linked from this page for this article."""
|
|
76
|
+
landing_path = f"/doi/suppl/{doi.lower()}"
|
|
77
|
+
links: list[SupplementLink] = []
|
|
78
|
+
landing = ""
|
|
79
|
+
rows = page.evaluate(_SUPPLEMENT_ROWS_JS)
|
|
80
|
+
for row in rows if isinstance(rows, list) and doi else []:
|
|
81
|
+
target = urlparse(str(row.get("href") or "") if isinstance(row, dict) else "")
|
|
82
|
+
url = target._replace(fragment="").geturl()
|
|
83
|
+
if not self._on_site(url):
|
|
84
|
+
continue
|
|
85
|
+
path = unquote(target.path).lower()
|
|
86
|
+
if path.startswith(landing_path + "/suppl_file/"):
|
|
87
|
+
if url not in {link.url for link in links}:
|
|
88
|
+
links.append(SupplementLink(url, str(row.get("label") or "")))
|
|
89
|
+
elif path.rstrip("/") == landing_path:
|
|
90
|
+
landing = landing or url
|
|
91
|
+
return links, landing
|
|
92
|
+
|
|
83
93
|
def institution_chooser_open(self, page: Any) -> bool:
|
|
84
94
|
return self._chooser(str(getattr(page, "url", "") or "")) and page.locator("select#shib-search--fed").is_visible()
|
|
85
95
|
|
|
@@ -28,6 +28,29 @@ _SUPPLEMENT_ROWS_JS = """() => [...document.querySelectorAll('a[href]')].map(a =
|
|
|
28
28
|
in_section: !!a.closest('[class*="supplementary-material"], .dataSuppLink')}))"""
|
|
29
29
|
|
|
30
30
|
|
|
31
|
+
# The article toolbar's content filters ("Figures & tables", "Video", "Supplementary
|
|
32
|
+
# Material", ...): a kind the article has is marked "has-content", one it lacks "hide".
|
|
33
|
+
_CONTENT_FILTERS_JS = """() => ({
|
|
34
|
+
doi: document.querySelector('meta[name="citation_doi"]')?.content || '',
|
|
35
|
+
filters: [...document.querySelectorAll('li.article-content-filter')].map(li => ({
|
|
36
|
+
label: (li.textContent || '').replace(/\\s+/g, ' ').trim(),
|
|
37
|
+
hide: li.classList.contains('hide'), has: li.classList.contains('has-content')}))})"""
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def declares_no_supplements(page: Any, doi: str) -> bool:
|
|
41
|
+
"""This article's own Silverchair page says it has no supplementary material:
|
|
42
|
+
its "Supplementary Material" filter hidden while another kind is marked as
|
|
43
|
+
present (pubs.aip.org, whose files are otherwise found only through Figshare
|
|
44
|
+
links, 2026-11-08). Any other page says nothing."""
|
|
45
|
+
data = page.evaluate(_CONTENT_FILTERS_JS)
|
|
46
|
+
if not isinstance(data, dict) or str(data.get("doi") or "").lower() != (doi or "").lower():
|
|
47
|
+
return False
|
|
48
|
+
filters = [f for f in data.get("filters") or () if isinstance(f, dict)]
|
|
49
|
+
supplements = [f for f in filters if re.fullmatch(r"supplementary (?:material|data)", str(f.get("label") or ""), re.I)]
|
|
50
|
+
return (bool(supplements) and all(f.get("hide") and not f.get("has") for f in supplements)
|
|
51
|
+
and any(f.get("has") for f in filters))
|
|
52
|
+
|
|
53
|
+
|
|
31
54
|
def supplement_links(page: Any, doi: str, hosts: frozenset[str]) -> list[SupplementLink]:
|
|
32
55
|
"""This article's supplementary files on a Silverchair page: Silverchair's own
|
|
33
56
|
address ``/<journal>/article-supplement/<article id>/<type>/<name>/`` on the
|
|
@@ -86,6 +86,10 @@ svg.i { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-widt
|
|
|
86
86
|
.paper .name { line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
|
|
87
87
|
.paper .where { color: var(--faint); font-size: 12px; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
88
88
|
.paper .notice { color: var(--accent); font-size: 12px; margin-top: 3px; }
|
|
89
|
+
.paper-link { display: block; width: 100%; padding: 0; border: 0; background: none; font: inherit; color: inherit; text-align: left; cursor: pointer; border-radius: 6px; }
|
|
90
|
+
.paper-link .name, .paper-link .where, .paper-link .notice { display: block; }
|
|
91
|
+
.paper-link:hover .name { text-decoration: underline; }
|
|
92
|
+
.paper-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
|
|
89
93
|
.steps { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
|
|
90
94
|
.steps .bars { display: flex; gap: 3px; flex: 1; }
|
|
91
95
|
.steps .bars span { flex: 1; height: 3px; border-radius: 2px; background: var(--track); }
|
|
@@ -159,6 +163,10 @@ svg.i { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-widt
|
|
|
159
163
|
.paper-list li { font-size: 12px; padding: 3px 0; }
|
|
160
164
|
.paper-list .t, .paper-list .w { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
161
165
|
.paper-list .w, .paper-list .more { color: var(--faint); }
|
|
166
|
+
.paper-list .open-article { display: block; width: 100%; padding: 0; border: none; background: none; text-align: left;
|
|
167
|
+
font: inherit; color: inherit; cursor: pointer; }
|
|
168
|
+
.paper-list .open-article:hover .t { color: var(--accent); text-decoration: underline; }
|
|
169
|
+
.paper-list .open-article:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-radius: 3px; }
|
|
162
170
|
.tag { display: inline-block; font-size: 11px; line-height: 16px; padding: 0 6px; border-radius: 5px; flex: none; }
|
|
163
171
|
.tag.no_access, .tag.other { background: var(--hover); color: var(--fg); }
|
|
164
172
|
.tag.user_or_external { background: var(--warn-bg); color: var(--warn); }
|
|
@@ -254,9 +262,14 @@ function header(title, sub, closable) {
|
|
|
254
262
|
function paperBlock() {
|
|
255
263
|
const v = V;
|
|
256
264
|
const note = flash.text && Date.now() < flash.until ? flash.text : v.notice;
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
265
|
+
// The paper being downloaded: a click shows its browser while it has one (user request, 2026-11-08).
|
|
266
|
+
const tag = v.browser ? "span" : "div";
|
|
267
|
+
let html = '<div class="paper">' + (v.browser
|
|
268
|
+
? '<button type="button" class="paper-link" data-act="show_browser" title="点击切到下载浏览器" aria-label="切到下载浏览器">' : "")
|
|
269
|
+
+ "<" + tag + ' class="name">' + esc(v.title || v.current || "") + "</" + tag + ">";
|
|
270
|
+
html += note ? "<" + tag + ' class="notice">' + esc(note) + "</" + tag + ">"
|
|
271
|
+
: (v.where ? "<" + tag + ' class="where">' + esc(v.where) + (v.title && v.current ? " · " + esc(v.current) : "") + "</" + tag + ">" : "");
|
|
272
|
+
if (v.browser) html += "</button>";
|
|
260
273
|
if (v.step) {
|
|
261
274
|
html += '<div class="steps"><div class="bars">' + v.steps.map((_, i) =>
|
|
262
275
|
"<span" + (i < v.step.index ? ' class="done"' : i === v.step.index ? ' class="now"' : "") + "></span>").join("")
|
|
@@ -321,9 +334,11 @@ function attentionCard() {
|
|
|
321
334
|
|
|
322
335
|
const CLASS_TAGS = { no_access: "没权限", user_or_external: "外部原因", unsupported: "暂不支持", unexplained: "原因不明", other: "其他" };
|
|
323
336
|
let openGroups = null, groupsRun = ""; // null: each reason row as the view opens it
|
|
337
|
+
// Main-text rows first, then the supplementary files' rows, numbered on.
|
|
338
|
+
function allGroups() { return V.summary.groups.concat(V.summary.supplement_groups || []); }
|
|
324
339
|
function groupOpen(i) {
|
|
325
340
|
if (groupsRun !== V.run_id) { openGroups = null; groupsRun = V.run_id; }
|
|
326
|
-
return openGroups ? openGroups.has(i) : !!
|
|
341
|
+
return openGroups ? openGroups.has(i) : !!(allGroups()[i] || {}).open;
|
|
327
342
|
}
|
|
328
343
|
function toggleGroup(i) {
|
|
329
344
|
const opened = !groupOpen(i);
|
|
@@ -331,14 +346,19 @@ function toggleGroup(i) {
|
|
|
331
346
|
render(true);
|
|
332
347
|
}
|
|
333
348
|
|
|
334
|
-
function reasonRow(g, i) {
|
|
349
|
+
function reasonRow(g, i, brief) {
|
|
335
350
|
const opened = groupOpen(i);
|
|
336
351
|
let html = '<div class="grp"><button type="button" class="row" data-act="group" data-group="' + i + '" aria-expanded="' + opened + '">'
|
|
337
352
|
+ '<span class="tag ' + esc(g.cls) + '">' + esc(CLASS_TAGS[g.cls] || "") + '</span><span class="reason">' + esc(g.reason) + "</span>"
|
|
338
353
|
+ '<span class="n">' + g.count + " 篇</span>" + icon(opened ? "down" : "right") + "</button>";
|
|
339
|
-
if (!opened) return html + (g.where ? '<div class="m">' + esc(g.where) + "</div>" : "") + "</div>";
|
|
354
|
+
if (!opened) return html + (g.where && !brief ? '<div class="m">' + esc(g.where) + "</div>" : "") + "</div>";
|
|
340
355
|
return html + '<ul class="paper-list' + (g.papers.length > 5 ? " scroll" : "") + '">'
|
|
341
|
-
+ g.papers.map((p) =>
|
|
356
|
+
+ g.papers.map((p) => {
|
|
357
|
+
const lines = '<div class="t">' + esc(p.title) + "</div>" + (p.where ? '<div class="w">' + esc(p.where) + "</div>" : "");
|
|
358
|
+
// The article's page in the user's browser, to fetch it by hand (user, 2026-11-08).
|
|
359
|
+
return "<li>" + (p.doi ? '<button type="button" class="open-article" data-act="open_article" data-doi="' + esc(p.doi)
|
|
360
|
+
+ '" title="在浏览器打开这篇文章">' + lines + "</button>" : lines) + "</li>";
|
|
361
|
+
}).join("")
|
|
342
362
|
+ (g.more ? '<li class="more">另有 ' + g.more + " 篇未列出</li>" : "") + "</ul></div>";
|
|
343
363
|
}
|
|
344
364
|
|
|
@@ -349,8 +369,14 @@ function doneCard() {
|
|
|
349
369
|
+ '<div><b' + (v.bad ? ' style="color:var(--bad)"' : "") + ">" + v.bad + "</b><span>失败</span></div>"
|
|
350
370
|
+ "<div><b>" + esc(v.elapsed || "—") + "</b><span>用时</span></div></div>";
|
|
351
371
|
if (s && s.groups.length) {
|
|
352
|
-
|
|
353
|
-
|
|
372
|
+
const apart = s.supplement_groups && s.supplement_groups.length;
|
|
373
|
+
html += '<div class="sec"><div class="sec-h"><b>' + (apart ? "正文未下到 " : "未完成 ") + v.bad + " 篇</b><span>按原因</span></div>"
|
|
374
|
+
+ s.groups.map((g, i) => reasonRow(g, i)).join("") + "</div>";
|
|
375
|
+
}
|
|
376
|
+
// Main text and supplementary files apart, kept short: closed rows, no journal line (user, 2026-11-08).
|
|
377
|
+
if (s && s.supplement_groups && s.supplement_groups.length) {
|
|
378
|
+
html += '<div class="sec"><div class="sec-h"><b>附录未下全 ' + s.supplement_missing + " 篇</b><span>正文已保存</span></div>"
|
|
379
|
+
+ s.supplement_groups.map((g, i) => reasonRow(g, s.groups.length + i, true)).join("") + "</div>";
|
|
354
380
|
}
|
|
355
381
|
if (s && v.ok) {
|
|
356
382
|
html += '<div class="sec"><div class="sec-h"><b>已完成 ' + v.ok + " 篇</b></div>"
|
|
@@ -519,6 +545,7 @@ async function act(action, target) {
|
|
|
519
545
|
case "minimize": open = false; panel = ""; render(true); return api().minimize(); // back as a capsule when restored
|
|
520
546
|
case "close": closing = true; ++fitGeneration; clearInterval(pollTimer); clearTimeout(hoverTimer); clearTimeout(leaveTimer); return api().request_close(); // no call left waiting on a closed page
|
|
521
547
|
case "folder": return api().open_folder();
|
|
548
|
+
case "open_article": return say(await api().open_article(target.dataset.doi));
|
|
522
549
|
case "group": return toggleGroup(Number(target.dataset.group));
|
|
523
550
|
case "show_browser": {
|
|
524
551
|
try { await inputActivation; }
|
|
@@ -23,7 +23,7 @@ from urllib.parse import urlsplit
|
|
|
23
23
|
from uuid import UUID, uuid4
|
|
24
24
|
from weakref import WeakKeyDictionary
|
|
25
25
|
|
|
26
|
-
from .watchdog import BrowserUnresponsive, operation_remaining
|
|
26
|
+
from .watchdog import BrowserUnresponsive, CallAbandoned, call_limit, operation_remaining
|
|
27
27
|
from ..entitlements import UserMarkedNoEntitlement
|
|
28
28
|
|
|
29
29
|
_OBSERVERS = WeakKeyDictionary()
|
|
@@ -33,6 +33,7 @@ OBSERVE_INTERVAL_SEC = 4 # between unforced frames (waits refresh at most this
|
|
|
33
33
|
MAX_KEPT_FRAMES = 5 # earlier page states kept per download, besides each tab's newest frame
|
|
34
34
|
JPEG_QUALITY = 60
|
|
35
35
|
SCREENSHOT_TIMEOUT_MS = 1500
|
|
36
|
+
CAPTURE_BACKOFF_SEC = 30 # after a frame that never came, for the same page state
|
|
36
37
|
|
|
37
38
|
|
|
38
39
|
def _atomic(path: Path, data: bytes) -> None:
|
|
@@ -63,6 +64,7 @@ class BrowserPreview:
|
|
|
63
64
|
self.observing = False
|
|
64
65
|
self.paused = 0
|
|
65
66
|
self._cdp = WeakKeyDictionary()
|
|
67
|
+
self._no_frame = WeakKeyDictionary() # page -> (url, until): its capture timed out
|
|
66
68
|
self._navigation_listeners = {}
|
|
67
69
|
context.on('close', self.close)
|
|
68
70
|
self._write([])
|
|
@@ -145,8 +147,19 @@ class BrowserPreview:
|
|
|
145
147
|
session = False
|
|
146
148
|
self._cdp[page] = session
|
|
147
149
|
if session:
|
|
148
|
-
|
|
149
|
-
|
|
150
|
+
url, until = self._no_frame.get(page, ("", 0.0))
|
|
151
|
+
if url == page.url and time.monotonic() < until:
|
|
152
|
+
raise TimeoutError("no frame from this page yet")
|
|
153
|
+
# The capture waits for a drawn frame and has no timeout of its own:
|
|
154
|
+
# Thieme's article tab after the school login held it for 90 s, and the
|
|
155
|
+
# watchdog ended the article as browser_unresponsive (2026-11-08).
|
|
156
|
+
try:
|
|
157
|
+
with call_limit(SCREENSHOT_TIMEOUT_MS / 1000):
|
|
158
|
+
data = session.send("Page.captureScreenshot",
|
|
159
|
+
{"format": "jpeg", "quality": JPEG_QUALITY, "fromSurface": True})
|
|
160
|
+
except CallAbandoned:
|
|
161
|
+
self._no_frame[page] = (page.url, time.monotonic() + CAPTURE_BACKOFF_SEC)
|
|
162
|
+
raise
|
|
150
163
|
return base64.b64decode(data["data"])
|
|
151
164
|
return page.screenshot(timeout=SCREENSHOT_TIMEOUT_MS, full_page=False, type="jpeg", quality=JPEG_QUALITY)
|
|
152
165
|
|
|
@@ -33,8 +33,10 @@ log = logging.getLogger(__name__)
|
|
|
33
33
|
# timeout); waits for the user are made of short calls.
|
|
34
34
|
LIMIT_SEC = 90
|
|
35
35
|
|
|
36
|
-
_inflight: dict[int, tuple[float, str, list[str], Any, Any]] = {}
|
|
36
|
+
_inflight: dict[int, tuple[float, str, list[str], Any, Any, Any]] = {}
|
|
37
37
|
_call_deadlines: dict[int, tuple[float, str]] = {}
|
|
38
|
+
# Calls dropped by :func:`abandon`: they end in :class:`CallAbandoned`.
|
|
39
|
+
_abandoned: set[int] = set()
|
|
38
40
|
_local = threading.local()
|
|
39
41
|
_installed = False
|
|
40
42
|
# A browser call longer than this is reported to ``on_slow_call(name, seconds,
|
|
@@ -70,6 +72,65 @@ class BrowserBudgetExhausted(BrowserOperationTimeout):
|
|
|
70
72
|
"""No time remained to send another call; the driver did not stall."""
|
|
71
73
|
|
|
72
74
|
|
|
75
|
+
class CallAbandoned(Exception):
|
|
76
|
+
"""A call whose answer is no longer wanted (:func:`abandon`)."""
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def _greenlet() -> Any:
|
|
80
|
+
"""The greenlet making a call: the driver runs each event handler in its own."""
|
|
81
|
+
try:
|
|
82
|
+
from greenlet import getcurrent
|
|
83
|
+
except ImportError:
|
|
84
|
+
return None
|
|
85
|
+
return getcurrent()
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
@contextmanager
|
|
89
|
+
def owned_by(owners: set):
|
|
90
|
+
"""Mark the calls this greenlet makes meanwhile as ``owners``' (see :func:`abandon`)."""
|
|
91
|
+
me = _greenlet()
|
|
92
|
+
owners.add(me)
|
|
93
|
+
try:
|
|
94
|
+
yield
|
|
95
|
+
finally:
|
|
96
|
+
owners.discard(me)
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def abandon(owners: set) -> int:
|
|
100
|
+
"""Cancel the running calls of these greenlets without ending the browser: their
|
|
101
|
+
answer is no longer wanted. A response read in an event handler that never
|
|
102
|
+
returned was otherwise timed out 90 s later, and the article running then
|
|
103
|
+
(JAMA after AIAA's blocked PDF, 2026-11-08) ended as browser_unresponsive.
|
|
104
|
+
Returns how many were cancelled."""
|
|
105
|
+
count = 0
|
|
106
|
+
for key, entry in list(_inflight.items()):
|
|
107
|
+
if entry[5] is None or entry[5] not in owners:
|
|
108
|
+
continue
|
|
109
|
+
_abandoned.add(key)
|
|
110
|
+
_inflight.pop(key, None)
|
|
111
|
+
_call_deadlines.pop(key, None)
|
|
112
|
+
loop, coro = entry[3], entry[4]
|
|
113
|
+
if loop is not None and not loop.is_closed():
|
|
114
|
+
loop.call_soon_threadsafe(_cancel, coro)
|
|
115
|
+
count += 1
|
|
116
|
+
return count
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
@contextmanager
|
|
120
|
+
def call_limit(seconds: float):
|
|
121
|
+
"""Abandon this greenlet's calls still running after ``seconds`` (:func:`abandon`):
|
|
122
|
+
for calls whose answer is optional, such as a preview frame."""
|
|
123
|
+
owners: set = set()
|
|
124
|
+
timer = threading.Timer(seconds, abandon, args=(owners,))
|
|
125
|
+
timer.daemon = True
|
|
126
|
+
with owned_by(owners):
|
|
127
|
+
timer.start()
|
|
128
|
+
try:
|
|
129
|
+
yield
|
|
130
|
+
finally:
|
|
131
|
+
timer.cancel()
|
|
132
|
+
|
|
133
|
+
|
|
73
134
|
@contextmanager
|
|
74
135
|
def operation(seconds: float, label: str):
|
|
75
136
|
"""One monotonic deadline shared by all calls and retries in this scope."""
|
|
@@ -148,12 +209,14 @@ def install(limit_sec: float = LIMIT_SEC) -> None:
|
|
|
148
209
|
raise BrowserBudgetExhausted(f"{label} exhausted its page budget before {name}")
|
|
149
210
|
_call_deadlines[key] = (deadline, label)
|
|
150
211
|
_inflight[key] = (started, name, traceback.format_stack(limit=8)[:-1],
|
|
151
|
-
getattr(self, "_loop", None), coro)
|
|
212
|
+
getattr(self, "_loop", None), coro, _greenlet())
|
|
152
213
|
ended = "returned"
|
|
153
214
|
try:
|
|
154
215
|
return original(self, coro)
|
|
155
216
|
except asyncio.CancelledError:
|
|
156
217
|
ended = "cancelled"
|
|
218
|
+
if key in _abandoned:
|
|
219
|
+
raise CallAbandoned(name) from None
|
|
157
220
|
if fired is not None:
|
|
158
221
|
raise _timeout_error() from None
|
|
159
222
|
if interrupted is not None:
|
|
@@ -165,6 +228,7 @@ def install(limit_sec: float = LIMIT_SEC) -> None:
|
|
|
165
228
|
finally:
|
|
166
229
|
_inflight.pop(key, None)
|
|
167
230
|
_call_deadlines.pop(key, None)
|
|
231
|
+
_abandoned.discard(key)
|
|
168
232
|
elapsed = time.monotonic() - started
|
|
169
233
|
_period["calls"] += 1
|
|
170
234
|
_period["seconds"] += elapsed
|
|
@@ -209,7 +273,7 @@ def check(limit_sec: float) -> bool:
|
|
|
209
273
|
if not overdue:
|
|
210
274
|
return False
|
|
211
275
|
key, entry = min(overdue, key=lambda pair: pair[1][0])
|
|
212
|
-
started, name, stack, loop, coro = entry
|
|
276
|
+
started, name, stack, loop, coro, _ = entry
|
|
213
277
|
fired = {"call": name, "seconds": int(now - started)}
|
|
214
278
|
deadline = deadlines.get(key)
|
|
215
279
|
if deadline and deadline[0] <= now and deadline[0] <= started + limit_sec:
|
|
@@ -230,7 +294,7 @@ def interrupt(exc: BaseException) -> None:
|
|
|
230
294
|
call raise ``exc`` until :func:`clear_interrupt`."""
|
|
231
295
|
global interrupted
|
|
232
296
|
interrupted = exc
|
|
233
|
-
for _, _, _, loop, coro in list(_inflight.values()):
|
|
297
|
+
for _, _, _, loop, coro, _ in list(_inflight.values()):
|
|
234
298
|
if loop is not None and not loop.is_closed():
|
|
235
299
|
loop.call_soon_threadsafe(_cancel, coro)
|
|
236
300
|
|
|
@@ -41,11 +41,16 @@ class ScreenArea:
|
|
|
41
41
|
work: Rect
|
|
42
42
|
|
|
43
43
|
|
|
44
|
+
def _overlap(a: Rect, b: Rect) -> float:
|
|
45
|
+
return (max(0, min(a.right, b.right) - max(a.x, b.x))
|
|
46
|
+
* max(0, min(a.bottom, b.bottom) - max(a.y, b.y)))
|
|
47
|
+
|
|
48
|
+
|
|
44
49
|
def screen_for(rect: Rect, screens: list[ScreenArea]) -> ScreenArea:
|
|
45
|
-
"""
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
50
|
+
"""The display holding most of the rectangle, otherwise the nearest (unplugged display)."""
|
|
51
|
+
best = max(screens, key=lambda s: _overlap(rect, s.bounds))
|
|
52
|
+
if _overlap(rect, best.bounds) > 0:
|
|
53
|
+
return best
|
|
49
54
|
x, y = rect.x + rect.width / 2, rect.y + rect.height / 2
|
|
50
55
|
return min(screens, key=lambda s: max(s.bounds.x - x, 0, x - s.bounds.right) ** 2
|
|
51
56
|
+ max(s.bounds.y - y, 0, y - s.bounds.bottom) ** 2)
|
|
@@ -57,9 +62,16 @@ def fit_rect(rect: Rect, work: Rect) -> Rect:
|
|
|
57
62
|
max(work.y, min(rect.y, work.bottom - rect.height)), rect.width, rect.height)
|
|
58
63
|
|
|
59
64
|
|
|
60
|
-
def
|
|
61
|
-
|
|
62
|
-
|
|
65
|
+
def pill_anchor(pill: Rect, work: Rect) -> tuple[str, str]:
|
|
66
|
+
"""Grow away from the nearer screen edges, keeping the pill's sides there fixed."""
|
|
67
|
+
return ("down" if pill.y + pill.height / 2 < work.y + work.height / 2 else "up",
|
|
68
|
+
"right" if pill.x + pill.width / 2 < work.x + work.width / 2 else "left")
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def direction_for(pill: Rect, work: Rect, height: float) -> tuple[str, str]:
|
|
72
|
+
"""Open down unless the card does not fit below; sideways away from the nearer edge."""
|
|
73
|
+
below, above = work.bottom - pill.y, pill.bottom - work.y
|
|
74
|
+
return "down" if below >= height or below >= above else "up", pill_anchor(pill, work)[1]
|
|
63
75
|
|
|
64
76
|
|
|
65
77
|
def _edge(start: float, end: float, low: float, high: float) -> int:
|
|
@@ -80,6 +92,7 @@ class Placement:
|
|
|
80
92
|
self.direction = ("down" if corner == "top" else "up", "left")
|
|
81
93
|
self.edges = (0, 0)
|
|
82
94
|
self.expanded = False
|
|
95
|
+
self._direction_fixed = False
|
|
83
96
|
self.scale = 1.0
|
|
84
97
|
self._saved: dict = {}
|
|
85
98
|
try:
|
|
@@ -138,7 +151,7 @@ class Placement:
|
|
|
138
151
|
self.home = fit_rect(Rect(b.right - EDGE - w,
|
|
139
152
|
b.y + TOP_GAP if self.corner == "top" else b.bottom - BOTTOM_GAP - h,
|
|
140
153
|
w, h), self.screen.work)
|
|
141
|
-
self.direction = self._direction(self.home)
|
|
154
|
+
self.direction = self._direction(pill_anchor(self.home, self.screen.work))
|
|
142
155
|
return round(self.home.x), round(self.home.y)
|
|
143
156
|
|
|
144
157
|
def rescale(self, scale: float) -> None:
|
|
@@ -163,7 +176,8 @@ class Placement:
|
|
|
163
176
|
self.home = actual
|
|
164
177
|
self.screen = screen_for(self.home, screens)
|
|
165
178
|
if not self.expanded:
|
|
166
|
-
self.direction = self._direction(self.home)
|
|
179
|
+
self.direction = self._direction(pill_anchor(self.home, self.screen.work))
|
|
180
|
+
self._direction_fixed = False
|
|
167
181
|
if expanded:
|
|
168
182
|
self.expanded = True
|
|
169
183
|
|
|
@@ -171,14 +185,21 @@ class Placement:
|
|
|
171
185
|
assert self.home is not None and self.screen is not None
|
|
172
186
|
home, work = self.home, self.screen.work
|
|
173
187
|
width, height = min(width, int(work.width)), min(height, int(work.height))
|
|
174
|
-
if expanded
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
188
|
+
if expanded:
|
|
189
|
+
# Chosen once per expansion: taller panels such as settings are
|
|
190
|
+
# clamped to the work area instead of flipping the card.
|
|
191
|
+
if not self._direction_fixed:
|
|
192
|
+
self.direction = self._direction(direction_for(home, work, height))
|
|
193
|
+
self._direction_fixed = True
|
|
194
|
+
anchor, (vertical, horizontal) = self._dragged_card or home, self.direction
|
|
195
|
+
elif self.expanded:
|
|
196
|
+
# Back into the corner the card grew from, also when the status
|
|
197
|
+
# changed the pill's width while it was open.
|
|
198
|
+
anchor, (vertical, horizontal) = home, self.direction
|
|
179
199
|
else:
|
|
180
|
-
|
|
181
|
-
|
|
200
|
+
anchor, (vertical, horizontal) = home, self._direction(pill_anchor(home, work))
|
|
201
|
+
x = anchor.right - width if horizontal == "left" else anchor.x
|
|
202
|
+
y = anchor.bottom - height if vertical == "up" else anchor.y
|
|
182
203
|
return self._fit(Rect(x, y, width, height))
|
|
183
204
|
|
|
184
205
|
def finish(self, expanded: bool, actual: Rect) -> None:
|
|
@@ -195,8 +216,9 @@ class Placement:
|
|
|
195
216
|
y = work.y if vertical < 0 else work.bottom - rect.height if vertical > 0 else rect.y
|
|
196
217
|
return fit_rect(Rect(x, y, rect.width, rect.height), work)
|
|
197
218
|
|
|
198
|
-
def _direction(self,
|
|
199
|
-
|
|
219
|
+
def _direction(self, free: tuple[str, str]) -> tuple[str, str]:
|
|
220
|
+
"""A docked edge decides its axis; the other axis keeps the free choice."""
|
|
221
|
+
vertical, horizontal = free
|
|
200
222
|
x, y = self.edges
|
|
201
223
|
return ("down" if y < 0 else "up" if y > 0 else vertical,
|
|
202
224
|
"right" if x < 0 else "left" if x > 0 else horizontal)
|
|
@@ -227,29 +249,27 @@ class Placement:
|
|
|
227
249
|
|
|
228
250
|
def dragged(self, after: Rect, screens: list[ScreenArea],
|
|
229
251
|
pointer: tuple[float, float] | None = None) -> Rect:
|
|
230
|
-
# At a display seam the
|
|
231
|
-
#
|
|
232
|
-
self.screen =
|
|
233
|
-
if self.screen is None:
|
|
234
|
-
self.screen = screen_for(after, screens)
|
|
252
|
+
# At a display seam the pointer may already be on the next display;
|
|
253
|
+
# the window stays on the one that holds most of it.
|
|
254
|
+
self.screen = screen_for(after, screens)
|
|
235
255
|
work = self.screen.work
|
|
236
256
|
point = pointer if pointer and self.screen.bounds.contains(*pointer) else None
|
|
237
257
|
self.edges = self._drop_edges(after, work, point)
|
|
238
258
|
after = self._fit(Rect(after.x, after.y, min(after.width, work.width), min(after.height, work.height)))
|
|
239
|
-
self.direction = self._direction(after)
|
|
240
259
|
if self.home is None or not self.expanded:
|
|
241
260
|
self.home = after
|
|
261
|
+
self.direction = self._direction(pill_anchor(after, work))
|
|
242
262
|
else:
|
|
263
|
+
# The pill goes to the card's top corner on the side nearer the
|
|
264
|
+
# screen edge (bottom corner when docked there), so opening it
|
|
265
|
+
# again puts the card back where it was dropped.
|
|
243
266
|
self._dragged_card = after
|
|
267
|
+
self.direction = self._direction(("down", pill_anchor(after, work)[1]))
|
|
268
|
+
self._direction_fixed = True
|
|
244
269
|
vertical, horizontal = self.direction
|
|
245
270
|
w, h = self.home.width, self.home.height
|
|
246
|
-
if
|
|
247
|
-
|
|
248
|
-
# much smaller pill lands along the side.
|
|
249
|
-
self.home = Rect(point[0] - w / 2, point[1] - h / 2, w, h)
|
|
250
|
-
else:
|
|
251
|
-
self.home = Rect(after.right - w if horizontal == "left" else after.x,
|
|
252
|
-
after.bottom - h if vertical == "up" else after.y, w, h)
|
|
271
|
+
self.home = Rect(after.right - w if horizontal == "left" else after.x,
|
|
272
|
+
after.bottom - h if vertical == "up" else after.y, w, h)
|
|
253
273
|
self.home = self._fit(self.home)
|
|
254
274
|
self.save()
|
|
255
275
|
return after
|
|
@@ -26,6 +26,7 @@ challenge_or_viewer_timeout ip_blocked access_blocked pdf_not_captured
|
|
|
26
26
|
pdf_identity_mismatch pdf_identity_unverified invalid_pdf
|
|
27
27
|
profile_busy cancelled interrupted skipped_cached_attempt target_verified_reached navigation_error
|
|
28
28
|
unsupported_platform unsupported_publisher user_skipped user_marked_no_entitlement pdf_wrong_article
|
|
29
|
+
article_not_yet_published
|
|
29
30
|
institution_federation_unavailable browser_unresponsive browser_operation_timeout login_not_reached idp_no_return_to_publisher
|
|
30
31
|
generic_institution_entry_missing
|
|
31
32
|
""".split())
|
|
@@ -43,7 +44,7 @@ challenge_or_viewer_timeout challenge_resolved challenge_wait cookie_banner_dism
|
|
|
43
44
|
advertisement_closed pdf_step_article_page institution_choice_returned_article institution_choice_stopped
|
|
44
45
|
cookie_inject_failed download_capture_error elsevier_institution_entry_error
|
|
45
46
|
institution_continue institution_continue_error institution_entry_unresolved institution_federation_selected
|
|
46
|
-
institution_search_error institution_search_retyped institution_session_other idp_confirmation_required
|
|
47
|
+
institution_search_error institution_search_retyped institution_session_other idp_confirmation_accepted idp_confirmation_required
|
|
47
48
|
institution_required institution_search institution_search_submitted
|
|
48
49
|
institution_select_error institution_selected institution_selection_required
|
|
49
50
|
institution_session_return_article institution_session_return_error
|
|
@@ -56,6 +57,7 @@ pdf_capture_started pdf_navigation_error pdf_saved pdf_state_candidate post_logi
|
|
|
56
57
|
post_login_hold_article_access post_login_hold_auth_wall post_login_hold_login_page
|
|
57
58
|
post_run_hold publisher_access_blocked publisher_content_error publisher_unreachable publisher_login_menu_opened
|
|
58
59
|
publisher_pdf_link_unverified publisher_session_save_failed publisher_session_saved
|
|
60
|
+
publisher_terms_accepted
|
|
59
61
|
record_article_return record_article_return_error seamlessaccess_chooser_opened
|
|
60
62
|
shared_cookies_exported shared_cookies_loaded sso_entry_clicked sso_entry_error sso_start
|
|
61
63
|
access_unknown_pdf_first access_unknown_pdf_failed pdf_step_login_required login_round_trip_returned
|
|
@@ -80,6 +80,17 @@ def registrable_domain(host: str) -> str:
|
|
|
80
80
|
_ABSTRACT_ONLY = re.compile(r"/article-abstract/|/abs/pii/", re.I)
|
|
81
81
|
|
|
82
82
|
|
|
83
|
+
# The publisher shows the article as accepted, its full text not online yet:
|
|
84
|
+
# Optica's page "This paper has been accepted for publication. The DOI ... has been
|
|
85
|
+
# registered ... will redirect to the published article when available" (2026-11-08).
|
|
86
|
+
_NOT_YET_PUBLISHED = (("accepted for publication", "redirect to the published article when available"),)
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def not_yet_published(text: str) -> bool:
|
|
90
|
+
flat = " ".join(text.lower().split())
|
|
91
|
+
return any(all(marker in flat for marker in markers) for markers in _NOT_YET_PUBLISHED)
|
|
92
|
+
|
|
93
|
+
|
|
83
94
|
def abstract_only(url: str) -> bool:
|
|
84
95
|
return bool(_ABSTRACT_ONLY.search(urlparse(url or "").path))
|
|
85
96
|
|
|
@@ -62,6 +62,7 @@ from .batch_common import (
|
|
|
62
62
|
PublisherAccessBlocked,
|
|
63
63
|
PublisherContentError,
|
|
64
64
|
PublisherPlatformUnsupported,
|
|
65
|
+
ArticleNotYetPublished,
|
|
65
66
|
RETRYABLE_REASONS,
|
|
66
67
|
_ACCESS_GATE_JS,
|
|
67
68
|
_IN_REFERENCES_JS,
|
|
@@ -213,7 +214,12 @@ class PublisherBatchDownloader(
|
|
|
213
214
|
own_page = [final_url] if final_url and self.adapter.is_article_page_url(final_url) else []
|
|
214
215
|
candidates = self.adapter.supplements_page_urls(doi) or [self._article_url(doi)]
|
|
215
216
|
incomplete = ""
|
|
216
|
-
|
|
217
|
+
listed = list(getattr(result, "_listed_supplements", None) or [])
|
|
218
|
+
if listed:
|
|
219
|
+
# Read on the article page before its PDF: no second load.
|
|
220
|
+
links = listed
|
|
221
|
+
self._event(result, "supplements_listed_on_article", str(len(links)))
|
|
222
|
+
for url in ([] if listed else dict.fromkeys(own_page + candidates)):
|
|
217
223
|
open_page(page, url, timeout_ms=60_000)
|
|
218
224
|
if self._challenge_shell(page) or self._is_challenge_page(page):
|
|
219
225
|
if not self._wait_for_challenge(page, result):
|
|
@@ -289,7 +295,10 @@ class PublisherBatchDownloader(
|
|
|
289
295
|
if not _is_browser_error(exc):
|
|
290
296
|
raise
|
|
291
297
|
self._event(result, "supplements_failed", f"{type(exc).__name__}: {str(exc)[:160]}")
|
|
292
|
-
|
|
298
|
+
# The site did not answer, not the error's class name ("Error": pubs.acs.org
|
|
299
|
+
# closed the connection on every try, Windows 2026-11-07).
|
|
300
|
+
reason = "publisher_unreachable" if _is_network_failure(exc) else type(exc).__name__
|
|
301
|
+
return [{"status": "failed", "reason": reason, "url": "", "label": ""}]
|
|
293
302
|
finally:
|
|
294
303
|
user_watch.set()
|
|
295
304
|
watchdog.clear_interrupt()
|
|
@@ -311,7 +320,10 @@ class PublisherBatchDownloader(
|
|
|
311
320
|
own = self.adapter.supplement_links(page, doi)
|
|
312
321
|
external = external_links(page, doi)
|
|
313
322
|
if own is None and external is None:
|
|
314
|
-
|
|
323
|
+
from ..adapters.platforms.silverchair import declares_no_supplements
|
|
324
|
+
|
|
325
|
+
# No rule found files, but the page itself may say there are none.
|
|
326
|
+
return [] if declares_no_supplements(page, doi) else None
|
|
315
327
|
return list(dict.fromkeys([*(own or []), *(external or [])]))
|
|
316
328
|
except Exception as exc:
|
|
317
329
|
if (attempt == 2 or not _is_browser_error(exc)
|
|
@@ -610,6 +622,12 @@ class PublisherBatchDownloader(
|
|
|
610
622
|
self._event(result, "publisher_access_blocked")
|
|
611
623
|
self._write_diagnostic(page, result, run_dir)
|
|
612
624
|
return result
|
|
625
|
+
except ArticleNotYetPublished as page_url:
|
|
626
|
+
result.reason = result.state = "article_not_yet_published"
|
|
627
|
+
self._event(result, "article_not_yet_published", str(page_url))
|
|
628
|
+
progress_reporter.update(phase="出版社尚未发布这篇论文的全文,当前路径已停止")
|
|
629
|
+
self._write_diagnostic(page, result, run_dir)
|
|
630
|
+
return result
|
|
613
631
|
except PublisherPlatformUnsupported as platform:
|
|
614
632
|
result.reason = result.state = "unsupported_platform"
|
|
615
633
|
self._event(result, "unsupported_platform", str(platform))
|
|
@@ -16,6 +16,7 @@ from .batch_common import (
|
|
|
16
16
|
settle,
|
|
17
17
|
DownloadResult,
|
|
18
18
|
PublisherAccessBlocked,
|
|
19
|
+
ArticleNotYetPublished,
|
|
19
20
|
PublisherContentError,
|
|
20
21
|
PublisherPlatformUnsupported,
|
|
21
22
|
_ACCESS_GATE_JS,
|
|
@@ -211,6 +212,8 @@ class AccessMixin:
|
|
|
211
212
|
if self._is_auth_page(url):
|
|
212
213
|
return access_rules.OUT, "login_page", url[:160]
|
|
213
214
|
snap = snapshot or self._access_snapshot(page)
|
|
215
|
+
if access_rules.not_yet_published(str(getattr(snap, "text", "") or "")):
|
|
216
|
+
raise ArticleNotYetPublished(url[:160])
|
|
214
217
|
if self._institution_session(page, snap) == "ours":
|
|
215
218
|
names = access_rules.session_names(snap.lines)
|
|
216
219
|
label = next((str(l) for l in snap.probe.get("labels") or () if not access_rules.is_generic_label(str(l))), "")
|