papersearch 0.6.6 → 0.6.8
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/dist/capabilities/pdf-discovery/batch.d.ts +6 -0
- package/dist/capabilities/pdf-discovery/batch.d.ts.map +1 -1
- package/dist/capabilities/pdf-discovery/batch.js +210 -18
- package/dist/capabilities/pdf-discovery/batch.js.map +1 -1
- package/dist/capabilities/pdf-discovery/batchSummary.d.ts.map +1 -1
- package/dist/capabilities/pdf-discovery/batchSummary.js +9 -1
- package/dist/capabilities/pdf-discovery/batchSummary.js.map +1 -1
- package/dist/capabilities/pdf-discovery/handler.d.ts +3 -1
- package/dist/capabilities/pdf-discovery/handler.d.ts.map +1 -1
- package/dist/capabilities/pdf-discovery/handler.js +27 -1
- package/dist/capabilities/pdf-discovery/handler.js.map +1 -1
- package/dist/capabilities/pdf-discovery/outputLayout.d.ts +8 -1
- package/dist/capabilities/pdf-discovery/outputLayout.d.ts.map +1 -1
- package/dist/capabilities/pdf-discovery/outputLayout.js +76 -6
- package/dist/capabilities/pdf-discovery/outputLayout.js.map +1 -1
- package/dist/capabilities/pdf-discovery/resume.d.ts +22 -0
- package/dist/capabilities/pdf-discovery/resume.d.ts.map +1 -0
- package/dist/capabilities/pdf-discovery/resume.js +114 -0
- package/dist/capabilities/pdf-discovery/resume.js.map +1 -0
- package/dist/capabilities/pdf-discovery/schemas.d.ts +34 -3
- package/dist/capabilities/pdf-discovery/schemas.d.ts.map +1 -1
- package/dist/capabilities/pdf-discovery/schemas.js +6 -3
- package/dist/capabilities/pdf-discovery/schemas.js.map +1 -1
- package/dist/capabilities/pdf-discovery/school/SchoolAttempt.d.ts.map +1 -1
- package/dist/capabilities/pdf-discovery/school/SchoolAttempt.js +4 -0
- package/dist/capabilities/pdf-discovery/school/SchoolAttempt.js.map +1 -1
- package/dist/capabilities/pdf-discovery/school/SchoolMcpClient.d.ts +15 -1
- package/dist/capabilities/pdf-discovery/school/SchoolMcpClient.d.ts.map +1 -1
- package/dist/capabilities/pdf-discovery/school/SchoolMcpClient.js +42 -7
- package/dist/capabilities/pdf-discovery/school/SchoolMcpClient.js.map +1 -1
- package/dist/capabilities/pdf-discovery/school/SchoolReadiness.d.ts +4 -0
- package/dist/capabilities/pdf-discovery/school/SchoolReadiness.d.ts.map +1 -1
- package/dist/capabilities/pdf-discovery/school/SchoolReadiness.js +4 -0
- package/dist/capabilities/pdf-discovery/school/SchoolReadiness.js.map +1 -1
- package/dist/capabilities/pdf-discovery/school/SchoolResultNormalizer.js +7 -1
- package/dist/capabilities/pdf-discovery/school/SchoolResultNormalizer.js.map +1 -1
- package/dist/capabilities/pdf-discovery/school/index.d.ts +2 -2
- package/dist/capabilities/pdf-discovery/school/index.d.ts.map +1 -1
- package/dist/capabilities/pdf-discovery/school/index.js +1 -1
- package/dist/capabilities/pdf-discovery/school/index.js.map +1 -1
- package/dist/capabilities/pdf-discovery/school/types.d.ts +35 -0
- package/dist/capabilities/pdf-discovery/school/types.d.ts.map +1 -1
- package/dist/capabilities/pdf-discovery/tools.d.ts +8 -4
- package/dist/capabilities/pdf-discovery/tools.d.ts.map +1 -1
- package/dist/capabilities/pdf-discovery/tools.js +5 -3
- package/dist/capabilities/pdf-discovery/tools.js.map +1 -1
- package/dist/infrastructure/runlog/RunLedger.d.ts +4 -0
- package/dist/infrastructure/runlog/RunLedger.d.ts.map +1 -1
- package/dist/infrastructure/runlog/RunLedger.js.map +1 -1
- package/dist/infrastructure/runlog/failureClass.d.ts.map +1 -1
- package/dist/infrastructure/runlog/failureClass.js +5 -0
- package/dist/infrastructure/runlog/failureClass.js.map +1 -1
- package/dist/management/failures/exportReport.d.ts.map +1 -1
- package/dist/management/failures/exportReport.js +3 -1
- package/dist/management/failures/exportReport.js.map +1 -1
- package/dist/management/school/autoUpdate.d.ts.map +1 -1
- package/dist/management/school/autoUpdate.js +8 -0
- package/dist/management/school/autoUpdate.js.map +1 -1
- package/dist/management/school/cliProgress.d.ts.map +1 -1
- package/dist/management/school/cliProgress.js +2 -0
- package/dist/management/school/cliProgress.js.map +1 -1
- package/dist/management/school/host.d.ts.map +1 -1
- package/dist/management/school/host.js +3 -1
- package/dist/management/school/host.js.map +1 -1
- package/dist/management/school/settingsWindow.d.ts +1 -1
- package/dist/management/school/settingsWindow.d.ts.map +1 -1
- package/dist/management/school/settingsWindow.js +4 -2
- package/dist/management/school/settingsWindow.js.map +1 -1
- package/dist/platforms/CrossrefSearcher.d.ts +7 -0
- package/dist/platforms/CrossrefSearcher.d.ts.map +1 -1
- package/dist/platforms/CrossrefSearcher.js +14 -0
- package/dist/platforms/CrossrefSearcher.js.map +1 -1
- package/dist/platforms/PubMedSearcher.d.ts +5 -0
- package/dist/platforms/PubMedSearcher.d.ts.map +1 -1
- package/dist/platforms/PubMedSearcher.js +62 -1
- package/dist/platforms/PubMedSearcher.js.map +1 -1
- package/package.json +1 -1
- package/school/README.md +2 -2
- package/school/paper_search_school/adapters/base.py +5 -0
- package/school/paper_search_school/adapters/platforms/atypon/__init__.py +7 -0
- package/school/paper_search_school/assets/capsule.html +84 -12
- package/school/paper_search_school/assets/capsule_en.json +35 -6
- package/school/paper_search_school/blocked_journals.py +39 -0
- package/school/paper_search_school/browser/foreground.py +11 -0
- package/school/paper_search_school/cli.py +15 -0
- package/school/paper_search_school/download_diagnostics.py +1 -1
- package/school/paper_search_school/engine/batch.py +6 -1
- package/school/paper_search_school/engine/batch_access.py +10 -0
- package/school/paper_search_school/engine/batch_capture.py +10 -2
- package/school/paper_search_school/engine/batch_institution.py +20 -3
- package/school/paper_search_school/engine/batch_login.py +16 -3
- package/school/paper_search_school/engine/batch_user.py +12 -0
- package/school/paper_search_school/engine/bridge.py +46 -5
- package/school/paper_search_school/entitlements.py +27 -0
- package/school/paper_search_school/orchestrator.py +3 -0
- package/school/paper_search_school/progress_capsule.py +36 -12
- package/school/paper_search_school/progress_reporter.py +29 -2
- package/school/paper_search_school/progress_view.py +33 -7
- package/school/paper_search_school/server.py +15 -3
- package/skills/paper-search/SKILL.md +2 -2
- package/skills/paper-search/references/browser-download.md +15 -4
- package/skills/paper-search/references/cli-contract.md +1 -1
- package/skills/paper-search/references/publisher-support.md +1 -1
|
@@ -8,6 +8,9 @@ and not another, and its journals can sit on other sites (the user, 2026-11-02;
|
|
|
8
8
|
BMJ's Cloudflare page came from the exit network). The file, not the process,
|
|
9
9
|
keeps it: PaperSearch starts the backend anew for every article. Entries older
|
|
10
10
|
than ``KEEP_SEC`` are dropped when the file is read, so a later batch tries again.
|
|
11
|
+
Every ``RECHECK_SEC`` one article tries the site again (``skip_for``): the user may
|
|
12
|
+
have moved to another network (Windows, 2026-11-16); its site not blocking it any
|
|
13
|
+
more ends the journal's entry (``recheck_ended``).
|
|
11
14
|
"""
|
|
12
15
|
from __future__ import annotations
|
|
13
16
|
|
|
@@ -18,6 +21,7 @@ from typing import Any
|
|
|
18
21
|
from .entitlements import _data_dir, _read_json, _write_json
|
|
19
22
|
|
|
20
23
|
KEEP_SEC = 30 * 60
|
|
24
|
+
RECHECK_SEC = 5 * 60 # the user, 2026-11-16 (two minutes first)
|
|
21
25
|
|
|
22
26
|
|
|
23
27
|
def ledger_path() -> Path:
|
|
@@ -51,6 +55,41 @@ def blocked_by(identity: dict[str, Any], now: float | None = None) -> str:
|
|
|
51
55
|
return str(entry.get("doi") or "") if entry else ""
|
|
52
56
|
|
|
53
57
|
|
|
58
|
+
def skip_for(identity: dict[str, Any], doi: str, now: float | None = None) -> str:
|
|
59
|
+
"""The DOI whose page blocked this journal's site, when this article is answered at
|
|
60
|
+
once; "" when it is tried: the journal is not blocked, or this article re-checks the
|
|
61
|
+
site, once every ``RECHECK_SEC`` (``recheck_ended`` says how that went)."""
|
|
62
|
+
key = journal_key(identity)
|
|
63
|
+
if not key:
|
|
64
|
+
return ""
|
|
65
|
+
now = time.time() if now is None else now
|
|
66
|
+
data = _recent(now)
|
|
67
|
+
entry = data.get(key)
|
|
68
|
+
if not entry:
|
|
69
|
+
return ""
|
|
70
|
+
if now - max(float(entry["at"]), float(entry.get("checked_at") or 0)) >= RECHECK_SEC:
|
|
71
|
+
entry.update(checked_at=now, checked_by=(doi or "").lower())
|
|
72
|
+
_write_json(ledger_path(), data)
|
|
73
|
+
return ""
|
|
74
|
+
return str(entry.get("doi") or "")
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def recheck_ended(doi: str, blocked: bool) -> None:
|
|
78
|
+
"""The article that re-checked a blocked journal's site ended: unless that site
|
|
79
|
+
blocked it again (``remember`` has written so), the journal is open again."""
|
|
80
|
+
if blocked or not doi:
|
|
81
|
+
return
|
|
82
|
+
data = _read_json(ledger_path())
|
|
83
|
+
if not isinstance(data, dict):
|
|
84
|
+
return
|
|
85
|
+
keys = [key for key, entry in data.items()
|
|
86
|
+
if isinstance(entry, dict) and entry.get("checked_by") == doi.lower()]
|
|
87
|
+
if keys:
|
|
88
|
+
for key in keys:
|
|
89
|
+
del data[key]
|
|
90
|
+
_write_json(ledger_path(), data)
|
|
91
|
+
|
|
92
|
+
|
|
54
93
|
def remember(doi: str, identity: dict[str, Any], now: float | None = None) -> bool:
|
|
55
94
|
"""Write the journal as blocked; False when the journal is not known."""
|
|
56
95
|
key = journal_key(identity)
|
|
@@ -71,6 +71,17 @@ def _browser_pids(page: Any, config: dict) -> list[int]:
|
|
|
71
71
|
return found
|
|
72
72
|
|
|
73
73
|
|
|
74
|
+
def browser_pids(page: Any, config: dict) -> list[int]:
|
|
75
|
+
"""The processes of this page's browser (Windows), for the progress window to raise it."""
|
|
76
|
+
return _browser_pids(page, config)
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def activate_windows(pids: list[int]) -> bool:
|
|
80
|
+
"""Raise the browser of these processes from the progress window, which the user's
|
|
81
|
+
click has made the foreground window; False when none of them has a window."""
|
|
82
|
+
return _activate_windows(pids, lambda: "")
|
|
83
|
+
|
|
84
|
+
|
|
74
85
|
def _activate_windows(pids: list[int], window_title: Callable[[], str]) -> bool:
|
|
75
86
|
from ctypes import wintypes
|
|
76
87
|
|
|
@@ -20,6 +20,8 @@ Credentials are never passed through this CLI: logins happen in the browser wind
|
|
|
20
20
|
from __future__ import annotations
|
|
21
21
|
|
|
22
22
|
import argparse
|
|
23
|
+
import codecs
|
|
24
|
+
import io
|
|
23
25
|
import json
|
|
24
26
|
import os
|
|
25
27
|
import sys
|
|
@@ -538,7 +540,20 @@ def _cmd_settings(args: argparse.Namespace) -> int:
|
|
|
538
540
|
return 0
|
|
539
541
|
|
|
540
542
|
|
|
543
|
+
def _utf8_stdio() -> None:
|
|
544
|
+
"""Read and write the standard streams in UTF-8, as PaperSearch does at the
|
|
545
|
+
other end of the pipes. Piped, Python otherwise uses the system code page
|
|
546
|
+
(cp1252, GBK on Windows): a reply with a character it cannot encode stops
|
|
547
|
+
the command with UnicodeEncodeError, and Chinese it can encode reaches
|
|
548
|
+
PaperSearch garbled. Each stream keeps its error handler; a missing stream
|
|
549
|
+
(pythonw) or a replaced one is left alone."""
|
|
550
|
+
for stream in (sys.stdin, sys.stdout, sys.stderr):
|
|
551
|
+
if isinstance(stream, io.TextIOWrapper) and codecs.lookup(stream.encoding).name != "utf-8":
|
|
552
|
+
stream.reconfigure(encoding="utf-8", errors=stream.errors)
|
|
553
|
+
|
|
554
|
+
|
|
541
555
|
def main(argv: list[str] | None = None) -> int:
|
|
556
|
+
_utf8_stdio()
|
|
542
557
|
# Fingerprint generation needs no parallel linear algebra. On Windows its
|
|
543
558
|
# default OpenBLAS worker pool reserves hundreds of MiB in each backend.
|
|
544
559
|
# Limit only this owned CLI process; keep an explicit caller override.
|
|
@@ -26,7 +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
|
+
article_not_yet_published doi_not_resolved
|
|
30
30
|
institution_federation_unavailable browser_unresponsive browser_operation_timeout login_not_reached idp_no_return_to_publisher
|
|
31
31
|
generic_institution_entry_missing browser_closed
|
|
32
32
|
""".split())
|
|
@@ -495,6 +495,9 @@ class PublisherBatchDownloader(
|
|
|
495
495
|
if preparation is not None:
|
|
496
496
|
return preparation
|
|
497
497
|
if self.config.get("login_only"):
|
|
498
|
+
# The article's title in the window, as the PDF step shows it (a visit given
|
|
499
|
+
# no title showed only the DOI, 2026-11-16).
|
|
500
|
+
self._show_title(page)
|
|
498
501
|
# `login` (cli): the school's login and the article's access, then stop; no PDF.
|
|
499
502
|
result.signed_in = self._school_login_done()
|
|
500
503
|
result.state = "access_ready"
|
|
@@ -709,7 +712,9 @@ class PublisherBatchDownloader(
|
|
|
709
712
|
"browser_unresponsive", "browser_operation_timeout", "user_skipped", "batch_stopped", "user_marked_no_entitlement"}
|
|
710
713
|
if not stopped:
|
|
711
714
|
self._capture_reported_issues(page, result, act=False)
|
|
712
|
-
|
|
715
|
+
# A visit that stops at the article's access (`login`) took no PDF and went fine:
|
|
716
|
+
# not "这条路没走通,正在换路" (Windows, 2026-11-16).
|
|
717
|
+
if not result.ok and result.state != "access_ready":
|
|
713
718
|
progress_reporter.report_stage("route_failed", current=record.doi)
|
|
714
719
|
if not stopped:
|
|
715
720
|
self._hold_after_run(page, result)
|
|
@@ -25,6 +25,9 @@ from .batch_common import (
|
|
|
25
25
|
|
|
26
26
|
# The bare body a publisher's front proxy serves when the server behind it did
|
|
27
27
|
# not answer: Envoy, nginx and similar. Nothing else is on such a page.
|
|
28
|
+
# A publisher's own page for a blocked address: "Your IP has been blocked.", "Your IP
|
|
29
|
+
# 69.63.193.18 has been blocked." (Science, 2026-11-16), "your IP address … has been blocked".
|
|
30
|
+
_IP_BLOCKED = re.compile(r"\byour ip(?: address)?(?: [0-9a-f.:]+)? (?:has been|is) blocked\b")
|
|
28
31
|
_GATEWAY_ERROR_MARKERS = (
|
|
29
32
|
"upstream connect error or disconnect/reset before headers",
|
|
30
33
|
"502 bad gateway", "503 service unavailable", "503 service temporarily unavailable",
|
|
@@ -163,6 +166,13 @@ class AccessMixin:
|
|
|
163
166
|
return ("sorry, you have been blocked" in text
|
|
164
167
|
and "you are unable to access" in text)
|
|
165
168
|
|
|
169
|
+
@staticmethod
|
|
170
|
+
def _ip_blocked_text(text: str) -> bool:
|
|
171
|
+
"""The publisher's own page for a blocked address, under its usual title (Science,
|
|
172
|
+
2026-11-16: "Your IP 69.63.193.18 has been blocked."): no login can open it. Read
|
|
173
|
+
from the article page's text the access check reads anyway (``_access_snapshot``)."""
|
|
174
|
+
return bool(_IP_BLOCKED.search(" ".join(text[:4000].lower().split())))
|
|
175
|
+
|
|
166
176
|
def _raise_on_publisher_access_blocked(self, page: Any) -> None:
|
|
167
177
|
if self._publisher_access_blocked(page):
|
|
168
178
|
raise PublisherAccessBlocked("publisher_access_blocked")
|
|
@@ -36,6 +36,12 @@ from .batch_common import (
|
|
|
36
36
|
)
|
|
37
37
|
|
|
38
38
|
|
|
39
|
+
def _sent_as_attachment(headers: dict[str, str]) -> bool:
|
|
40
|
+
"""The site sends the PDF to be saved, not shown (Content-Disposition: attachment):
|
|
41
|
+
Chrome downloads it besides the capture, which holds it already."""
|
|
42
|
+
return headers.get("content-disposition", "").strip().lower().startswith("attachment")
|
|
43
|
+
|
|
44
|
+
|
|
39
45
|
class CaptureMixin:
|
|
40
46
|
"""Getting the PDF: the article's PDF control, the browser's viewer and downloads, fetching again."""
|
|
41
47
|
|
|
@@ -508,10 +514,12 @@ class CaptureMixin:
|
|
|
508
514
|
else payload["body"].encode("latin-1")
|
|
509
515
|
)
|
|
510
516
|
if self._accept_pdf_body(body, url):
|
|
511
|
-
if self.adapter.keeps_pdf_out_of_downloads:
|
|
517
|
+
if self.adapter.keeps_pdf_out_of_downloads or _sent_as_attachment(headers):
|
|
512
518
|
# We own the validated bytes and save them under the
|
|
513
519
|
# DOI below. Do not also hand the response to Chrome's
|
|
514
|
-
# download manager, which exposes a UUID temp file
|
|
520
|
+
# download manager, which exposes a UUID temp file and,
|
|
521
|
+
# for a PDF sent as an attachment, a full second copy in
|
|
522
|
+
# its download list (Science's ?download=true, 2026-11-15).
|
|
515
523
|
cdp_session.send("Fetch.fulfillRequest", {
|
|
516
524
|
"requestId": request_id, "responseCode": 204,
|
|
517
525
|
"responseHeaders": [], "body": "",
|
|
@@ -649,8 +649,14 @@ class InstitutionMixin:
|
|
|
649
649
|
where = str(event.get("detail", "")).split(" @ ", 1)[-1]
|
|
650
650
|
return event["state"] == "auto_institution_search" and self._same_address(where, url)
|
|
651
651
|
|
|
652
|
-
|
|
652
|
+
searches = [index for index, e in enumerate(result.events) if searched_here(e)]
|
|
653
|
+
if not searches:
|
|
653
654
|
return False # nothing searched here: a page's other lists say nothing
|
|
655
|
+
if any(e["state"] == "institution_selected" for e in result.events[searches[-1]:]):
|
|
656
|
+
# Its entry was chosen after that search: the list has the school, and the
|
|
657
|
+
# page is on its way to the school's login (Science sent its login page back,
|
|
658
|
+
# the second choice was still leaving it, 2026-11-15).
|
|
659
|
+
return False
|
|
654
660
|
others = sorted({str(it.get("t") or "")[:80] for score, it in scored if score == 1})
|
|
655
661
|
# A unit of the school (its library, campus, a faculty) may be its way in,
|
|
656
662
|
# unless its publisher marks it as signing in no one (IP, VPN, email).
|
|
@@ -781,10 +787,21 @@ class InstitutionMixin:
|
|
|
781
787
|
raise
|
|
782
788
|
return True # not readable now: nothing concluded from it
|
|
783
789
|
|
|
790
|
+
# The site's own line naming the institution it serves the reader for ("brought to
|
|
791
|
+
# you by <school>" in Science's header, 2026-11-15) is no entry of a list.
|
|
792
|
+
_SESSION_BANNER = re.compile(r"\s*(?:brought to you by|access (?:provided|funded) by)", re.I)
|
|
793
|
+
|
|
794
|
+
def _listed_entries(self, page: Any) -> Any:
|
|
795
|
+
"""The entries a page lists now (``_ENTRIES_JS``), the site's session banner aside."""
|
|
796
|
+
items = page.evaluate(self._ENTRIES_JS, self._ENTRY_SELECTOR)
|
|
797
|
+
if not isinstance(items, list):
|
|
798
|
+
return items
|
|
799
|
+
return [it for it in items if not (isinstance(it, dict) and self._SESSION_BANNER.match(str(it.get("t") or "")))]
|
|
800
|
+
|
|
784
801
|
def _entry_texts(self, page: Any) -> set[str]:
|
|
785
802
|
"""The entries a page lists now, by their text (``_ENTRIES_JS``)."""
|
|
786
803
|
try:
|
|
787
|
-
items =
|
|
804
|
+
items = self._listed_entries(page)
|
|
788
805
|
except Exception as exc:
|
|
789
806
|
if not _is_browser_error(exc):
|
|
790
807
|
raise
|
|
@@ -803,7 +820,7 @@ class InstitutionMixin:
|
|
|
803
820
|
list, 2026-11-01).
|
|
804
821
|
"""
|
|
805
822
|
try:
|
|
806
|
-
items =
|
|
823
|
+
items = self._listed_entries(page)
|
|
807
824
|
except Exception:
|
|
808
825
|
return False
|
|
809
826
|
if not isinstance(items, list):
|
|
@@ -15,7 +15,7 @@ from urllib.parse import unquote, urljoin, urlparse
|
|
|
15
15
|
from . import access_rules
|
|
16
16
|
from .login_wait import LoginWait
|
|
17
17
|
from .. import federations, progress_reporter
|
|
18
|
-
from .batch_common import (AWAY_WAIT_SEC, POLL_MS, DownloadResult, PublisherContentError, _is_browser_error,
|
|
18
|
+
from .batch_common import (AWAY_WAIT_SEC, POLL_MS, DownloadResult, PublisherAccessBlocked, PublisherContentError, _is_browser_error,
|
|
19
19
|
_is_navigation_cut, open_page, pump_until, settle)
|
|
20
20
|
|
|
21
21
|
# A site without a publisher profile (publishers/site.py) whose article page
|
|
@@ -75,6 +75,9 @@ class LoginMixin:
|
|
|
75
75
|
self._raise_on_publisher_content_error(page)
|
|
76
76
|
self._dismiss_cookie_banners(page, result)
|
|
77
77
|
snapshot = self._access_snapshot(page) if not self._is_auth_page(str(page.url)) else None
|
|
78
|
+
if snapshot is not None and self._ip_blocked_text(snapshot.text):
|
|
79
|
+
# Science, 2026-11-16: the driver went on to the school's login and waited out its time.
|
|
80
|
+
raise PublisherAccessBlocked("publisher_access_blocked")
|
|
78
81
|
if self._institution_pdf_entitlement_missing(page, snapshot=snapshot):
|
|
79
82
|
return False
|
|
80
83
|
if self._pdf_first_unless_signed_out(page, result, snapshot=snapshot):
|
|
@@ -273,6 +276,12 @@ class LoginMixin:
|
|
|
273
276
|
result._login_wait = None
|
|
274
277
|
self._set_login_attention(result, "")
|
|
275
278
|
|
|
279
|
+
def _at_login_landing(self, url: str, result: DownloadResult) -> bool:
|
|
280
|
+
"""The publisher's own page its login ends on (``is_login_landing``), after
|
|
281
|
+
this paper chose the school."""
|
|
282
|
+
return (self.adapter.is_login_landing(url)
|
|
283
|
+
and any(e.get("state") in self._SCHOOL_CHOSEN for e in result.events))
|
|
284
|
+
|
|
276
285
|
def _complete_login_steps(self, page: Any, result: DownloadResult) -> bool:
|
|
277
286
|
own = self.adapter.complete_login(page, result)
|
|
278
287
|
if own is not None:
|
|
@@ -414,13 +423,17 @@ class LoginMixin:
|
|
|
414
423
|
after_login, returned, last_probe = returned and self._school_login_done(), False, time.time()
|
|
415
424
|
if self._probe_pdf_while_waiting(page, result, after_login=after_login):
|
|
416
425
|
return False # signed in, and the page still offers or denies the article
|
|
417
|
-
elif (
|
|
426
|
+
elif (on_publisher and article_returns < 2
|
|
427
|
+
and (visited_idp or self._at_login_landing(here.geturl(), result))
|
|
418
428
|
and not self._is_success_article_url(here.geturl())
|
|
419
429
|
and not self._is_auth_page(here.geturl())
|
|
420
430
|
and not self._challenge_shell(page)):
|
|
421
431
|
# Back from the IdP on a publisher page that is neither the
|
|
422
432
|
# article nor a login/chooser page (Taylor & Francis drops the
|
|
423
|
-
# redirect and lands on its home page): open the article.
|
|
433
|
+
# redirect and lands on its home page): open the article. So too
|
|
434
|
+
# on the page a publisher's login ends on once the school was chosen,
|
|
435
|
+
# its sign-in still valid and the IdP passed unseen between two
|
|
436
|
+
# passes (Science: choosing the school again there was no login).
|
|
424
437
|
article_returns += 1
|
|
425
438
|
try:
|
|
426
439
|
open_page(page, result.article_url, timeout_ms=60_000)
|
|
@@ -11,6 +11,7 @@ Part of ``PublisherBatchDownloader`` (batch.py), which combines the mixins."""
|
|
|
11
11
|
|
|
12
12
|
from __future__ import annotations
|
|
13
13
|
|
|
14
|
+
import os
|
|
14
15
|
import sys
|
|
15
16
|
import threading
|
|
16
17
|
import time
|
|
@@ -77,6 +78,17 @@ class UserRequestsMixin:
|
|
|
77
78
|
self._event(result, "browser_focus_unavailable", type(exc).__name__)
|
|
78
79
|
pid = 0
|
|
79
80
|
progress_reporter.update(browser_pid=pid)
|
|
81
|
+
elif os.name == "nt":
|
|
82
|
+
# The window raises the browser itself, as on macOS: a request left for this
|
|
83
|
+
# article's watch was lost once the watch had ended (Windows, 2026-11-16).
|
|
84
|
+
from ..browser.foreground import browser_pids
|
|
85
|
+
|
|
86
|
+
try:
|
|
87
|
+
pids = browser_pids(page, self.config)
|
|
88
|
+
except Exception as exc:
|
|
89
|
+
self._event(result, "browser_focus_unavailable", type(exc).__name__)
|
|
90
|
+
pids = []
|
|
91
|
+
progress_reporter.update(browser_pids=pids)
|
|
80
92
|
|
|
81
93
|
def watch() -> None:
|
|
82
94
|
while not stop.wait(1.0):
|
|
@@ -57,6 +57,9 @@ _FAILURE_KINDS = {
|
|
|
57
57
|
"supplements_only": ("supplements_only", "supplements_only"),
|
|
58
58
|
# The DOI resolves to no site to sign in on (publishers/site.py): no driver can run.
|
|
59
59
|
"unsupported_publisher": ("unsupported_publisher", "review_publisher_profiles"),
|
|
60
|
+
# doi.org answered no address for the DOI (a paper online days before its DOI is
|
|
61
|
+
# registered, Science 2026-11-15) and the publisher's article page is only reached through it.
|
|
62
|
+
"doi_not_resolved": ("doi_not_resolved", "retry_later"),
|
|
60
63
|
# A site without a publisher profile: the shared rules found no institution entry.
|
|
61
64
|
"generic_institution_entry_missing": ("generic_institution_entry_missing", "review_publisher_profiles"),
|
|
62
65
|
**{code: (code, "review_browser") for code in _LOGIN_FAILURE_CODES},
|
|
@@ -260,10 +263,16 @@ def _try_builtin_institutional(
|
|
|
260
263
|
|
|
261
264
|
# Step 1: Resolve DOI to publisher URL
|
|
262
265
|
resolved_url = _resolve_doi(doi)
|
|
266
|
+
if not resolved_url and profile:
|
|
267
|
+
# A paper is online at its publisher days before doi.org knows its DOI (Science,
|
|
268
|
+
# 2026-11-15): the profile's own article address opens it all the same.
|
|
269
|
+
resolved_url = _own_article_url(profile, doi)
|
|
270
|
+
if resolved_url:
|
|
271
|
+
log.info(" [Institutional] DOI not at doi.org yet: the publisher's article page")
|
|
263
272
|
if not resolved_url:
|
|
264
273
|
log.info(" [Institutional] Could not resolve DOI")
|
|
265
274
|
# Without a profile there is no site to build one for.
|
|
266
|
-
return
|
|
275
|
+
return _failure(doi, "doi_not_resolved") if profile else _unsupported_publisher(doi)
|
|
267
276
|
|
|
268
277
|
if not profile:
|
|
269
278
|
from ..publishers.profiles import infer_publisher_profile_from_url
|
|
@@ -300,7 +309,7 @@ def _try_builtin_institutional(
|
|
|
300
309
|
"error_type": "no_entitlement", "reason": "user_marked_no_entitlement",
|
|
301
310
|
"action": "skipped_by_user", "entitlement": remembered}
|
|
302
311
|
from .. import blocked_journals
|
|
303
|
-
blocked_by = blocked_journals.
|
|
312
|
+
blocked_by = blocked_journals.skip_for(identity, doi)
|
|
304
313
|
if blocked_by:
|
|
305
314
|
log.info(" [Institutional] Skipped: this journal's site blocked the current network (%s)", blocked_by)
|
|
306
315
|
return {"success": False, "identifier": doi, "doi": doi, "source": "institutional:blocked_journal",
|
|
@@ -376,7 +385,8 @@ def _try_builtin_institutional(
|
|
|
376
385
|
"action": primary["action"], "source_failures": failures}
|
|
377
386
|
if primary["error_type"] == "access_blocked":
|
|
378
387
|
_remember_blocked_journal(doi, identity)
|
|
379
|
-
if primary["error_type"] == "institution_federation_unavailable" and manual_school
|
|
388
|
+
if (primary["error_type"] == "institution_federation_unavailable" and manual_school
|
|
389
|
+
and (primary.get("artifacts") or {}).get("route_missing")):
|
|
380
390
|
_remember_missing_route(publisher_name, config, doi)
|
|
381
391
|
if "reason_code" in primary:
|
|
382
392
|
result["reason_code"] = primary["reason_code"]
|
|
@@ -395,12 +405,26 @@ def _try_builtin_institutional(
|
|
|
395
405
|
return None
|
|
396
406
|
|
|
397
407
|
|
|
398
|
-
def
|
|
399
|
-
error_type, action = _FAILURE_KINDS[
|
|
408
|
+
def _failure(doi: str, kind: str) -> dict[str, Any]:
|
|
409
|
+
error_type, action = _FAILURE_KINDS[kind]
|
|
400
410
|
return {"success": False, "identifier": doi, "doi": doi, "source": "institutional",
|
|
401
411
|
"error_type": error_type, "reason": error_type, "action": action}
|
|
402
412
|
|
|
403
413
|
|
|
414
|
+
def _unsupported_publisher(doi: str) -> dict[str, Any]:
|
|
415
|
+
return _failure(doi, "unsupported_publisher")
|
|
416
|
+
|
|
417
|
+
|
|
418
|
+
def _own_article_url(profile: Any, doi: str) -> str:
|
|
419
|
+
"""The profile's article address for ``doi`` when it is the publisher's own, not doi.org's."""
|
|
420
|
+
try:
|
|
421
|
+
url = profile.article_url(doi)
|
|
422
|
+
except (AttributeError, KeyError, IndexError, ValueError):
|
|
423
|
+
return ""
|
|
424
|
+
host = (urlparse(url).hostname or "").lower()
|
|
425
|
+
return url if url.startswith("https://") and host and not (host == "doi.org" or host.endswith(".doi.org")) else ""
|
|
426
|
+
|
|
427
|
+
|
|
404
428
|
def _resolve_doi(doi: str) -> str | None:
|
|
405
429
|
"""Resolve a DOI to the publisher landing URL that doi.org redirects to.
|
|
406
430
|
|
|
@@ -711,6 +735,11 @@ def _write_exception_diagnostic(run_dir: Path, doi: str, exc: Exception, *,
|
|
|
711
735
|
return str(path)
|
|
712
736
|
|
|
713
737
|
|
|
738
|
+
#: Where a wait on a school login can end (``BatchLoginMixin._login_wait_page``).
|
|
739
|
+
LOGIN_WAIT_PAGES = ("school_login", "school_choice", "institution_chooser", "authentication_redirect",
|
|
740
|
+
"publisher", "other", "closed")
|
|
741
|
+
|
|
742
|
+
|
|
714
743
|
def _browser_artifacts(result: Any, profile: Any) -> dict[str, str]:
|
|
715
744
|
"""Where the browser run left its record (success) or diagnostic packet (failure).
|
|
716
745
|
|
|
@@ -725,6 +754,18 @@ def _browser_artifacts(result: Any, profile: Any) -> dict[str, str]:
|
|
|
725
754
|
"diagnostic": str(getattr(result, "diagnostic_path", "") or ""),
|
|
726
755
|
"state": state if re.fullmatch(r"[a-z0-9_]{1,64}", state) else "",
|
|
727
756
|
}
|
|
757
|
+
# The publisher's list was seen without the school in this run, and the school was
|
|
758
|
+
# chosen nowhere in it: only this is remembered as no route (``login_routes``); an
|
|
759
|
+
# article that ended on the earlier finding, or whose school was chosen, is not.
|
|
760
|
+
events = getattr(result, "events", None) or []
|
|
761
|
+
if getattr(result, "_institution_not_listed", False) is True and not any(
|
|
762
|
+
isinstance(e, dict) and e.get("state") == "institution_selected" for e in events):
|
|
763
|
+
artifacts["route_missing"] = True
|
|
764
|
+
# Where a wait on a school login ended (``_login_wait_page``): a fixed word. The caller
|
|
765
|
+
# holds a publisher only on the school's own sign-in page (2026-11-15).
|
|
766
|
+
wait_page = str(getattr(result, "login_wait_page", "") or "")
|
|
767
|
+
if wait_page in LOGIN_WAIT_PAGES:
|
|
768
|
+
artifacts["login_wait_page"] = wait_page
|
|
728
769
|
# The school's site the login stopped on: a host name only, for the message.
|
|
729
770
|
host = str(getattr(result, "_stopped_host", "") or "").lower()
|
|
730
771
|
if state == "idp_no_return_to_publisher" and re.fullmatch(r"[a-z0-9-]+(?:\.[a-z0-9-]+)+", host) and len(host) <= 253:
|
|
@@ -42,6 +42,8 @@ class UserStoppedBatch(UserMarkedNoEntitlement):
|
|
|
42
42
|
# Not an entitlement decision: nothing is recorded, the batch ends.
|
|
43
43
|
STOP_BATCH = "stop_batch"
|
|
44
44
|
SHOW_BROWSER = "show_browser"
|
|
45
|
+
# The user is back: a publisher the batch held goes on (``resume_path``).
|
|
46
|
+
RESUME_HELD = "resume_held"
|
|
45
47
|
|
|
46
48
|
|
|
47
49
|
SKIP = "skip"
|
|
@@ -204,6 +206,31 @@ def request_action(current: str, action: str, run_id: str = "") -> None:
|
|
|
204
206
|
_write_json(control_path(), data)
|
|
205
207
|
|
|
206
208
|
|
|
209
|
+
def resume_path() -> Path:
|
|
210
|
+
return control_path().with_name("resume.json")
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
def request_resume(key: str, batch_id: str) -> None:
|
|
214
|
+
"""The user asked the batch to go on with a publisher it holds (a DOI prefix)."""
|
|
215
|
+
data = _read_json(resume_path())
|
|
216
|
+
keys = list(data.get("keys") or []) if data.get("batch_id") == batch_id else []
|
|
217
|
+
if key not in keys:
|
|
218
|
+
keys.append(key)
|
|
219
|
+
_write_json(resume_path(), {"batch_id": batch_id, "keys": keys, "at": time.time()})
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
def take_resumes(batch_id: str) -> list[str]:
|
|
223
|
+
"""The publishers the user asked this batch to go on with, once (the caller's next report)."""
|
|
224
|
+
data = _read_json(resume_path())
|
|
225
|
+
if not batch_id or data.get("batch_id") != batch_id:
|
|
226
|
+
return []
|
|
227
|
+
try:
|
|
228
|
+
resume_path().unlink()
|
|
229
|
+
except OSError:
|
|
230
|
+
pass
|
|
231
|
+
return [str(key) for key in data.get("keys") or [] if isinstance(key, str)]
|
|
232
|
+
|
|
233
|
+
|
|
207
234
|
def batch_stop_requested() -> bool:
|
|
208
235
|
"""A durable stop for the current run, including the gap between papers."""
|
|
209
236
|
stop = _read_json(control_path().with_name("stop.json"))
|
|
@@ -143,6 +143,9 @@ def _download_impl(doi: str, output_dir: str | Path | None, *,
|
|
|
143
143
|
except Exception as exc:
|
|
144
144
|
log.info(f" [Institutional] route exception: {type(exc).__name__}")
|
|
145
145
|
return fail(doi, "institutional route raised", error_type="source_exception", action="review_logs")
|
|
146
|
+
# An article that re-checked a blocked journal's site: open again unless blocked again.
|
|
147
|
+
from . import blocked_journals
|
|
148
|
+
blocked_journals.recheck_ended(doi, blocked=bool(result) and result.get("error_type") == "access_blocked")
|
|
146
149
|
|
|
147
150
|
if result is None:
|
|
148
151
|
return fail(
|
|
@@ -225,8 +225,17 @@ class Api:
|
|
|
225
225
|
def act(self, action: str, current: str, run_id: str = "") -> str:
|
|
226
226
|
"""Control the running download, including showing its browser on request."""
|
|
227
227
|
try:
|
|
228
|
-
from .entitlements import SHOW_BROWSER, request_action
|
|
228
|
+
from .entitlements import RESUME_HELD, SHOW_BROWSER, request_action, request_resume
|
|
229
229
|
|
|
230
|
+
if action == RESUME_HELD:
|
|
231
|
+
# The user is back: every publisher the batch holds goes on.
|
|
232
|
+
state = read_state() or {}
|
|
233
|
+
held = [str(entry["key"]) for entry in state.get("held") or [] if isinstance(entry, dict) and entry.get("key")]
|
|
234
|
+
if state.get("status") != "running" or str(state.get("run_id") or "") != run_id or not held:
|
|
235
|
+
return "这批下载已没有暂停的篇目"
|
|
236
|
+
for key in held:
|
|
237
|
+
request_resume(key, str(state.get("batch_id") or ""))
|
|
238
|
+
return progress_view.ACTION_FEEDBACK[RESUME_HELD]
|
|
230
239
|
if action == SHOW_BROWSER:
|
|
231
240
|
# Asked for from a reminder, or from the paper on the card at any
|
|
232
241
|
# time while it has a browser (user request, 2026-11-08).
|
|
@@ -243,12 +252,25 @@ class Api:
|
|
|
243
252
|
pid = state.get("browser_pid")
|
|
244
253
|
if not isinstance(pid, int) or pid <= 0 or not activate_mac(pid):
|
|
245
254
|
return "未能切到下载浏览器,请从程序坞打开"
|
|
246
|
-
if os.name == "nt"
|
|
247
|
-
# The
|
|
248
|
-
#
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
255
|
+
if os.name == "nt":
|
|
256
|
+
# The window raises the browser itself, as on macOS, whatever the paper
|
|
257
|
+
# is fetching and between papers: a request left for the article's watch
|
|
258
|
+
# was lost once the watch had ended (Windows, 2026-11-16).
|
|
259
|
+
pids = [p for p in state.get("browser_pids") or [] if isinstance(p, int) and p > 0]
|
|
260
|
+
if pids:
|
|
261
|
+
from .browser.foreground import activate_windows
|
|
262
|
+
|
|
263
|
+
if not activate_windows(pids):
|
|
264
|
+
return "未能切到下载浏览器,请从任务栏打开"
|
|
265
|
+
if isinstance(state.get("owner_pid"), int) and state["owner_pid"] > 0:
|
|
266
|
+
# The click gives this foreground window permission to let
|
|
267
|
+
# the exact backend process activate its browser on Windows.
|
|
268
|
+
import ctypes
|
|
269
|
+
|
|
270
|
+
ctypes.windll.user32.AllowSetForegroundWindow(state["owner_pid"])
|
|
271
|
+
if state.get("awaiting_next"):
|
|
272
|
+
# Between papers no article watches for requests: raised above, nothing to leave.
|
|
273
|
+
return "已切到下载浏览器"
|
|
252
274
|
|
|
253
275
|
request_action(str(current), str(action), str(run_id))
|
|
254
276
|
return progress_view.ACTION_FEEDBACK[str(action)]
|
|
@@ -286,7 +308,7 @@ class Api:
|
|
|
286
308
|
return "已在浏览器打开这篇文章" if opened else "打开失败:没有找到默认浏览器"
|
|
287
309
|
|
|
288
310
|
def open_folder(self) -> bool:
|
|
289
|
-
return progress_view.open_folder(
|
|
311
|
+
return progress_view.open_folder(progress_view.batch_folder(read_papers(), read_state()))
|
|
290
312
|
|
|
291
313
|
# --- the lists behind 成功, 失败 and 剩余 ---------------------------------
|
|
292
314
|
def _papers_batch(self) -> str:
|
|
@@ -303,15 +325,17 @@ class Api:
|
|
|
303
325
|
return progress_view.paper_lists(read_papers(), read_state())
|
|
304
326
|
|
|
305
327
|
def show_paper(self, index: int) -> str:
|
|
306
|
-
"""A saved
|
|
307
|
-
recorded for it,
|
|
328
|
+
"""A saved paper of the running or finished batch, shown in its folder: the file the batch
|
|
329
|
+
recorded for it (its PDF, else what it saved of it: a batch of the supplementary files or the
|
|
330
|
+
Markdown alone has no PDF, 2026-11-16), wherever the paper was sent (folders of their own by
|
|
331
|
+
topic, user 2026-11-11). The file is only selected in its folder, never opened."""
|
|
308
332
|
listed, state = read_papers() or {}, read_state() or {}
|
|
309
333
|
key = str(index) if isinstance(index, int) and not isinstance(index, bool) else ""
|
|
310
334
|
paper = (listed.get("papers") or {}).get(key) if listed.get("batch_id") == state.get("batch_id") else None
|
|
311
335
|
path = str((paper or {}).get("path") or "") if (paper or {}).get("state") == "ok" else ""
|
|
312
336
|
real = os.path.realpath(path) if path else ""
|
|
313
|
-
if not real
|
|
314
|
-
return "
|
|
337
|
+
if not real:
|
|
338
|
+
return "打开失败:这篇没有保存的文件"
|
|
315
339
|
if not progress_view.reveal_file(real):
|
|
316
340
|
return "打开失败:文件已被移走或删除"
|
|
317
341
|
return "已打开所在文件夹"
|
|
@@ -295,6 +295,8 @@ def _adopt_batch(batch_id: str, total: int, counts: tuple[int | None, int | None
|
|
|
295
295
|
and not _STATE.get("awaiting_next")):
|
|
296
296
|
done, succeeded, failed = counts
|
|
297
297
|
_STATE.update(total=int(total), lanes=fields.get("lanes", ""),
|
|
298
|
+
**({"held": fields["held"]} if "held" in fields else {}),
|
|
299
|
+
**({"held_wait": fields["held_wait"]} if "held_wait" in fields else {}),
|
|
298
300
|
**({"done": done} if done is not None else {}),
|
|
299
301
|
**({"success": succeeded} if succeeded is not None else {}),
|
|
300
302
|
**({"failed": failed} if failed is not None else {}))
|
|
@@ -335,9 +337,28 @@ def _adopt_batch(batch_id: str, total: int, counts: tuple[int | None, int | None
|
|
|
335
337
|
return True
|
|
336
338
|
|
|
337
339
|
|
|
340
|
+
_HELD_KEY = re.compile(r"10\.\d{4,9}/")
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
def _held(raw: Any) -> list[dict[str, Any]]:
|
|
344
|
+
"""The publishers whose papers the caller holds (their school login stopped working
|
|
345
|
+
mid-batch): [{key (a DOI prefix), name, count}], at most four, checked for the window."""
|
|
346
|
+
held: list[dict[str, Any]] = []
|
|
347
|
+
for entry in raw if isinstance(raw, list) else []:
|
|
348
|
+
if not isinstance(entry, dict) or not _HELD_KEY.fullmatch(str(entry.get("key") or "")):
|
|
349
|
+
continue
|
|
350
|
+
count = entry.get("count")
|
|
351
|
+
if not isinstance(count, int) or isinstance(count, bool) or not 0 < count <= 1_000_000:
|
|
352
|
+
continue
|
|
353
|
+
name = _short_line(entry.get("name"), 40) or entry["key"]
|
|
354
|
+
held.append({"key": entry["key"], "name": name, "count": count})
|
|
355
|
+
return held[:4]
|
|
356
|
+
|
|
357
|
+
|
|
338
358
|
def sync_batch(batch_id: str, total: int, done: int, succeeded: int, failed: int, *,
|
|
339
359
|
current: str = "", finished: bool = False, results: Any = None,
|
|
340
|
-
phase: str = "", channel: str = "", lanes: str = ""
|
|
360
|
+
phase: str = "", channel: str = "", lanes: str = "", held: Any = None,
|
|
361
|
+
held_wait: bool = False) -> bool:
|
|
341
362
|
"""Record batch totals for items finished without the backend, or the batch end.
|
|
342
363
|
|
|
343
364
|
``results`` (the batch end only) is the caller's summary of every item,
|
|
@@ -348,7 +369,10 @@ def sync_batch(batch_id: str, total: int, done: int, succeeded: int, failed: int
|
|
|
348
369
|
short single lines and are dropped at the batch end. ``lanes`` is one line on
|
|
349
370
|
what each lane got in a batch whose open-access checks run beside its downloads;
|
|
350
371
|
it may come while a download of the batch runs, which then keeps its paper,
|
|
351
|
-
stage and prompts (``_adopt_batch``).
|
|
372
|
+
stage and prompts (``_adopt_batch``). ``held``: the publishers the caller holds
|
|
373
|
+
(``_held``), each with a button to go on with them; an empty list clears them.
|
|
374
|
+
``held_wait``: nothing else is left and the batch waits for the user to go on with
|
|
375
|
+
them or end it (each report says it again; any other report, or a download, ends it)."""
|
|
352
376
|
ctx = BatchContext.from_args(batch_id, max(1, min(done, total)), total, done, succeeded, failed)
|
|
353
377
|
if ctx is None or done > total:
|
|
354
378
|
return False
|
|
@@ -361,6 +385,8 @@ def sync_batch(batch_id: str, total: int, done: int, succeeded: int, failed: int
|
|
|
361
385
|
beside_download=bool(lanes) and not finished,
|
|
362
386
|
**({"current": current} if current else {}),
|
|
363
387
|
**({"lanes": lanes} if lanes or finished else {}),
|
|
388
|
+
**({"held": [] if finished else _held(held)} if held is not None or finished else {}),
|
|
389
|
+
held_wait=bool(held_wait) and not finished,
|
|
364
390
|
stage="saved_pending_verification" if finished else "starting",
|
|
365
391
|
channel="" if finished else channel,
|
|
366
392
|
phase=(f"批量下载结束:成功 {succeeded},失败 {failed}" if finished
|
|
@@ -572,6 +598,7 @@ def tracked_download(current: str, output_dir: Any = None, batch: BatchContext |
|
|
|
572
598
|
_notify_stage("starting", current)
|
|
573
599
|
with _LOCK:
|
|
574
600
|
_STATE.pop("hourly_wait", None) # this article runs: no longer held by the hourly limit
|
|
601
|
+
_STATE.pop("held_wait", None) # nor waiting for the user to go on with held publishers
|
|
575
602
|
update(content=content if content in ("main", "supplements", "both") else "main")
|
|
576
603
|
if output_dir:
|
|
577
604
|
set_output_dir(output_dir)
|