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
|
@@ -98,9 +98,11 @@ class InstitutionMixin:
|
|
|
98
98
|
here = str(getattr(page, "url", "") or "")
|
|
99
99
|
if self._school_choices_here(result, here) >= self.SCHOOL_CHOICE_REPEATS:
|
|
100
100
|
return self._after_repeated_school_choice(page, result, here)
|
|
101
|
-
# The OpenAthens wayfinder goes straight to the school's entity
|
|
102
|
-
#
|
|
103
|
-
|
|
101
|
+
# The OpenAthens wayfinder goes straight to the school's entity, also for a federation's school the
|
|
102
|
+
# publisher sends there (LWW's Ovid, Windows 2026-11-22): its search took 40 s, and a school the wayfinder
|
|
103
|
+
# remembered ("Access through <another school>") left the login waiting a minute. The entityID was what
|
|
104
|
+
# its search came to anyway, its CARSI sign-in beside its library's OpenAthens account.
|
|
105
|
+
if self._select_openathens_wayfinder(page, result):
|
|
104
106
|
return True
|
|
105
107
|
# Everything except human verification and the user's credentials is
|
|
106
108
|
# automated once an institution is configured: a remembered
|
|
@@ -154,6 +156,7 @@ class InstitutionMixin:
|
|
|
154
156
|
try:
|
|
155
157
|
inp = page.locator(selector).first
|
|
156
158
|
if inp.is_visible(timeout=5_000):
|
|
159
|
+
self._clear_before_typing(page, result)
|
|
157
160
|
inp.fill(self._typed_school_name())
|
|
158
161
|
self._event(result, "institution_search", selector)
|
|
159
162
|
settle(page, 2_000)
|
|
@@ -298,8 +301,18 @@ class InstitutionMixin:
|
|
|
298
301
|
return select, hits[0][0], hits[0][1]
|
|
299
302
|
return None
|
|
300
303
|
|
|
301
|
-
|
|
302
|
-
|
|
304
|
+
# A list of societies to sign in through ("Select your society"; BMJ's #society-login-select, Windows 2026-11-22):
|
|
305
|
+
# not a list of schools, whatever its names ("... College of Sport and Exercise Physicians") or values (addresses).
|
|
306
|
+
_SOCIETY_LIST = re.compile(r"societ", re.I)
|
|
307
|
+
|
|
308
|
+
@classmethod
|
|
309
|
+
def _society_list(cls, select: dict) -> bool:
|
|
310
|
+
options = [o for o in select.get("options") or () if isinstance(o, (list, tuple)) and len(o) == 2]
|
|
311
|
+
return bool(cls._SOCIETY_LIST.search(str(select.get("name") or ""))
|
|
312
|
+
or (options and cls._SOCIETY_LIST.search(str(options[0][1]))))
|
|
313
|
+
|
|
314
|
+
@classmethod
|
|
315
|
+
def _filled_lists(cls, lists: Any, federation: dict) -> dict:
|
|
303
316
|
"""Filled school lists, not the header's journal/language/search lists.
|
|
304
317
|
|
|
305
318
|
Only positive institution evidence can establish that a school is
|
|
@@ -308,7 +321,7 @@ class InstitutionMixin:
|
|
|
308
321
|
"""
|
|
309
322
|
school = re.compile(r"institut|school|universit|\buniv\b|college|organi[sz]ation|\bidp\b|大学|学院|研究院", re.I)
|
|
310
323
|
return {str(s.get("name")): list(s.get("options") or ()) for s in lists or ()
|
|
311
|
-
if s.get("i") != federation.get("i") and len(s.get("options") or ()) > 1
|
|
324
|
+
if s.get("i") != federation.get("i") and len(s.get("options") or ()) > 1 and not cls._society_list(s)
|
|
312
325
|
and (school.search(str(s.get("name") or "")) or any(
|
|
313
326
|
school.search(str(o[1])) for o in s.get("options") or ()
|
|
314
327
|
if isinstance(o, (list, tuple)) and len(o) == 2))}
|
|
@@ -445,8 +458,9 @@ class InstitutionMixin:
|
|
|
445
458
|
|
|
446
459
|
def _entity_lists(self, lists: Any) -> dict:
|
|
447
460
|
return {str(s.get("name")): list(s.get("options") or ()) for s in lists or ()
|
|
448
|
-
if
|
|
449
|
-
|
|
461
|
+
if not self._society_list(s)
|
|
462
|
+
and sum(1 for o in s.get("options") or () if isinstance(o, (list, tuple)) and len(o) == 2
|
|
463
|
+
and self._ENTITY_VALUE.match(str(o[0]))) >= self.ENTITY_LIST_MIN}
|
|
450
464
|
|
|
451
465
|
def _check_entity_list(self, page: Any, result: DownloadResult, lists: list[dict], url: str) -> None:
|
|
452
466
|
"""A filled list of schools by entityID without the configured school, the same a
|
|
@@ -636,16 +650,17 @@ class InstitutionMixin:
|
|
|
636
650
|
|
|
637
651
|
_ENTRY_SELECTOR = "li, a, button, [role=option], [role=button]"
|
|
638
652
|
|
|
639
|
-
# An entry's own identifiers: its link
|
|
640
|
-
#
|
|
641
|
-
# entry (Elsevier keeps each result's entityID in a hidden
|
|
653
|
+
# An entry's own identifiers: its link, its onclick (JAMA's search entries name their entityID
|
|
654
|
+
# only there, 2026-11-17) and data attributes, and the hidden fields and data attributes of the
|
|
655
|
+
# elements around it that hold no other entry (Elsevier keeps each result's entityID in a hidden
|
|
656
|
+
# field, 2026-10-31).
|
|
642
657
|
_ENTRIES_JS = """(sel) => {
|
|
643
658
|
const all = [...document.querySelectorAll(sel)];
|
|
644
659
|
const visible = el => el.getClientRects().length > 0 && getComputedStyle(el).visibility !== 'hidden';
|
|
645
660
|
const cands = all.filter(visible);
|
|
646
661
|
const inner = cands.filter(el => !cands.some(o => o !== el && el.contains(o)));
|
|
647
662
|
const ids = el => {
|
|
648
|
-
const out = [el.href || el.getAttribute('href') || ''];
|
|
663
|
+
const out = [el.href || el.getAttribute('href') || '', el.getAttribute('onclick') || ''];
|
|
649
664
|
for (let row = el, up = 0; row && up < 4; up++) {
|
|
650
665
|
for (const a of row.attributes || []) if (a.name.startsWith('data-')) out.push(a.value);
|
|
651
666
|
for (const h of row.querySelectorAll('input[type=hidden]')) out.push(h.value || '');
|
|
@@ -660,10 +675,47 @@ class InstitutionMixin:
|
|
|
660
675
|
.filter(it => it.t && it.t.length <= 160);
|
|
661
676
|
}"""
|
|
662
677
|
|
|
678
|
+
def _users_own_search(self, page: Any) -> bool:
|
|
679
|
+
"""A shown institution search box holding text the program did not type: the user is choosing."""
|
|
680
|
+
queries = {" ".join(q.split()).lower() for q in self._search_queries(list(self._institution_names()))}
|
|
681
|
+
for selector in self._INSTITUTION_INPUTS: # the institution boxes only, the page not read for them
|
|
682
|
+
try:
|
|
683
|
+
boxes = page.locator(selector).all()
|
|
684
|
+
if not isinstance(boxes, list):
|
|
685
|
+
continue
|
|
686
|
+
for box in boxes[:4]:
|
|
687
|
+
if box.is_visible(timeout=300) is not True:
|
|
688
|
+
continue
|
|
689
|
+
value = " ".join(str(box.input_value(timeout=800) or "").split()).lower()
|
|
690
|
+
if value and value not in queries:
|
|
691
|
+
return True
|
|
692
|
+
except Exception as exc:
|
|
693
|
+
if not _is_browser_error(exc):
|
|
694
|
+
raise
|
|
695
|
+
return False
|
|
696
|
+
|
|
663
697
|
def _institution_entry_score(self, entry: dict, entity_id: str) -> int:
|
|
664
|
-
|
|
698
|
+
ids = str(entry.get("ids") or "")
|
|
699
|
+
if self._carries_entity_id(ids, entity_id):
|
|
665
700
|
return 4
|
|
666
|
-
|
|
701
|
+
score = self._institution_match_score(entry.get("t", ""))
|
|
702
|
+
if score >= 2 and self._names_another_sign_in(ids, entity_id):
|
|
703
|
+
return 1 # the school's name, another sign-in than the saved one: not clicked
|
|
704
|
+
return score
|
|
705
|
+
|
|
706
|
+
# The sign-in an entry names: Atypon's /action/ssostart?idp=<entityID>, SeamlessAccess's
|
|
707
|
+
# saveInstitution(this, '<entityID>') in its onclick (JAMA's search, 2026-11-17).
|
|
708
|
+
_ENTRY_IDP = re.compile(r"[?&]idp=([^&#\s\"']+)|saveInstitution\(\s*[^,()]*,\s*['\"]([^'\"]+)['\"]", re.I)
|
|
709
|
+
|
|
710
|
+
def _names_another_sign_in(self, text: str, entity_id: str) -> bool:
|
|
711
|
+
"""An entry's link names an identity provider, and not the school's saved one (Sage listed a test school with
|
|
712
|
+
idp=<its library's OpenAthens entityID>, which sent the login straight back to the article, while its saved
|
|
713
|
+
Shibboleth entityID signs in elsewhere; Windows 2026-11-22)."""
|
|
714
|
+
if not entity_id or not text:
|
|
715
|
+
return False
|
|
716
|
+
named = {unquote(unquote(link or saved)).strip().lower() for link, saved in self._ENTRY_IDP.findall(text)}
|
|
717
|
+
named = {value for value in named if value.startswith(("https://", "http://", "urn:"))}
|
|
718
|
+
return bool(named) and entity_id.strip().lower() not in named
|
|
667
719
|
|
|
668
720
|
def _name_residue(self, text: str) -> str | None:
|
|
669
721
|
"""What is left of ``text`` (lower case) once the school's names are taken
|
|
@@ -777,6 +829,11 @@ class InstitutionMixin:
|
|
|
777
829
|
recorded, url = unquote(str(recorded or "")), unquote(str(url or ""))
|
|
778
830
|
return len(recorded) > 10 and url.startswith(recorded)
|
|
779
831
|
|
|
832
|
+
def _searched_here(self, result: DownloadResult, url: str) -> bool:
|
|
833
|
+
"""The school's name was typed into a search on the page at ``url``."""
|
|
834
|
+
return any(e.get("state") == "auto_institution_search"
|
|
835
|
+
and self._same_address(str(e.get("detail", "")).split(" @ ", 1)[-1], url) for e in result.events)
|
|
836
|
+
|
|
780
837
|
def _search_queries(self, names: list[str]) -> list[str]:
|
|
781
838
|
"""The school's names to search by (straight apostrophes): its English name
|
|
782
839
|
first, then the others in Latin letters, its shared login entry's own name
|
|
@@ -835,6 +892,8 @@ class InstitutionMixin:
|
|
|
835
892
|
if (not settled and not chosen and not getattr(result, "_institution_not_listed", False)
|
|
836
893
|
and time.time() - float(getattr(result, "_search_typed_at", 0) or 0) >= self.SEARCH_NOTHING_SEC
|
|
837
894
|
and (self._search_list_closed(page, result, url) or not self._entry_texts(page) - before)):
|
|
895
|
+
if self._retype_lost_search(page, result, url, tried[-1]):
|
|
896
|
+
return True
|
|
838
897
|
result._institution_not_listed = True
|
|
839
898
|
self._event(result, "institution_search_found_nothing", f"{', '.join(tried)[:120]} @ {url[:200]}")
|
|
840
899
|
return False
|
|
@@ -852,6 +911,7 @@ class InstitutionMixin:
|
|
|
852
911
|
if settled:
|
|
853
912
|
self._event(result, "institution_search_retry_skipped", f"box holds {value[:60]!r} @ {url[:200]}")
|
|
854
913
|
return False
|
|
914
|
+
self._clear_before_typing(page, result)
|
|
855
915
|
box.fill("")
|
|
856
916
|
box.press_sequentially(left[0], delay=40)
|
|
857
917
|
except Exception as exc:
|
|
@@ -867,6 +927,41 @@ class InstitutionMixin:
|
|
|
867
927
|
self._event(result, "auto_institution_search", f"{left[0]} @ {url}")
|
|
868
928
|
return True
|
|
869
929
|
|
|
930
|
+
def _clear_before_typing(self, page: Any, result: DownloadResult | None) -> None:
|
|
931
|
+
"""Before the school's name is typed into a page, wherever: a cookie banner over it answered first
|
|
932
|
+
(``_dismiss_cookie_banners``). One keeping the focus takes the keys typed behind it (Springer Nature's
|
|
933
|
+
chooser, 2026-11-22: the box stayed empty and the school was said not listed); the school's and the
|
|
934
|
+
federations' own pages stay as they are."""
|
|
935
|
+
if self._dismiss_cookie_banners(page, result):
|
|
936
|
+
settle(page, 1_000)
|
|
937
|
+
|
|
938
|
+
def _retype_lost_search(self, page: Any, result: DownloadResult, url: str, query: str) -> bool:
|
|
939
|
+
"""Before the school is said not listed: the box typed in is empty, nothing chosen or
|
|
940
|
+
answered there, so the keys went elsewhere (a cookie banner over Springer Nature's chooser
|
|
941
|
+
took them, 2026-11-22). Any banner answered, the name is typed again, once per page. True
|
|
942
|
+
when typed; a box holding anything is left as it is."""
|
|
943
|
+
box_at = getattr(result, "_search_box", None)
|
|
944
|
+
if (not query or not isinstance(box_at, tuple)
|
|
945
|
+
or any(e["state"] == "institution_search_lost"
|
|
946
|
+
and self._same_address(str(e.get("detail", "")).partition(" @ ")[2], url) for e in result.events)):
|
|
947
|
+
return False
|
|
948
|
+
try:
|
|
949
|
+
box = page.locator(f"[{self._SEARCH_BOX_MARK}]").first
|
|
950
|
+
if box.is_visible(timeout=500) is not True:
|
|
951
|
+
box = page.locator(box_at[1]).first
|
|
952
|
+
if box.is_visible(timeout=500) is not True or str(box.input_value(timeout=2_000) or "").strip():
|
|
953
|
+
return False
|
|
954
|
+
self._clear_before_typing(page, result)
|
|
955
|
+
box.fill("")
|
|
956
|
+
box.press_sequentially(query, delay=40)
|
|
957
|
+
except Exception as exc:
|
|
958
|
+
if not _is_browser_error(exc):
|
|
959
|
+
raise
|
|
960
|
+
return False
|
|
961
|
+
result._search_typed_at = time.time()
|
|
962
|
+
self._event(result, "institution_search_lost", f"{query} @ {url}")
|
|
963
|
+
return True
|
|
964
|
+
|
|
870
965
|
def _search_list_closed(self, page: Any, result: DownloadResult, url: str) -> bool:
|
|
871
966
|
"""The search box typed in says its list is closed (``aria-expanded="false"``):
|
|
872
967
|
no results are shown, whatever else the page lists (2026-11-13: a search
|
|
@@ -926,11 +1021,12 @@ class InstitutionMixin:
|
|
|
926
1021
|
|
|
927
1022
|
An entry carrying the school's entityID wins (several such entries are
|
|
928
1023
|
the same school); otherwise the entry naming it. Only innermost
|
|
929
|
-
candidates count (a list item and its link are one entry).
|
|
930
|
-
with the same best name score
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
1024
|
+
candidates count (a list item and its link are one entry). Several entries
|
|
1025
|
+
with the same best name score are taken one after another, the orchestrator's
|
|
1026
|
+
``institution_entry_turn`` saying which (user, 2026-11-22); only partial
|
|
1027
|
+
matches are left to the user; the same text with the same link (an actual
|
|
1028
|
+
link, not two buttons) is one school (SAMS Sigma's "Recently Chosen" above
|
|
1029
|
+
its full list, 2026-11-01).
|
|
934
1030
|
"""
|
|
935
1031
|
try:
|
|
936
1032
|
items = self._listed_entries(page)
|
|
@@ -941,6 +1037,17 @@ class InstitutionMixin:
|
|
|
941
1037
|
entity_id = self._entity_id()
|
|
942
1038
|
|
|
943
1039
|
scored = [(self._institution_entry_score(it, entity_id), it) for it in items if isinstance(it, dict)]
|
|
1040
|
+
# The school's name with another of its sign-ins than the saved one (its library's OpenAthens account beside
|
|
1041
|
+
# its CARSI sign-in: all Sage and JAMA list of a test school, its login page asking for a picture code; Windows
|
|
1042
|
+
# 2026-11-22). On such a page an entry by the school's name carrying nothing to tell its sign-in by may be that
|
|
1043
|
+
# one too (Sage's "Recent institution": what SeamlessAccess kept of an earlier choice of it): not clicked either.
|
|
1044
|
+
another = [it for score, it in scored if score == 1 and self._names_another_sign_in(str(it.get("ids") or ""), entity_id)
|
|
1045
|
+
and self._institution_match_score(str(it.get("t") or "")) >= 2]
|
|
1046
|
+
if another:
|
|
1047
|
+
result._another_sign_in_at = url
|
|
1048
|
+
another_here = bool(another) or self._same_address(str(getattr(result, "_another_sign_in_at", "") or ""), url)
|
|
1049
|
+
if another_here and not any(score == 4 for score, _ in scored):
|
|
1050
|
+
scored = [(1 if score >= 2 and not str(it.get("ids") or "").strip() else score, it) for score, it in scored]
|
|
944
1051
|
if self.federation is not None:
|
|
945
1052
|
# An entry its publisher marks as signing in no school (Elsevier's
|
|
946
1053
|
# entries carry their route: IP, VPN or a work email, no entityID) is
|
|
@@ -949,15 +1056,18 @@ class InstitutionMixin:
|
|
|
949
1056
|
and self.adapter.institution_entry_signs_in(unquote(str(it.get("ids") or ""))) is False]
|
|
950
1057
|
if without:
|
|
951
1058
|
scored = [(score, it) for score, it in scored if not any(it is w for w in without)]
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
result
|
|
960
|
-
|
|
1059
|
+
# Listed only so, the school has no route here: 没权限, another saved school tried at a batch's end.
|
|
1060
|
+
if (without or another_here) and not any(score >= 2 for score, _ in scored):
|
|
1061
|
+
if not self._list_settled(result, items):
|
|
1062
|
+
return False # the search may still be adding entries
|
|
1063
|
+
if getattr(result, "_institution_not_listed", False) is not True: # once, not every pass
|
|
1064
|
+
count = len(without) or max(len(another), 1)
|
|
1065
|
+
kind = "without a school sign-in" if without else "with another of its sign-ins"
|
|
1066
|
+
self._event(result, "auto_institution_not_found",
|
|
1067
|
+
f"{self.institution_query} (listed only {kind}: "
|
|
1068
|
+
f"{count} entr{'y' if count == 1 else 'ies'}) @ {url}")
|
|
1069
|
+
result._institution_not_listed = True
|
|
1070
|
+
return False
|
|
961
1071
|
top = max([score for score, _ in scored] or [0])
|
|
962
1072
|
best = [it for score, it in scored if score == top]
|
|
963
1073
|
if top < 2 and self.federation is not None and self._search_lists_no_school(page, result, url, scored):
|
|
@@ -979,8 +1089,27 @@ class InstitutionMixin:
|
|
|
979
1089
|
# configured sign-in, by its entityID, the one this browser keeps the session of.
|
|
980
1090
|
if top >= 2 and len(best) > 1 and self._select_openathens_wayfinder(page, result):
|
|
981
1091
|
return True
|
|
1092
|
+
if top < 2 or len(best) < 2 or self._users_own_search(page):
|
|
1093
|
+
return False # the user typing a search of their own chooses (typed input is never replaced)
|
|
1094
|
+
# Several entries by the school's name, nothing else to tell them apart by (JAMA's search: a test school's name
|
|
1095
|
+
# two or three times, its CARSI sign-in and its library's proxy, Windows 2026-11-22): one after another in
|
|
1096
|
+
# the page's order, the next when the one before did not do (user, 2026-11-18 and 2026-11-22; the turn is
|
|
1097
|
+
# the orchestrator's, ``institution_entry_turn``).
|
|
1098
|
+
turn = int(self.config.get("institution_entry_turn") or 0)
|
|
1099
|
+
result._same_name_entries = len(best)
|
|
1100
|
+
if turn >= len(best):
|
|
1101
|
+
return False
|
|
1102
|
+
target = best[turn]
|
|
1103
|
+
self._event(result, "institution_same_name_choice",
|
|
1104
|
+
f"{turn + 1}/{len(best)}: {str(target.get('t') or '')[:60]} @ {url[:200]}")
|
|
1105
|
+
else:
|
|
1106
|
+
target = best[0]
|
|
1107
|
+
if (top in (2, 3) and entity_id and not str(target.get("ids") or "").strip()
|
|
1108
|
+
and self._searched_here(result, url) and not self._list_settled(result, items)):
|
|
1109
|
+
# An entry by the school's name carrying nothing to tell its sign-in by, where its name was searched: taken
|
|
1110
|
+
# once the list has settled, the search's own entries (each with its sign-in) shown by then (Sage's "Recent
|
|
1111
|
+
# institution" was clicked a second before its search showed that entry's other sign-in, Windows 2026-11-22).
|
|
982
1112
|
return False
|
|
983
|
-
target = best[0]
|
|
984
1113
|
before = str(getattr(page, "url", "") or "")
|
|
985
1114
|
try:
|
|
986
1115
|
marked = page.evaluate("""([sel, idx]) => {
|
|
@@ -1194,6 +1323,17 @@ class InstitutionMixin:
|
|
|
1194
1323
|
label = re.sub(r"^\s*access through\s*", "", candidate["text"], flags=re.I)
|
|
1195
1324
|
entries.append((self._institution_match_score(label), label,
|
|
1196
1325
|
page.locator(f'[data-paper-search-remembered="{candidate["i"]}"]')))
|
|
1326
|
+
# A remembered entry whose link names another sign-in than the school's saved one: not clicked (Sage's
|
|
1327
|
+
# "Access through <the school>", idp=.../entity, sent the login straight back, Windows 2026-11-22).
|
|
1328
|
+
def link_of(entry: Any) -> str:
|
|
1329
|
+
try:
|
|
1330
|
+
return str(entry.get_attribute("href", timeout=1_000) or "")
|
|
1331
|
+
except Exception as exc:
|
|
1332
|
+
if not _is_browser_error(exc):
|
|
1333
|
+
raise
|
|
1334
|
+
return ""
|
|
1335
|
+
entries = [(1 if score >= 2 and self._names_another_sign_in(link_of(entry), self._entity_id()) else score,
|
|
1336
|
+
label, entry) for score, label, entry in entries]
|
|
1197
1337
|
top = max((score for score, _, _ in entries), default=0)
|
|
1198
1338
|
best = [(label, entry) for score, label, entry in entries if score == top]
|
|
1199
1339
|
if top >= 2 and len(best) == 1:
|
|
@@ -1229,6 +1369,7 @@ class InstitutionMixin:
|
|
|
1229
1369
|
continue
|
|
1230
1370
|
if str(box.input_value(timeout=2_000) or "").strip():
|
|
1231
1371
|
return False # the user is typing; never replace it
|
|
1372
|
+
self._clear_before_typing(page, result)
|
|
1232
1373
|
# Marked before typing: a box found by its placeholder loses it once it holds a
|
|
1233
1374
|
# name, and the next name is typed into it again (Science, 2026-11-17).
|
|
1234
1375
|
box.evaluate(f"el => el.setAttribute('{self._SEARCH_BOX_MARK}', '')")
|
|
@@ -1351,6 +1492,7 @@ class InstitutionMixin:
|
|
|
1351
1492
|
continue
|
|
1352
1493
|
if (box.input_value(timeout=2_000) or "").strip():
|
|
1353
1494
|
return False # the user already typed; never overwrite
|
|
1495
|
+
self._clear_before_typing(page, result)
|
|
1354
1496
|
box.fill(self._typed_school_name())
|
|
1355
1497
|
self._event(result, "institution_search", f"{federation.code}:{selector}")
|
|
1356
1498
|
pump_until(page, lambda: self._any_visible(page, self._institution_result_selectors()), 2_000)
|
|
@@ -729,7 +729,8 @@ class LoginMixin:
|
|
|
729
729
|
continue
|
|
730
730
|
if self._return_from_login_site(page, result):
|
|
731
731
|
continue
|
|
732
|
-
if self._accept_publisher_terms(page, result) or self._accept_idp_confirmation(page, result)
|
|
732
|
+
if (self._accept_publisher_terms(page, result) or self._accept_idp_confirmation(page, result)
|
|
733
|
+
or self._skip_personal_account_offer(page, result)):
|
|
733
734
|
continue
|
|
734
735
|
if manual_selection:
|
|
735
736
|
if self._is_challenge_page(page):
|
|
@@ -905,6 +906,69 @@ class LoginMixin:
|
|
|
905
906
|
settle(page, 2_000)
|
|
906
907
|
return True
|
|
907
908
|
|
|
909
|
+
# After the school's sign-in, the publisher's offer of an account of the user's own (Elsevier ID's
|
|
910
|
+
# "Personalize your experience. We now know you're from <school>. … enter your email to sign in or
|
|
911
|
+
# create an Elsevier account", 2026-11-22, once the browser kept no Elsevier account's sign-in): the
|
|
912
|
+
# school's access needs none, so it is skipped (user, 2026-11-22). Its empty email field, and a
|
|
913
|
+
# "Skip", "Not now" or "No thanks", else its close (×), marked for the click.
|
|
914
|
+
_ACCOUNT_OFFER_JS = r"""() => {
|
|
915
|
+
const shown = el => !!el && el.getClientRects().length > 0 && getComputedStyle(el).visibility !== 'hidden';
|
|
916
|
+
const words = el => [el.innerText || el.value || '', el.getAttribute('aria-label') || '', el.getAttribute('title') || '']
|
|
917
|
+
.join(' ').replace(/\s+/g, ' ').trim();
|
|
918
|
+
const body = ((document.body && document.body.innerText) || '').replace(/\s+/g, ' ').slice(0, 4000);
|
|
919
|
+
const OFFER = /personali[sz]e your experience|\b(?:sign|log) in or (?:create|register)\b|\bcreate (?:an?|your)(?: free)?(?: [\w-]+)? account\b|\bregister for (?:an?|your)(?: free)? account\b|创建(?:个人)?账[号户]|注册(?:个人)?账[号户]/i;
|
|
920
|
+
if (!OFFER.test(body)) return null;
|
|
921
|
+
const email = [...document.querySelectorAll('input')].filter(el => shown(el) && !el.disabled && !el.readOnly
|
|
922
|
+
&& (el.type === 'email' || /e-?mail|邮箱/i.test([el.name, el.id, el.autocomplete, el.placeholder,
|
|
923
|
+
el.getAttribute('aria-label'), el.labels && [...el.labels].map(l => l.innerText).join(' ')].join(' '))));
|
|
924
|
+
if (!email.length || email.some(el => String(el.value || '').length > 0)) return null; // someone typing: theirs
|
|
925
|
+
const controls = [...document.querySelectorAll('button, a, [role="button"], input[type="button"], input[type="submit"]')]
|
|
926
|
+
.filter(el => shown(el) && !el.disabled);
|
|
927
|
+
const SKIP = /^(?:skip(?: for now| this step)?|not now|no,? thanks?|maybe later|remind me later|later|continue without(?: an?)?(?: account| signing in| sign-?in| registering)|continue as (?:a )?guest|跳过|暂不|以后再说|稍后再说)$/i;
|
|
928
|
+
const named = el => `${el.getAttribute('aria-label') || ''} ${el.getAttribute('title') || ''}`;
|
|
929
|
+
let kind = 'skip', pick = controls.find(el => SKIP.test(words(el)));
|
|
930
|
+
if (!pick) {
|
|
931
|
+
kind = 'close';
|
|
932
|
+
pick = controls.find(el => /^(?:close|dismiss|关闭|[×✕✖xX])$/i.test((el.innerText || el.value || '').trim())
|
|
933
|
+
|| /\bclose\b|\bdismiss\b|关闭/i.test(named(el))
|
|
934
|
+
|| (!(el.innerText || '').trim() && /(?:^|[-_ ])close(?:$|[-_ ])/i.test(`${el.id} ${el.getAttribute('class') || ''}`)));
|
|
935
|
+
}
|
|
936
|
+
if (pick) pick.setAttribute('data-papersearch-offer', '1');
|
|
937
|
+
const heading = ((document.querySelector('h1, h2') || {}).innerText || '').replace(/\s+/g, ' ').trim();
|
|
938
|
+
return {kind: pick ? kind : '', label: pick ? words(pick).slice(0, 60) : '', heading: heading.slice(0, 80)};
|
|
939
|
+
}"""
|
|
940
|
+
ACCOUNT_OFFER_SKIPS = 2
|
|
941
|
+
|
|
942
|
+
def _skip_personal_account_offer(self, page: Any, result: DownloadResult) -> bool:
|
|
943
|
+
"""After the school's sign-in, on the publisher's site or its sign-in service: skip its offer
|
|
944
|
+
of a personal account (``_ACCOUNT_OFFER_JS``). Still offered after ``ACCOUNT_OFFER_SKIPS``
|
|
945
|
+
clicks, or with nothing to skip it by, the article is opened again, once. True when done."""
|
|
946
|
+
url = str(getattr(page, "url", "") or "")
|
|
947
|
+
if (not self._school_login_done() or not (self._on_publisher_host(url) or self._is_auth_page(url))
|
|
948
|
+
or self._is_idp_host(urlparse(url).netloc) or self._on_school_login_page(url)):
|
|
949
|
+
return False
|
|
950
|
+
try:
|
|
951
|
+
offer = page.evaluate(self._ACCOUNT_OFFER_JS)
|
|
952
|
+
except Exception as exc:
|
|
953
|
+
if not _is_browser_error(exc):
|
|
954
|
+
raise
|
|
955
|
+
return False
|
|
956
|
+
if not isinstance(offer, dict):
|
|
957
|
+
return False
|
|
958
|
+
where = f"{offer.get('heading') or ''} @ {url[:160]}"
|
|
959
|
+
skips = sum(e["state"] == "personal_account_offer_skipped" for e in result.events)
|
|
960
|
+
if offer.get("kind") and skips < self.ACCOUNT_OFFER_SKIPS and self._click_control(
|
|
961
|
+
page, page.locator('[data-papersearch-offer="1"]').first, result, "skip the publisher's account offer"):
|
|
962
|
+
self._event(result, "personal_account_offer_skipped", f"{offer['kind']} \"{offer.get('label') or ''}\" | {where}")
|
|
963
|
+
settle(page, 3_000)
|
|
964
|
+
return True
|
|
965
|
+
if not result.article_url or any(e["state"] == "personal_account_offer_left" for e in result.events):
|
|
966
|
+
return False
|
|
967
|
+
open_page(page, result.article_url, timeout_ms=60_000)
|
|
968
|
+
self._event(result, "personal_account_offer_left", where)
|
|
969
|
+
settle(page, 3_000)
|
|
970
|
+
return True
|
|
971
|
+
|
|
908
972
|
# The school's IdP asking to agree before it goes on (Shibboleth's attribute
|
|
909
973
|
# release and terms of use): accepted for the user too, as they asked
|
|
910
974
|
# (2026-11-08). The release keeps the choices the school preselected; the
|
|
@@ -7,6 +7,7 @@ from __future__ import annotations
|
|
|
7
7
|
import inspect
|
|
8
8
|
import re
|
|
9
9
|
import time
|
|
10
|
+
from collections.abc import Callable
|
|
10
11
|
from contextlib import ExitStack
|
|
11
12
|
from typing import Any
|
|
12
13
|
from urllib.parse import urlparse
|
|
@@ -24,17 +25,21 @@ class UserWaitMixin:
|
|
|
24
25
|
page: Any,
|
|
25
26
|
result: DownloadResult,
|
|
26
27
|
deadline: float,
|
|
28
|
+
until: Callable[[], bool] | None = None,
|
|
27
29
|
) -> bool:
|
|
30
|
+
"""``until``: what the wait is for has arrived behind the verification page
|
|
31
|
+
(``_wait_for_challenge``)."""
|
|
28
32
|
try:
|
|
29
33
|
signature = inspect.signature(self._wait_for_challenge)
|
|
30
34
|
except (TypeError, ValueError):
|
|
31
35
|
return self._wait_for_challenge(page, result)
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
any_keyword = any(param.kind == inspect.Parameter.VAR_KEYWORD for param in signature.parameters.values())
|
|
37
|
+
options: dict[str, Any] = {}
|
|
38
|
+
if "deadline" in signature.parameters or any_keyword:
|
|
39
|
+
options["deadline"] = deadline
|
|
40
|
+
if until is not None and ("until" in signature.parameters or any_keyword):
|
|
41
|
+
options["until"] = until
|
|
42
|
+
return self._wait_for_challenge(page, result, **options)
|
|
38
43
|
|
|
39
44
|
# A wait off the school's login page (verification, the publisher's pages and
|
|
40
45
|
# choosers, the PDF step): config ``browser_page_wait_timeout``, else this.
|
|
@@ -571,8 +576,12 @@ class UserWaitMixin:
|
|
|
571
576
|
else:
|
|
572
577
|
progress_reporter.update_attention_deadline(key, deadline)
|
|
573
578
|
|
|
574
|
-
def _wait_for_challenge(self, page: Any, result: DownloadResult, *, deadline: float | None = None
|
|
575
|
-
|
|
579
|
+
def _wait_for_challenge(self, page: Any, result: DownloadResult, *, deadline: float | None = None,
|
|
580
|
+
until: Callable[[], bool] | None = None) -> bool:
|
|
581
|
+
"""Wait while a verification page is up, until ``_wait_deadline``. ``until``: the
|
|
582
|
+
wait ends, as passed, once it says what it waits for has arrived though the page
|
|
583
|
+
is still up (the PDF's answer, captured while ScienceDirect's tab stayed on "Just
|
|
584
|
+
a moment...": two articles failed with the PDF in hand, 2026-11-21)."""
|
|
576
585
|
interaction = ExitStack()
|
|
577
586
|
activity, activity_owned = self._observe_page_activity(page, result)
|
|
578
587
|
automatic: dict[str, Any] = {}
|
|
@@ -587,6 +596,11 @@ class UserWaitMixin:
|
|
|
587
596
|
checks = 0
|
|
588
597
|
while True:
|
|
589
598
|
self._check_user_decision(result, page)
|
|
599
|
+
if until is not None and until():
|
|
600
|
+
if waited:
|
|
601
|
+
result.state = state_before
|
|
602
|
+
self._event(result, "challenge_wait_ended", "what it waited for arrived")
|
|
603
|
+
return True
|
|
590
604
|
# While the interstitial is up, look only at title and URL.
|
|
591
605
|
shell = self._challenge_shell(page)
|
|
592
606
|
if not shell:
|
|
@@ -42,6 +42,9 @@ _FAILURE_KINDS = {
|
|
|
42
42
|
"browser_unresponsive": ("browser_unresponsive", "review_browser"),
|
|
43
43
|
"browser_operation_timeout": ("browser_operation_timeout", "review_browser"),
|
|
44
44
|
"publisher_access_blocked": ("access_blocked", "review_access"),
|
|
45
|
+
# The site said its downloads are used up for now (batch_capture ``_note_download_limit``):
|
|
46
|
+
# like a block, the journal's later articles wait and one re-checks now and then.
|
|
47
|
+
"publisher_download_limit": ("access_blocked", "review_access"),
|
|
45
48
|
"publisher_unreachable": ("publisher_unreachable", "review_publisher_error"),
|
|
46
49
|
"sso_required": ("paywall", "login_required"),
|
|
47
50
|
"institution_pdf_entitlement_missing": ("paywall", "review_entitlement"),
|
|
@@ -71,6 +74,9 @@ _FAILURE_KINDS = {
|
|
|
71
74
|
"doi_not_registered": ("doi_not_registered", "review_publisher_error"),
|
|
72
75
|
# A site without a publisher profile: the shared rules found no institution entry.
|
|
73
76
|
"generic_institution_entry_missing": ("generic_institution_entry_missing", "review_publisher_profiles"),
|
|
77
|
+
# A publisher with rules of its own: its article page showed no login entry the rules found
|
|
78
|
+
# (reported as download_failed until 2026-11-22, "原因不明"; Thieme's Thrombosis and Haemostasis).
|
|
79
|
+
"publisher_institution_entry_missing": ("publisher_institution_entry_missing", "review_browser"),
|
|
74
80
|
# The site's page shows no way to any school's login (an open-access site, one with personal
|
|
75
81
|
# accounts only): no school login was started (user, 2026-11-18).
|
|
76
82
|
"no_institution_entry": ("no_institution_entry", ""),
|
|
@@ -124,9 +130,17 @@ def _failure_reason_code(result: Any) -> str:
|
|
|
124
130
|
reason_code = "login_timeout" if wait_page in ("school_login", "school_choice") else "login_not_reached"
|
|
125
131
|
elif reason_code == "sso_required" and getattr(result, "_user_wait_expired", False):
|
|
126
132
|
reason_code = "login_timeout" # the login waited on the user until its time was up
|
|
133
|
+
if getattr(result, "_download_limit", "") and reason_code in _PDF_NOT_ARRIVED:
|
|
134
|
+
# The site had said its downloads were used up: that, not the wait, is why.
|
|
135
|
+
reason_code = "publisher_download_limit"
|
|
127
136
|
return reason_code
|
|
128
137
|
|
|
129
138
|
|
|
139
|
+
# Failures that only say the PDF did not come (a site's download-limit notice says why).
|
|
140
|
+
_PDF_NOT_ARRIVED = frozenset({"challenge_or_viewer_timeout", "pdf_not_captured", "download_failed",
|
|
141
|
+
"request_failed", "download_timeout", "browser_operation_timeout", ""})
|
|
142
|
+
|
|
143
|
+
|
|
130
144
|
def try_institutional(
|
|
131
145
|
doi: str,
|
|
132
146
|
output_path: Path,
|
|
@@ -341,7 +355,9 @@ def _try_builtin_institutional(
|
|
|
341
355
|
remembered = entitlements.decision_for(doi, publisher_name, identity=identity)
|
|
342
356
|
except Exception:
|
|
343
357
|
remembered = None
|
|
344
|
-
|
|
358
|
+
# The user's marks were made with the default school: another one's visit is not skipped by them (没权限时换下一所学校).
|
|
359
|
+
from .. import school_switch
|
|
360
|
+
if remembered and remembered.get("decision") == "skip" and not config.get(school_switch.MARKS_OFF):
|
|
345
361
|
log.info(" [Institutional] Skipped: %s marked as no access", remembered.get("key"))
|
|
346
362
|
return {"success": False, "identifier": doi, "doi": doi, "source": "institutional:entitlement_memory",
|
|
347
363
|
"error_type": "no_entitlement", "reason": "user_marked_no_entitlement",
|
|
@@ -386,6 +402,8 @@ def _try_builtin_institutional(
|
|
|
386
402
|
failure["supplements"] = result["supplements"]
|
|
387
403
|
if isinstance(result.get("fulltext_page"), dict):
|
|
388
404
|
failure["fulltext_page"] = result["fulltext_page"]
|
|
405
|
+
if isinstance(result.get("same_name_entries"), int):
|
|
406
|
+
failure["same_name_entries"] = result["same_name_entries"]
|
|
389
407
|
if failure["error_type"] in _LOGIN_FAILURE_CODES:
|
|
390
408
|
failure.update(reason=failure["error_type"], action="review_browser")
|
|
391
409
|
if (result.get("error_type") == "paywall"
|
|
@@ -417,13 +435,16 @@ def _try_builtin_institutional(
|
|
|
417
435
|
denial = next((f for f in failures if f.get("reason_code") ==
|
|
418
436
|
"institution_pdf_entitlement_missing"), None)
|
|
419
437
|
primary = next((f for code in ("source_exception", "unsupported_platform", "article_not_yet_published",
|
|
420
|
-
"generic_institution_entry_missing", "
|
|
438
|
+
"generic_institution_entry_missing", "publisher_institution_entry_missing",
|
|
439
|
+
"no_institution_entry",
|
|
421
440
|
"publisher_content_error", "access_blocked", *_LOGIN_FAILURE_CODES,
|
|
422
441
|
"download_timeout")
|
|
423
442
|
for f in failures if f["error_type"] == code), denial or failures[-1])
|
|
424
443
|
result = {"success": False, "identifier": doi, "doi": doi, "source": "institutional",
|
|
425
444
|
"error_type": primary["error_type"], "reason": primary["reason"],
|
|
426
|
-
"action": primary["action"], "source_failures": failures
|
|
445
|
+
"action": primary["action"], "source_failures": failures,
|
|
446
|
+
**({"same_name_entries": entries} if (entries := max((f.get("same_name_entries") or 0
|
|
447
|
+
for f in failures), default=0)) > 1 else {})}
|
|
427
448
|
if primary["error_type"] == "access_blocked":
|
|
428
449
|
_remember_blocked_journal(doi, identity)
|
|
429
450
|
if (primary["error_type"] == "institution_federation_unavailable" and manual_school
|
|
@@ -812,6 +833,9 @@ def _try_browser_batch_download(
|
|
|
812
833
|
failure = {"success": False, "identifier": doi, "source": "institutional:browser",
|
|
813
834
|
"error_type": error_type, "reason": error_type, "action": action,
|
|
814
835
|
"artifacts": _browser_artifacts(result, profile)}
|
|
836
|
+
if int(getattr(result, "_same_name_entries", 0) or 0) > 1:
|
|
837
|
+
# The school's entries by one name, one chosen this time: the orchestrator takes the next if it did not do.
|
|
838
|
+
failure["same_name_entries"] = int(result._same_name_entries)
|
|
815
839
|
if supplements_mode in ("with", "only"):
|
|
816
840
|
failure["supplements"] = result.supplements
|
|
817
841
|
if getattr(result, "fulltext_page", None) and reason_code != "institution_pdf_entitlement_missing" \
|
|
@@ -215,7 +215,8 @@ def is_pdf_candidate_url(profile: PublisherProfile, url: str) -> bool:
|
|
|
215
215
|
def is_thieme_article_pdf_url(url: str, doi: str = "") -> bool:
|
|
216
216
|
"""Exclude account/reset URLs that merely carry a PDF return address."""
|
|
217
217
|
parsed = urlparse(url.strip())
|
|
218
|
-
|
|
218
|
+
# Any DOI: Thieme's own 10.1055 and those of the journals it took over (Schattauer's 10.1160).
|
|
219
|
+
match = re.fullmatch(r"/products/ejournals/pdf/(10\.\d{4,9}/[^/]+)\.pdf",
|
|
219
220
|
unquote(parsed.path).lower())
|
|
220
221
|
return (parsed.scheme == "https" and not parsed.username and not parsed.password
|
|
221
222
|
and parsed.netloc.lower() in {"www.thieme-connect.de", "thieme-connect.de",
|