papersearch 0.7.1 → 0.7.3
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/download/batch/batch.d.ts.map +1 -1
- package/dist/capabilities/download/batch/batch.js +306 -12
- package/dist/capabilities/download/batch/batch.js.map +1 -1
- package/dist/capabilities/download/batch/batchFolder.js +1 -1
- package/dist/capabilities/download/batch/batchFolder.js.map +1 -1
- package/dist/capabilities/download/batch/batchSummary.d.ts.map +1 -1
- package/dist/capabilities/download/batch/batchSummary.js +17 -8
- package/dist/capabilities/download/batch/batchSummary.js.map +1 -1
- package/dist/capabilities/download/batch/journalKey.d.ts +12 -0
- package/dist/capabilities/download/batch/journalKey.d.ts.map +1 -0
- package/dist/capabilities/download/batch/journalKey.js +30 -0
- package/dist/capabilities/download/batch/journalKey.js.map +1 -0
- package/dist/capabilities/download/batch/networkLoss.d.ts +1 -1
- package/dist/capabilities/download/batch/networkLoss.js +1 -1
- package/dist/capabilities/download/content/markdown/shortfall.js +5 -5
- package/dist/capabilities/download/content/markdown/shortfall.js.map +1 -1
- package/dist/capabilities/download/content/pdf/DownloadTier.d.ts +4 -0
- package/dist/capabilities/download/content/pdf/DownloadTier.d.ts.map +1 -1
- package/dist/capabilities/download/content/pdf/OpenAccessFallbackService.d.ts.map +1 -1
- package/dist/capabilities/download/content/pdf/OpenAccessFallbackService.js +2 -0
- package/dist/capabilities/download/content/pdf/OpenAccessFallbackService.js.map +1 -1
- package/dist/capabilities/download/content/pdf/school.js +2 -0
- package/dist/capabilities/download/content/pdf/school.js.map +1 -1
- package/dist/capabilities/download/types.d.ts +4 -0
- package/dist/capabilities/download/types.d.ts.map +1 -1
- package/dist/cli.js +32 -9
- package/dist/cli.js.map +1 -1
- package/dist/infrastructure/runlog/failureClass.d.ts +16 -9
- package/dist/infrastructure/runlog/failureClass.d.ts.map +1 -1
- package/dist/infrastructure/runlog/failureClass.js +64 -54
- package/dist/infrastructure/runlog/failureClass.js.map +1 -1
- package/dist/infrastructure/school/SchoolAttempt.d.ts.map +1 -1
- package/dist/infrastructure/school/SchoolAttempt.js +61 -56
- package/dist/infrastructure/school/SchoolAttempt.js.map +1 -1
- package/dist/infrastructure/school/SchoolMcpClient.d.ts +9 -1
- package/dist/infrastructure/school/SchoolMcpClient.d.ts.map +1 -1
- package/dist/infrastructure/school/SchoolMcpClient.js +31 -1
- package/dist/infrastructure/school/SchoolMcpClient.js.map +1 -1
- package/dist/infrastructure/school/SchoolReadiness.d.ts +2 -0
- package/dist/infrastructure/school/SchoolReadiness.d.ts.map +1 -1
- package/dist/infrastructure/school/SchoolReadiness.js +3 -0
- package/dist/infrastructure/school/SchoolReadiness.js.map +1 -1
- package/dist/infrastructure/school/SchoolResultNormalizer.d.ts.map +1 -1
- package/dist/infrastructure/school/SchoolResultNormalizer.js +5 -0
- package/dist/infrastructure/school/SchoolResultNormalizer.js.map +1 -1
- package/dist/infrastructure/school/index.d.ts +1 -1
- package/dist/infrastructure/school/index.d.ts.map +1 -1
- package/dist/infrastructure/school/types.d.ts +19 -0
- package/dist/infrastructure/school/types.d.ts.map +1 -1
- package/dist/management/failures/index.d.ts +5 -2
- package/dist/management/failures/index.d.ts.map +1 -1
- package/dist/management/failures/index.js +21 -4
- package/dist/management/failures/index.js.map +1 -1
- package/dist/management/pro/activate.d.ts +36 -0
- package/dist/management/pro/activate.d.ts.map +1 -0
- package/dist/management/pro/activate.js +122 -0
- package/dist/management/pro/activate.js.map +1 -0
- package/dist/management/pro/install.d.ts +15 -0
- package/dist/management/pro/install.d.ts.map +1 -1
- package/dist/management/pro/install.js +39 -12
- package/dist/management/pro/install.js.map +1 -1
- package/dist/management/reports/index.d.ts +6 -0
- package/dist/management/reports/index.d.ts.map +1 -1
- package/dist/management/reports/index.js +6 -0
- package/dist/management/reports/index.js.map +1 -1
- package/dist/management/school/autoUpdate.d.ts.map +1 -1
- package/dist/management/school/autoUpdate.js +1 -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 +1 -0
- package/dist/management/school/cliProgress.js.map +1 -1
- package/dist/management/school/settingsWindow.d.ts +1 -0
- package/dist/management/school/settingsWindow.d.ts.map +1 -1
- package/dist/management/school/settingsWindow.js +2 -0
- package/dist/management/school/settingsWindow.js.map +1 -1
- package/dist/management/updates/selfUpdate.d.ts +86 -0
- package/dist/management/updates/selfUpdate.d.ts.map +1 -0
- package/dist/management/updates/selfUpdate.js +194 -0
- package/dist/management/updates/selfUpdate.js.map +1 -0
- package/package.json +1 -1
- package/school/paper_search_school/adapters/annual_reviews/__init__.py +1 -0
- package/school/paper_search_school/adapters/base.py +4 -0
- package/school/paper_search_school/adapters/ieee/__init__.py +1 -0
- package/school/paper_search_school/adapters/oup/__init__.py +20 -0
- package/school/paper_search_school/adapters/sage/__init__.py +4 -1
- package/school/paper_search_school/adapters/taylor_francis/__init__.py +3 -0
- package/school/paper_search_school/adapters/thieme/__init__.py +4 -2
- package/school/paper_search_school/assets/capsule.html +1044 -243
- package/school/paper_search_school/assets/capsule_en.json +320 -74
- package/school/paper_search_school/assets/capsule_fr.json +1309 -0
- package/school/paper_search_school/assets/capsule_ja.json +1309 -0
- package/school/paper_search_school/assets/capsule_ko.json +1309 -0
- package/school/paper_search_school/assets/capsule_zh-Hant.json +2436 -0
- package/school/paper_search_school/cli.py +15 -1
- package/school/paper_search_school/cold_start.py +82 -9
- package/school/paper_search_school/config.py +2 -0
- package/school/paper_search_school/download_diagnostics.py +4 -4
- package/school/paper_search_school/engine/access_rules.py +3 -2
- package/school/paper_search_school/engine/batch.py +12 -4
- package/school/paper_search_school/engine/batch_access.py +21 -9
- package/school/paper_search_school/engine/batch_capture.py +36 -2
- package/school/paper_search_school/engine/batch_diagnostics.py +1 -1
- package/school/paper_search_school/engine/batch_institution.py +171 -29
- package/school/paper_search_school/engine/batch_login.py +65 -1
- package/school/paper_search_school/engine/batch_waits.py +22 -8
- package/school/paper_search_school/engine/bridge.py +27 -3
- package/school/paper_search_school/engine/router.py +2 -1
- package/school/paper_search_school/i18n.py +46 -22
- package/school/paper_search_school/orchestrator.py +90 -12
- package/school/paper_search_school/pro_status.py +54 -63
- package/school/paper_search_school/progress_capsule.py +180 -24
- package/school/paper_search_school/progress_reporter.py +68 -13
- package/school/paper_search_school/progress_view.py +4 -3
- package/school/paper_search_school/publishers/builtin/sage.json +4 -2
- package/school/paper_search_school/publishers/builtin/thieme.json +3 -1
- package/school/paper_search_school/school_login.py +18 -4
- package/school/paper_search_school/school_switch.py +84 -0
- package/school/paper_search_school/school_test.py +335 -0
- package/school/paper_search_school/server.py +21 -3
- package/school/paper_search_school/updates.py +222 -0
- package/school/paper_search_school/user_settings.py +8 -3
- package/skills/paper-search/SKILL.md +1 -1
- package/skills/paper-search/references/browser-download.md +7 -9
- package/skills/paper-search/references/cli-contract.md +1 -1
- package/skills/paper-search/references/publisher-support.md +2 -2
- package/skills/paper-search/references/school-setup.md +1 -1
|
@@ -4,6 +4,8 @@ Commands:
|
|
|
4
4
|
run start the MCP stdio server (what PaperSearch spawns)
|
|
5
5
|
setup [...] show or change institutional access settings; --check for an environment check
|
|
6
6
|
login --doi DOI sign in to the school as a download does (no PDF); success only once confirmed
|
|
7
|
+
school-test --school ENTITY --doi DOI the settings' 测试登录: one download with a saved school, its PDF deleted,
|
|
8
|
+
the verdict in progress/school-test.json (school_test.py)
|
|
7
9
|
config get|set|list read or write the backend config in SCHOOL_DATA_DIR
|
|
8
10
|
list-publishers print publisher profiles and their platform labels
|
|
9
11
|
publisher-check --doi DOI run one institutional download and print a sanitized report
|
|
@@ -392,6 +394,12 @@ def _cmd_login(args: argparse.Namespace) -> int:
|
|
|
392
394
|
return 0 if reply["success"] else 1
|
|
393
395
|
|
|
394
396
|
|
|
397
|
+
def _cmd_school_test(args: argparse.Namespace) -> int:
|
|
398
|
+
from .school_test import run
|
|
399
|
+
|
|
400
|
+
return run(args.school, args.doi)
|
|
401
|
+
|
|
402
|
+
|
|
395
403
|
# ---------------------------------------------------------------------------
|
|
396
404
|
# other commands
|
|
397
405
|
# ---------------------------------------------------------------------------
|
|
@@ -619,7 +627,8 @@ def _cmd_issues(args: argparse.Namespace) -> int:
|
|
|
619
627
|
return 0
|
|
620
628
|
|
|
621
629
|
|
|
622
|
-
|
|
630
|
+
# about: PaperSearch's version and its update, Pro's with it (user, 2026-11-21); pro opens it too, by its old name.
|
|
631
|
+
SETTINGS_PAGES = ("home", "about", "download", "wait", "keys", "pro", "markdown", "login")
|
|
623
632
|
# PaperSearch Pro's pages (edition.py): Pro itself, its Markdown, the school's sign-in (school_login.py).
|
|
624
633
|
PRO_PAGES = ("pro", "markdown", "login")
|
|
625
634
|
|
|
@@ -729,6 +738,11 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
729
738
|
help="seconds to wait on the school's login page (default: the setting browser_login_timeout)")
|
|
730
739
|
lg.set_defaults(func=_cmd_login)
|
|
731
740
|
|
|
741
|
+
stt = sub.add_parser("school-test", help="the settings' 测试登录: one download with a saved school, its PDF deleted")
|
|
742
|
+
stt.add_argument("--school", required=True, help="the saved school's entityID")
|
|
743
|
+
stt.add_argument("--doi", required=True)
|
|
744
|
+
stt.set_defaults(func=_cmd_school_test)
|
|
745
|
+
|
|
732
746
|
cfg = sub.add_parser("config", help="read or write backend config")
|
|
733
747
|
cfg.add_argument("action", choices=["get", "set", "list"])
|
|
734
748
|
cfg.add_argument("key", nargs="?")
|
|
@@ -12,7 +12,9 @@ start forgets:
|
|
|
12
12
|
thelancet.com, ...) and their trackers.
|
|
13
13
|
|
|
14
14
|
It keeps bot-verification records (Cloudflare), personal publisher accounts
|
|
15
|
-
and cookie-consent choices
|
|
15
|
+
and cookie-consent choices; before a sign-in with another school (``before_sign_in``)
|
|
16
|
+
the personal accounts go too: Elsevier's keeps the school's access with it, while that school's own sign-in (its
|
|
17
|
+
login hosts and domains) stays, as it would come back as it is. Besides the profile's own cookie store it filters
|
|
16
18
|
the files that put cookies back: the session cookies saved for the next
|
|
17
19
|
launch and the saved publisher cookies. IndexedDB goes per site. Chrome keeps
|
|
18
20
|
every site's local storage in one database, which goes whole when it holds a
|
|
@@ -34,9 +36,10 @@ from . import federations
|
|
|
34
36
|
from .browser.backend import SESSION_COOKIES_FILE, chrome_profile_dir, profile_holder
|
|
35
37
|
from .browser.cookies import _CLOUDFLARE_COOKIE_NAMES, PUBLISHER_DOMAINS
|
|
36
38
|
from .engine.batch_institution import InstitutionMixin, _school_auth_patterns
|
|
39
|
+
from .schools import lookup as school_lookup
|
|
37
40
|
|
|
38
41
|
DELETE = ("school_login", "publisher", "other_site")
|
|
39
|
-
KEEP = ("verification", "personal_account", "consent")
|
|
42
|
+
KEEP = ("verification", "personal_account", "consent", "own_school")
|
|
40
43
|
|
|
41
44
|
# Personal publisher accounts (Elsevier's account system); extend when another
|
|
42
45
|
# publisher keeps personal sign-in on a host of its own.
|
|
@@ -65,17 +68,30 @@ def _publisher_domains() -> tuple[str, ...]:
|
|
|
65
68
|
|
|
66
69
|
|
|
67
70
|
class Classifier:
|
|
68
|
-
"""Sorts a cookie (host, name) or a site's data (host) into the categories above.
|
|
71
|
+
"""Sorts a cookie (host, name) or a site's data (host) into the categories above. ``accounts``: the personal
|
|
72
|
+
publisher accounts are forgotten as a school's login (another school to sign in with). ``keep_own``: the sign-in of
|
|
73
|
+
``config``'s school, the one about to sign in, is kept (its login hosts and domains, not a service other schools
|
|
74
|
+
sign in on): forgetting another school's need not make it type its password again, which its login answered with
|
|
75
|
+
a picture code after a few that day (a test school, Windows, 2026-11-22)."""
|
|
69
76
|
|
|
70
|
-
def __init__(self, config: dict[str, Any]):
|
|
77
|
+
def __init__(self, config: dict[str, Any], accounts: bool = False, keep_own: bool = False):
|
|
71
78
|
self.school_tokens = tuple(t.lower() for t in _school_auth_patterns(config) if t)
|
|
72
79
|
self.publishers = _publisher_domains()
|
|
80
|
+
self.accounts = accounts
|
|
81
|
+
own = (*school_lookup.login_hosts(config), *school_lookup.domains(config)) if keep_own else ()
|
|
82
|
+
self.own = tuple(h for h in dict.fromkeys(own) if h and not _under(h, FEDERATION_HOSTS))
|
|
73
83
|
|
|
74
84
|
def __call__(self, host: str, name: str = "") -> str:
|
|
75
85
|
host = (host or "").lower().lstrip(".").split(":")[0]
|
|
76
86
|
if name and (name in _CLOUDFLARE_COOKIE_NAMES or name.startswith(("cf_chl", "__cf"))):
|
|
77
87
|
return "verification"
|
|
88
|
+
if self.own and _under(host, self.own):
|
|
89
|
+
return "own_school"
|
|
78
90
|
if _under(host, PERSONAL_ACCOUNT_HOSTS):
|
|
91
|
+
# Elsevier's account keeps the school it was signed in through (remember.me signs the next visit in with
|
|
92
|
+
# it, the school's access and all: a test of another school passed with the last one's, user 2026-11-21).
|
|
93
|
+
if self.accounts:
|
|
94
|
+
return "consent" if name and _CONSENT_NAME.search(name) else "school_login"
|
|
79
95
|
return "school_login" if name and _REMEMBERED_SCHOOL_NAME.search(name) else "personal_account"
|
|
80
96
|
if name and _CONSENT_NAME.search(name):
|
|
81
97
|
return "consent"
|
|
@@ -103,10 +119,11 @@ def _netscape_rows(path: Path) -> list[list[str]]:
|
|
|
103
119
|
|
|
104
120
|
|
|
105
121
|
class ColdStart:
|
|
106
|
-
def __init__(self, profile: Path, cache_dir: Path | None, config: dict[str, Any]
|
|
122
|
+
def __init__(self, profile: Path, cache_dir: Path | None, config: dict[str, Any], accounts: bool = False,
|
|
123
|
+
keep_own: bool = False):
|
|
107
124
|
self.profile = profile
|
|
108
125
|
self.cache_dir = cache_dir # None: the profile only, no saved cookie files
|
|
109
|
-
self.classify = Classifier(config)
|
|
126
|
+
self.classify = Classifier(config, accounts, keep_own)
|
|
110
127
|
|
|
111
128
|
# -- reading ------------------------------------------------------------
|
|
112
129
|
|
|
@@ -257,7 +274,8 @@ def _write_json(path: Path, data: Any) -> None:
|
|
|
257
274
|
tmp.replace(path)
|
|
258
275
|
|
|
259
276
|
|
|
260
|
-
def for_config(config: dict[str, Any], profile: str | None = None, cache_dir: str | None = None
|
|
277
|
+
def for_config(config: dict[str, Any], profile: str | None = None, cache_dir: str | None = None,
|
|
278
|
+
accounts: bool = False, keep_own: bool = False) -> ColdStart:
|
|
261
279
|
"""The cold start for the configured download profile (Chrome's own directory)
|
|
262
280
|
and the configured cache. Another profile comes with only the cache named for
|
|
263
281
|
it: the configured cache belongs to the configured profile."""
|
|
@@ -265,6 +283,61 @@ def for_config(config: dict[str, Any], profile: str | None = None, cache_dir: st
|
|
|
265
283
|
from .engine.batch_common import _resolve_profile_dir
|
|
266
284
|
|
|
267
285
|
if profile:
|
|
268
|
-
return ColdStart(Path(profile), Path(cache_dir) if cache_dir else None, config)
|
|
286
|
+
return ColdStart(Path(profile), Path(cache_dir) if cache_dir else None, config, accounts, keep_own)
|
|
269
287
|
cache = cache_dir or config.get("cache_dir", str(DATA_DIR / "cache"))
|
|
270
|
-
return ColdStart(chrome_profile_dir(_resolve_profile_dir(config)), Path(cache), config)
|
|
288
|
+
return ColdStart(chrome_profile_dir(_resolve_profile_dir(config)), Path(cache), config, accounts, keep_own)
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
# -- another school's sign-in --------------------------------------------------------------------
|
|
292
|
+
# Switched to another school, the download browser stayed signed in with the last one: the publisher's page opened
|
|
293
|
+
# through it, and the new school's account was never used (user, 2026-11-21). The school the browser last signed in
|
|
294
|
+
# with is kept; a download with another forgets that sign-in first, as a cold start does (the publishers' sessions and
|
|
295
|
+
# remembered schools with it; verification records, personal accounts and consent choices kept).
|
|
296
|
+
|
|
297
|
+
def _signed_in_path() -> Path:
|
|
298
|
+
from .data_home import default_data_dir
|
|
299
|
+
|
|
300
|
+
return default_data_dir() / "browser_school.json"
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
def signed_in_school() -> str:
|
|
304
|
+
"""The school the download browser last signed in with ("" not known)."""
|
|
305
|
+
try:
|
|
306
|
+
data = json.loads(_signed_in_path().read_text(encoding="utf-8"))
|
|
307
|
+
except (OSError, ValueError):
|
|
308
|
+
return ""
|
|
309
|
+
return str(data.get("school") or "") if isinstance(data, dict) else ""
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
def before_sign_in(config: dict[str, Any], *, always: bool = False) -> str:
|
|
313
|
+
"""Before a download signs in with ``config``'s school: the browser last signed in with another forgets that
|
|
314
|
+
sign-in (``always``, the settings' 测试登录: whatever it was, so that the account is what the test tries).
|
|
315
|
+
"cleared"; "" when there was nothing to forget (the same school, or none known yet: kept from now on); "busy"
|
|
316
|
+
when the download browser is open (nothing changed)."""
|
|
317
|
+
entity = str(config.get("idp_entity_id") or "").strip()
|
|
318
|
+
if not entity:
|
|
319
|
+
return ""
|
|
320
|
+
last = signed_in_school()
|
|
321
|
+
if not always and (not last or last == entity):
|
|
322
|
+
if not last:
|
|
323
|
+
_signed_in_path().parent.mkdir(parents=True, exist_ok=True)
|
|
324
|
+
_write_json(_signed_in_path(), {"school": entity})
|
|
325
|
+
return ""
|
|
326
|
+
# The personal publisher accounts too: Elsevier's signs the next visit in with the last school's access. The school
|
|
327
|
+
# about to sign in keeps its own sign-in, but not for a test (``always``): its account is what the test tries.
|
|
328
|
+
run = for_config(config, accounts=True, keep_own=not always)
|
|
329
|
+
try:
|
|
330
|
+
run.apply()
|
|
331
|
+
except RuntimeError:
|
|
332
|
+
# A browser just closed (a batch's, for the next school) takes a few seconds to let go of the profile.
|
|
333
|
+
from .browser.profiles import wait_for_profile_release
|
|
334
|
+
|
|
335
|
+
if not wait_for_profile_release(str(run.profile), timeout=10):
|
|
336
|
+
return "busy"
|
|
337
|
+
try:
|
|
338
|
+
run.apply()
|
|
339
|
+
except RuntimeError:
|
|
340
|
+
return "busy"
|
|
341
|
+
_signed_in_path().parent.mkdir(parents=True, exist_ok=True)
|
|
342
|
+
_write_json(_signed_in_path(), {"school": entity})
|
|
343
|
+
return "cleared"
|
|
@@ -84,6 +84,8 @@ DEFAULT_CONFIG: dict[str, Any] = {
|
|
|
84
84
|
"publisher_hourly_limit": 100,
|
|
85
85
|
# 改了上面的上限时,正在等上限的篇目是否立即按新上限接着下;false = 这一小时过后再按新上限。
|
|
86
86
|
"publisher_hourly_limit_now": False,
|
|
87
|
+
# 没权限时换下一所学校 (school_switch.py; user, 2026-11-21): on unless turned off.
|
|
88
|
+
"school_switch": True,
|
|
87
89
|
# 灰色源竞速浏览器的独立无头开关(只影响 sci-hub 竞速,机构登录仍有可见窗口)。
|
|
88
90
|
# true = 竞速全程零窗口、零任务栏闪烁;指纹安全性由 UA 清洗保证。
|
|
89
91
|
"scihub_browser_headless": False,
|
|
@@ -19,7 +19,7 @@ login_timeout login_page_closed login_credentials_rejected login_retries_exhaust
|
|
|
19
19
|
login_required verification_required institution_not_registered idp_login_error sso_required
|
|
20
20
|
idp_account_locked idp_password_expired
|
|
21
21
|
sso_redirect_stalled institution_pdf_entitlement_missing publisher_content_error publisher_unreachable
|
|
22
|
-
publisher_access_blocked
|
|
22
|
+
publisher_access_blocked publisher_download_limit
|
|
23
23
|
publisher_institution_entry_missing institution_entry_unresolved
|
|
24
24
|
publisher_temporarily_unavailable
|
|
25
25
|
challenge_or_viewer_timeout ip_blocked access_blocked pdf_not_captured
|
|
@@ -46,7 +46,7 @@ advertisement_closed pdf_step_article_page institution_choice_returned_article i
|
|
|
46
46
|
cookie_inject_failed download_capture_error elsevier_institution_entry_error
|
|
47
47
|
institution_continue institution_continue_error institution_entry_unresolved institution_federation_selected
|
|
48
48
|
institution_search_error institution_search_retyped institution_session_other idp_confirmation_accepted idp_confirmation_required
|
|
49
|
-
institution_required institution_search institution_search_submitted
|
|
49
|
+
institution_required institution_search institution_search_submitted institution_search_lost
|
|
50
50
|
institution_select_error institution_selected institution_selection_required
|
|
51
51
|
institution_session_return_article institution_session_return_error
|
|
52
52
|
ip_blocked_body ip_blocked_response karger_institution_chooser_opened
|
|
@@ -58,14 +58,14 @@ pdf_capture_started pdf_navigation_error pdf_saved pdf_state_candidate post_logi
|
|
|
58
58
|
post_login_hold_article_access post_login_hold_auth_wall post_login_hold_login_page
|
|
59
59
|
post_run_hold publisher_access_blocked publisher_content_error publisher_unreachable publisher_login_menu_opened
|
|
60
60
|
publisher_pdf_link_unverified publisher_session_save_failed publisher_session_saved
|
|
61
|
-
publisher_terms_accepted
|
|
61
|
+
publisher_terms_accepted personal_account_offer_skipped personal_account_offer_left
|
|
62
62
|
record_article_return record_article_return_error seamlessaccess_chooser_opened
|
|
63
63
|
shared_cookies_exported shared_cookies_loaded sso_entry_clicked sso_entry_error sso_start
|
|
64
64
|
access_unknown_pdf_first access_unknown_pdf_failed pdf_step_login_required login_round_trip_returned
|
|
65
65
|
pdf_probe pdf_probe_captured pdf_probe_refused no_access_after_login pdf_found_while_waiting
|
|
66
66
|
login_entry_missing login_entry_controls access_menu_opened access_menu_entry_refused access_menu_error
|
|
67
67
|
open_access_signal open_access_no_login no_institution_entry_remembered
|
|
68
|
-
article_reopen_error supplements_skipped browser_start
|
|
68
|
+
article_reopen_error supplements_skipped browser_start challenge_wait_ended
|
|
69
69
|
""".split()) | _FAILURES
|
|
70
70
|
_DETAIL_CATEGORIES = {
|
|
71
71
|
"login_observed": frozenset("""
|
|
@@ -254,9 +254,10 @@ def reader_access(lines: list[str], text: str, probe: dict) -> str:
|
|
|
254
254
|
# Short controls and labels, a whole line or a control's whole text (links in a
|
|
255
255
|
# row share a line: BMJ's "Buy this article ($64)", Thieme's "Buy Article"):
|
|
256
256
|
# "Buy article PDF 39,95 €", "Purchase PDF", "Rent this article", "Get Access",
|
|
257
|
-
# "Check Access" (journals.lww.com, Ovid)
|
|
257
|
+
# "Check Access" (journals.lww.com, Ovid); Taylor & Francis's "Purchase options *" heading over its
|
|
258
|
+
# "Issue Purchase" box, the school signed in (Scand J Rheumatol 2013, Windows 2026-11-22).
|
|
258
259
|
OFFER_LABEL = (r"(?:buy|purchase|rent)\s+(?:this\s+)?(?:article|pdf|chapter|e-?book|issue|instant access|access)\b.{0,40}"
|
|
259
|
-
r"|(?:get|check)\s+access")
|
|
260
|
+
r"|(?:get|check)\s+access|purchase options\W{0,3}|issue purchase")
|
|
260
261
|
_OFFER_LINE = re.compile(OFFER_LABEL, re.I)
|
|
261
262
|
# Sentences only a reader without access is shown, anywhere in a line.
|
|
262
263
|
_OFFER_PHRASE = re.compile(
|
|
@@ -589,6 +589,8 @@ class PublisherBatchDownloader(
|
|
|
589
589
|
result.state = "article_loaded_after_sso"
|
|
590
590
|
pdf_bytes, pdf_url, cap_block = self._capture_pdf(page, record.doi, result)
|
|
591
591
|
ip_block = ip_block or cap_block
|
|
592
|
+
else:
|
|
593
|
+
self._note_wait_end(page, result)
|
|
592
594
|
result._pdf_retry_login = False
|
|
593
595
|
if (not pdf_bytes and not ip_block and result.reason != "institution_pdf_entitlement_missing"
|
|
594
596
|
and not self._pdf_sent_to_article_after_login(page, result, attempts_from)
|
|
@@ -860,13 +862,19 @@ class PublisherBatchDownloader(
|
|
|
860
862
|
step; elsewhere the program did not reach the login, ADR 0012)."""
|
|
861
863
|
result.reason = self._login_block_reason(page) or result.reason or "sso_required"
|
|
862
864
|
result.state = result.reason
|
|
863
|
-
if result.reason
|
|
864
|
-
|
|
865
|
-
result.login_wait_page = self._login_wait_page(page)
|
|
866
|
-
self._event(result, "login_wait_ended", result.login_wait_page)
|
|
865
|
+
if result.reason in ("login_timeout", "sso_required"):
|
|
866
|
+
self._note_wait_end(page, result)
|
|
867
867
|
self._write_diagnostic(page, result, run_dir)
|
|
868
868
|
return result
|
|
869
869
|
|
|
870
|
+
def _note_wait_end(self, page: Any, result: DownloadResult) -> None:
|
|
871
|
+
"""A wait on the user that ran out: where it ended (``login_wait_page``). Also after the login a failed PDF
|
|
872
|
+
asked for (Thieme's wait ended on its school list page, JAMA's on the school's login page, and neither said
|
|
873
|
+
where: both counted as the user's, Windows 2026-11-22)."""
|
|
874
|
+
if result.reason == "login_timeout" or getattr(result, "_user_wait_expired", False):
|
|
875
|
+
result.login_wait_page = self._login_wait_page(page)
|
|
876
|
+
self._event(result, "login_wait_ended", result.login_wait_page)
|
|
877
|
+
|
|
870
878
|
def _save_captured_pdf(self, page: Any, record: PaperRecord, result: DownloadResult, run_dir: Path,
|
|
871
879
|
pdf_bytes: bytes, pdf_url: str) -> DownloadResult:
|
|
872
880
|
"""Check that a captured PDF is this article's and save it with its record."""
|
|
@@ -435,15 +435,27 @@ class AccessMixin:
|
|
|
435
435
|
|
|
436
436
|
def _is_success_article_url(self, url: str) -> bool:
|
|
437
437
|
verdict = self.adapter.is_article_page_url(url)
|
|
438
|
-
if verdict is
|
|
439
|
-
|
|
440
|
-
verdict
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
438
|
+
if verdict is None:
|
|
439
|
+
verdict = self.adapter.is_success_article_url(url)
|
|
440
|
+
if verdict is None and self.profile.success_url_markers:
|
|
441
|
+
lower = url.lower()
|
|
442
|
+
verdict = any(marker in lower for marker in self.profile.success_url_markers)
|
|
443
|
+
if verdict is None:
|
|
444
|
+
return self._names_this_article(url)
|
|
445
|
+
# A rule of the publisher's that does not take the page still yields to an address ending
|
|
446
|
+
# in this item's DOI: a rule written for the publisher's own DOI prefix missed a journal it
|
|
447
|
+
# took over, which kept its prefix (Thieme's Thrombosis and Haemostasis, 10.1160, 2026-11-22).
|
|
448
|
+
return verdict or self._address_ends_with_this_doi(url)
|
|
449
|
+
|
|
450
|
+
def _address_ends_with_this_doi(self, url: str) -> bool:
|
|
451
|
+
"""A page of the publisher's site, not a login page, whose path ends with this
|
|
452
|
+
item's DOI (as is or %2F-escaped, in any case): how article pages are addressed by
|
|
453
|
+
DOI. A PDF or a supplementary file has more after the DOI."""
|
|
454
|
+
doi = str(getattr(self, "_adapter_doi", "") or "").strip().lower()
|
|
455
|
+
if (not doi or not str(url or "").startswith("http") or not self._on_publisher_host(url)
|
|
456
|
+
or self._is_auth_page(url)):
|
|
457
|
+
return False
|
|
458
|
+
return unquote(urlparse(url).path).lower().rstrip("/").endswith("/" + doi)
|
|
447
459
|
|
|
448
460
|
def _names_this_article(self, url: str) -> bool:
|
|
449
461
|
"""The article page for a profile without article-page markers of its own
|
|
@@ -132,7 +132,7 @@ class CaptureMixin:
|
|
|
132
132
|
|
|
133
133
|
attempts = result.pdf_attempts[since:]
|
|
134
134
|
sent_back = [a for a in attempts if a.get("outcome") in self._WEB_PAGE_OUTCOMES
|
|
135
|
-
and plain(a.get("final_url")) != plain(a.get("url"))
|
|
135
|
+
and (plain(a.get("final_url")) != plain(a.get("url")) or self.adapter.pdf_address_shows_article_page)
|
|
136
136
|
and self._is_success_article_url(str(a.get("final_url") or ""))]
|
|
137
137
|
url = str(getattr(page, "url", "") or "")
|
|
138
138
|
if (not sent_back or not self._school_login_done()
|
|
@@ -1268,11 +1268,43 @@ class CaptureMixin:
|
|
|
1268
1268
|
self._event(result, "pdf_attempt",
|
|
1269
1269
|
f"{entry['how']} {entry['url'][:160]} -> {outcome}; {entry['status'] or '-'} "
|
|
1270
1270
|
f"{entry['type'] or '-'} {entry['size'] or '-'} bytes; ended at {final[:160]}; {entry['seconds']} s")
|
|
1271
|
+
if outcome != "pdf ok":
|
|
1272
|
+
self._note_download_limit(page, result)
|
|
1271
1273
|
if outcome != "pdf ok" and not any(s["why"] == "pdf attempt failed" for s in result.snapshots):
|
|
1272
1274
|
self._snapshot(page, result, "pdf attempt failed")
|
|
1273
1275
|
except Exception as exc: # the record never ends the capture
|
|
1274
1276
|
self._event(result, "pdf_attempt_record_error", f"{type(exc).__name__}: {str(exc)[:160]}")
|
|
1275
1277
|
|
|
1278
|
+
# The text of the dialogs over the page (a react-modal's content is role="dialog").
|
|
1279
|
+
_DIALOG_TEXT_JS = """() => [...document.querySelectorAll(
|
|
1280
|
+
'[role="dialog"], [role="alertdialog"], [aria-modal="true"], dialog[open], .ReactModal__Content')]
|
|
1281
|
+
.filter(el => el.getClientRects().length > 0)
|
|
1282
|
+
.map(el => el.innerText || '').join(' ').slice(0, 2000)"""
|
|
1283
|
+
# A site's notice that the reader has used up its downloads for now.
|
|
1284
|
+
_DOWNLOAD_LIMIT = re.compile(
|
|
1285
|
+
r"download limit|(?:exceeded|reached)\b.{0,60}\bdownloads?\b|too many (?:pdf )?downloads"
|
|
1286
|
+
r"|下载.{0,8}(?:达到|超过|超出).{0,4}(?:上限|限额|限制)", re.I | re.S)
|
|
1287
|
+
|
|
1288
|
+
def _note_download_limit(self, page: Any, result: DownloadResult) -> None:
|
|
1289
|
+
"""A PDF attempt that got no PDF, with a dialog over the page saying the downloads
|
|
1290
|
+
are used up (ScienceDirect's "You have reached the daily bulk download limit" after
|
|
1291
|
+
its View PDF, 2026-11-21: 381 articles of one journal that day). Kept on the result:
|
|
1292
|
+
if the article ends without its PDF, that is why (bridge ``_failure_reason_code``).
|
|
1293
|
+
Read only from dialogs, not the article's own text."""
|
|
1294
|
+
if getattr(result, "_download_limit", ""):
|
|
1295
|
+
return
|
|
1296
|
+
try:
|
|
1297
|
+
said = " ".join(str(page.evaluate(self._DIALOG_TEXT_JS) or "").split())
|
|
1298
|
+
except Exception:
|
|
1299
|
+
return
|
|
1300
|
+
found = self._DOWNLOAD_LIMIT.search(said)
|
|
1301
|
+
if not found:
|
|
1302
|
+
return
|
|
1303
|
+
quoted = said[max(0, found.start() - 80):found.end() + 40]
|
|
1304
|
+
result._download_limit = quoted
|
|
1305
|
+
host = urlparse(str(getattr(page, "url", "") or "")).hostname or ""
|
|
1306
|
+
self._event(result, "publisher_download_limit", f'{host}: "{quoted[:200]}"')
|
|
1307
|
+
|
|
1276
1308
|
# Every link's address, label and visibility in one round trip: asking per
|
|
1277
1309
|
# link took ~25 s on a Nature page with hundreds of links.
|
|
1278
1310
|
_LINKS_JS = """() => [...document.querySelectorAll('a[href]')].map(a => ({
|
|
@@ -1750,7 +1782,9 @@ class CaptureMixin:
|
|
|
1750
1782
|
# not use up the PDF step, and once the check clears the PDF
|
|
1751
1783
|
# gets its full time again.
|
|
1752
1784
|
challenge_deadline = time.time() + max(self.page_wait_sec, timeout_sec)
|
|
1753
|
-
|
|
1785
|
+
# The PDF's answer can arrive while the tab still shows the check.
|
|
1786
|
+
arrived = (lambda: bool(captured.get("bytes"))) if captured is not None else None
|
|
1787
|
+
if not self._wait_for_challenge_with_deadline(page, result, challenge_deadline, until=arrived):
|
|
1754
1788
|
return None, str(getattr(page, "url", "") or "")
|
|
1755
1789
|
deadline = time.time() + timeout_sec
|
|
1756
1790
|
attempted.clear()
|
|
@@ -89,7 +89,7 @@ class DiagnosticsMixin:
|
|
|
89
89
|
"institution_search_submitted", "institution_search_retyped",
|
|
90
90
|
"institution_list_submitted", "institution_continue",
|
|
91
91
|
"login_round_trip_returned", "redirect_page_passed",
|
|
92
|
-
"publisher_terms_accepted", "idp_confirmation_accepted",
|
|
92
|
+
"publisher_terms_accepted", "idp_confirmation_accepted", "personal_account_offer_skipped",
|
|
93
93
|
}:
|
|
94
94
|
activity.progress()
|
|
95
95
|
# Only publish fixed phase text; event details can contain signed URLs.
|