litloop 1.18.3__py3-none-any.whl
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.
- litloop/__init__.py +89 -0
- litloop/__main__.py +6 -0
- litloop/_source_hygiene.py +158 -0
- litloop/agents/__init__.py +13 -0
- litloop/agents/client.py +164 -0
- litloop/agents/runner.py +123 -0
- litloop/agents/system.py +54 -0
- litloop/agents/tools.py +142 -0
- litloop/app_server.py +8 -0
- litloop/browser/__init__.py +1 -0
- litloop/browser/backend.py +1009 -0
- litloop/browser/camofox_api.py +368 -0
- litloop/browser/chrome_copy.py +136 -0
- litloop/browser/cloakbrowser_compat.py +72 -0
- litloop/browser/cookies.py +347 -0
- litloop/browser/engine.py +965 -0
- litloop/browser/login.py +636 -0
- litloop/browser/pdf.py +263 -0
- litloop/browser/profile_health.py +167 -0
- litloop/browser/runtime.py +210 -0
- litloop/cache.py +104 -0
- litloop/citations/__init__.py +1 -0
- litloop/citations/bib_import.py +102 -0
- litloop/citations/bibtex_crossref.py +143 -0
- litloop/citations/formats.py +225 -0
- litloop/citations/paper_list.py +200 -0
- litloop/citations/session_export.py +94 -0
- litloop/cli/__init__.py +12 -0
- litloop/cli/_utils.py +267 -0
- litloop/cli/commands.py +1098 -0
- litloop/cli/doctor.py +141 -0
- litloop/cli/main.py +1173 -0
- litloop/cli/web.py +190 -0
- litloop/config.py +413 -0
- litloop/data/VARCON-LICENSE.txt +62 -0
- litloop/data/elements.tsv +119 -0
- litloop/data/institutional_identity_policy.json +165 -0
- litloop/data/publisher_access_catalog.json +969 -0
- litloop/data/publisher_carsi.json +105 -0
- litloop/data/spelling_search.tsv.gz +0 -0
- litloop/data/spelling_us.tsv.gz +0 -0
- litloop/data/webvpn.dat +0 -0
- litloop/data/webvpn.json +603 -0
- litloop/db.py +1922 -0
- litloop/deps.py +128 -0
- litloop/desktop/__init__.py +1 -0
- litloop/desktop/agent_runner.py +537 -0
- litloop/desktop/download_jobs.py +571 -0
- litloop/desktop/error_text.py +192 -0
- litloop/desktop/server.py +999 -0
- litloop/desktop/settings.py +552 -0
- litloop/desktop/translate.py +103 -0
- litloop/diagnostics.py +126 -0
- litloop/download/__init__.py +1 -0
- litloop/download/doi_check.py +44 -0
- litloop/download/fetcher.py +975 -0
- litloop/download/markdown.py +130 -0
- litloop/download/pdf.py +454 -0
- litloop/download/pipeline.py +1166 -0
- litloop/download/progress.py +312 -0
- litloop/download/rename.py +211 -0
- litloop/extractors/__init__.py +0 -0
- litloop/extractors/html_extractor.py +31 -0
- litloop/extractors/pdf_extractor.py +151 -0
- litloop/extractors/publisher_adapters/__init__.py +0 -0
- litloop/extractors/publisher_adapters/acs.py +167 -0
- litloop/extractors/publisher_adapters/elsevier.py +178 -0
- litloop/extractors/publisher_adapters/generic.py +191 -0
- litloop/extractors/publisher_adapters/nature.py +204 -0
- litloop/extractors/publisher_adapters/rsc.py +154 -0
- litloop/extractors/publisher_adapters/tandfonline.py +154 -0
- litloop/extractors/publisher_adapters/wiley.py +160 -0
- litloop/http_utils.py +57 -0
- litloop/identifiers.py +134 -0
- litloop/institutional/__init__.py +1 -0
- litloop/institutional/auth.py +576 -0
- litloop/institutional/carsi_login.py +569 -0
- litloop/institutional/config_adapter.py +63 -0
- litloop/institutional/proxy_check.py +98 -0
- litloop/institutional/remote_assist.py +274 -0
- litloop/institutional/schools.py +102 -0
- litloop/institutional/session_heal.py +73 -0
- litloop/institutional/session_store.py +105 -0
- litloop/log.py +47 -0
- litloop/models.py +269 -0
- litloop/network.py +417 -0
- litloop/optional.py +310 -0
- litloop/publishers/__init__.py +1 -0
- litloop/publishers/access.py +232 -0
- litloop/publishers/pdf_router.py +451 -0
- litloop/publishers/profiles.py +899 -0
- litloop/publishers/strategies/__init__.py +122 -0
- litloop/publishers/strategies/_core.py +2340 -0
- litloop/publishers/strategies/_elsevier_api.py +578 -0
- litloop/publishers/strategies/acm.py +27 -0
- litloop/publishers/strategies/acs.py +42 -0
- litloop/publishers/strategies/aip.py +27 -0
- litloop/publishers/strategies/aps.py +29 -0
- litloop/publishers/strategies/asce.py +28 -0
- litloop/publishers/strategies/base.py +108 -0
- litloop/publishers/strategies/copernicus.py +24 -0
- litloop/publishers/strategies/elsevier.py +66 -0
- litloop/publishers/strategies/generic.py +39 -0
- litloop/publishers/strategies/ieee.py +28 -0
- litloop/publishers/strategies/iop.py +27 -0
- litloop/publishers/strategies/nature.py +27 -0
- litloop/publishers/strategies/oxford.py +27 -0
- litloop/publishers/strategies/registry.py +83 -0
- litloop/publishers/strategies/royalsociety.py +28 -0
- litloop/publishers/strategies/rsc.py +27 -0
- litloop/publishers/strategies/sage.py +30 -0
- litloop/publishers/strategies/science.py +27 -0
- litloop/publishers/strategies/springer.py +34 -0
- litloop/publishers/strategies/tandfonline.py +32 -0
- litloop/publishers/strategies/wiley.py +32 -0
- litloop/publishers/supplementary.py +219 -0
- litloop/quota.py +202 -0
- litloop/search/__init__.py +1 -0
- litloop/search/abstracts.py +291 -0
- litloop/search/deep.py +1216 -0
- litloop/search/quick.py +1102 -0
- litloop/search/scansci_find.py +410 -0
- litloop/search/screening.py +225 -0
- litloop/search/title_to_doi.py +163 -0
- litloop/search/watches.py +124 -0
- litloop/server.py +1731 -0
- litloop/sources/__init__.py +1339 -0
- litloop/sources/_batch.py +529 -0
- litloop/sources/_index.py +221 -0
- litloop/sources/_routes.py +290 -0
- litloop/sources/altcha.py +90 -0
- litloop/sources/arxiv.py +45 -0
- litloop/sources/attempt.py +91 -0
- litloop/sources/carsi.py +74 -0
- litloop/sources/core_api.py +46 -0
- litloop/sources/crossref.py +162 -0
- litloop/sources/elsevier_api.py +620 -0
- litloop/sources/elsevier_check.py +274 -0
- litloop/sources/europepmc.py +81 -0
- litloop/sources/ezproxy.py +317 -0
- litloop/sources/instsci.py +1295 -0
- litloop/sources/libgen.py +116 -0
- litloop/sources/nature.py +39 -0
- litloop/sources/oa_discovery.py +135 -0
- litloop/sources/openaire.py +122 -0
- litloop/sources/openalex.py +100 -0
- litloop/sources/publishers.py +684 -0
- litloop/sources/sage_cn.py +139 -0
- litloop/sources/scibban.py +10 -0
- litloop/sources/scihub.py +1379 -0
- litloop/sources/scihub_domains.py +203 -0
- litloop/sources/scihub_speed.py +187 -0
- litloop/sources/scoring.py +250 -0
- litloop/sources/semantic_scholar.py +146 -0
- litloop/sources/springer_tdm.py +172 -0
- litloop/sources/unpaywall.py +116 -0
- litloop/sources/vpnsci.py +38 -0
- litloop/store.py +264 -0
- litloop/templates/index.html +347 -0
- litloop/terms/__init__.py +1 -0
- litloop/terms/glossary.py +422 -0
- litloop/terms/spelling.py +89 -0
- litloop/terms/text.py +106 -0
- litloop/tor/__init__.py +1 -0
- litloop/tor/embedded.py +371 -0
- litloop/tor/proxy.py +110 -0
- litloop/updates.py +148 -0
- litloop/zotero/__init__.py +1 -0
- litloop/zotero/bridge.py +309 -0
- litloop/zotero/client.py +317 -0
- litloop-1.18.3.dist-info/METADATA +347 -0
- litloop-1.18.3.dist-info/RECORD +176 -0
- litloop-1.18.3.dist-info/WHEEL +5 -0
- litloop-1.18.3.dist-info/entry_points.txt +2 -0
- litloop-1.18.3.dist-info/licenses/LICENSE +197 -0
- litloop-1.18.3.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"""APS (American Physical Society) publisher strategy."""
|
|
2
|
+
|
|
3
|
+
from .base import BasePublisherStrategy
|
|
4
|
+
from .registry import StrategyRegistry
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@StrategyRegistry.register
|
|
8
|
+
class APSStrategy(BasePublisherStrategy):
|
|
9
|
+
name = "APS"
|
|
10
|
+
aliases = ("aps",)
|
|
11
|
+
doi_prefixes = ("10.1103/",)
|
|
12
|
+
base_domains = ("journals.aps.org", "aps.org")
|
|
13
|
+
sample_dois = ("10.1103/PhysRevLett.120.200601",)
|
|
14
|
+
article_url_template = "https://journals.aps.org/prl/abstract/{doi}"
|
|
15
|
+
pdf_url_templates = (
|
|
16
|
+
"https://journals.aps.org/prl/pdf/{doi}",
|
|
17
|
+
"https://journals.aps.org/prb/pdf/{doi}",
|
|
18
|
+
"https://journals.aps.org/pdf/{doi}",
|
|
19
|
+
)
|
|
20
|
+
success_url_markers = ("journals.aps.org/",)
|
|
21
|
+
auth_url_markers = (
|
|
22
|
+
"id.tsinghua.edu.cn",
|
|
23
|
+
"idp.tsinghua.edu.cn",
|
|
24
|
+
"login.openathens.net",
|
|
25
|
+
)
|
|
26
|
+
sso_text_markers = ("Access through your institution",)
|
|
27
|
+
sso_url_patterns = ("/shibboleth", "/institutional")
|
|
28
|
+
institution_input_selectors = ("input[name='search']", "#searchInstitution")
|
|
29
|
+
institution_result_selectors = ("input[name='search']",)
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"""ASCE Library publisher strategy."""
|
|
2
|
+
|
|
3
|
+
from .base import BasePublisherStrategy
|
|
4
|
+
from .registry import StrategyRegistry
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@StrategyRegistry.register
|
|
8
|
+
class ASCEStrategy(BasePublisherStrategy):
|
|
9
|
+
name = "ASCE"
|
|
10
|
+
aliases = ("asce",)
|
|
11
|
+
doi_prefixes = ("10.1061/",)
|
|
12
|
+
base_domains = ("ascelibrary.org",)
|
|
13
|
+
sample_dois = ("10.1061/(ASCE)0733-9364(2005)131:7(855)",)
|
|
14
|
+
article_url_template = "https://ascelibrary.org/doi/{doi}"
|
|
15
|
+
pdf_url_templates = (
|
|
16
|
+
"https://ascelibrary.org/doi/pdf/{doi}?download=true",
|
|
17
|
+
"https://ascelibrary.org/doi/pdf/{doi}",
|
|
18
|
+
)
|
|
19
|
+
success_url_markers = ("ascelibrary.org/doi/",)
|
|
20
|
+
auth_url_markers = (
|
|
21
|
+
"id.tsinghua.edu.cn",
|
|
22
|
+
"idp.tsinghua.edu.cn",
|
|
23
|
+
"login.openathens.net",
|
|
24
|
+
)
|
|
25
|
+
sso_text_markers = ("Access through your institution",)
|
|
26
|
+
sso_url_patterns = ("/shibboleth", "/institutional")
|
|
27
|
+
institution_input_selectors = ("input[name='search']", "#searchInstitution")
|
|
28
|
+
institution_result_selectors = ("input[name='search']",)
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"""Base class for publisher-specific PDF download strategies.
|
|
2
|
+
|
|
3
|
+
Unifies the declarative data from PublisherProfile with the imperative
|
|
4
|
+
download logic from publisher_strategies, so each publisher is a single
|
|
5
|
+
self-contained class.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
from typing import Any
|
|
12
|
+
from urllib.parse import quote
|
|
13
|
+
|
|
14
|
+
from ...log import get_logger
|
|
15
|
+
|
|
16
|
+
log = get_logger()
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class BasePublisherStrategy:
|
|
20
|
+
"""Unified publisher strategy: profile data + download logic.
|
|
21
|
+
|
|
22
|
+
Subclass this for each publisher. Register via ``StrategyRegistry.register``.
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
# ------------------------------------------------------------------
|
|
26
|
+
# Publisher identity
|
|
27
|
+
# ------------------------------------------------------------------
|
|
28
|
+
name: str = ""
|
|
29
|
+
aliases: tuple[str, ...] = ()
|
|
30
|
+
doi_prefixes: tuple[str, ...] = ()
|
|
31
|
+
base_domains: tuple[str, ...] = ()
|
|
32
|
+
sample_dois: tuple[str, ...] = ()
|
|
33
|
+
|
|
34
|
+
# ------------------------------------------------------------------
|
|
35
|
+
# URL templates
|
|
36
|
+
# ------------------------------------------------------------------
|
|
37
|
+
article_url_template: str | None = None
|
|
38
|
+
pdf_url_templates: tuple[str, ...] = ()
|
|
39
|
+
|
|
40
|
+
# ------------------------------------------------------------------
|
|
41
|
+
# PDF detection
|
|
42
|
+
# ------------------------------------------------------------------
|
|
43
|
+
pdf_url_markers: tuple[str, ...] = (
|
|
44
|
+
"/doi/pdf/",
|
|
45
|
+
"/doi/epdf/",
|
|
46
|
+
"/pdf/",
|
|
47
|
+
"/pdf",
|
|
48
|
+
"pdf",
|
|
49
|
+
)
|
|
50
|
+
pdf_link_text_markers: tuple[str, ...] = ("pdf",)
|
|
51
|
+
success_url_markers: tuple[str, ...] = ()
|
|
52
|
+
supplementary_url_markers: tuple[str, ...] = (
|
|
53
|
+
"suppl_file",
|
|
54
|
+
"suppdata",
|
|
55
|
+
"supporting-information",
|
|
56
|
+
"supplementary",
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
# ------------------------------------------------------------------
|
|
60
|
+
# SSO / Auth configuration
|
|
61
|
+
# ------------------------------------------------------------------
|
|
62
|
+
sso_text_markers: tuple[str, ...] = ()
|
|
63
|
+
sso_url_patterns: tuple[str, ...] = ()
|
|
64
|
+
auth_url_markers: tuple[str, ...] = ()
|
|
65
|
+
auth_title_markers: tuple[str, ...] = ()
|
|
66
|
+
institution_input_selectors: tuple[str, ...] = ()
|
|
67
|
+
institution_result_selectors: tuple[str, ...] = ()
|
|
68
|
+
|
|
69
|
+
# ------------------------------------------------------------------
|
|
70
|
+
# Methods
|
|
71
|
+
# ------------------------------------------------------------------
|
|
72
|
+
|
|
73
|
+
def article_url(self, doi: str) -> str:
|
|
74
|
+
"""Build the article landing-page URL from a DOI."""
|
|
75
|
+
if self.article_url_template:
|
|
76
|
+
return self.article_url_template.format(doi=doi)
|
|
77
|
+
return f"https://doi.org/{doi}"
|
|
78
|
+
|
|
79
|
+
def pdf_urls(self, doi: str) -> list[str]:
|
|
80
|
+
"""Build ordered candidate PDF URLs from a DOI."""
|
|
81
|
+
doi_suffix = doi.split("/", 1)[-1] if "/" in doi else doi
|
|
82
|
+
values = {
|
|
83
|
+
"doi": doi,
|
|
84
|
+
"doi_quoted": quote(doi, safe=""),
|
|
85
|
+
"doi_suffix": doi_suffix,
|
|
86
|
+
"doi_suffix_quoted": quote(doi_suffix, safe=""),
|
|
87
|
+
}
|
|
88
|
+
return [template.format(**values) for template in self.pdf_url_templates]
|
|
89
|
+
|
|
90
|
+
async def download(
|
|
91
|
+
self,
|
|
92
|
+
doi: str,
|
|
93
|
+
output_path: Path,
|
|
94
|
+
config: dict[str, Any],
|
|
95
|
+
) -> dict[str, Any] | None:
|
|
96
|
+
"""Download PDF for a DOI. Return a success dict or ``None``.
|
|
97
|
+
|
|
98
|
+
Subclasses must override this or set ``_uses_legacy_fn`` to ``True``
|
|
99
|
+
(in which case the legacy ``try_<publisher>_browser`` function is
|
|
100
|
+
called via the compatibility bridge).
|
|
101
|
+
"""
|
|
102
|
+
raise NotImplementedError(
|
|
103
|
+
f"{self.name} strategy must implement download() or set _uses_legacy_fn"
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
# Allow gradual migration: set to True to keep using the old
|
|
107
|
+
# try_<publisher>_browser function for this publisher.
|
|
108
|
+
_uses_legacy_fn: bool = True
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"""Copernicus Publications publisher strategy."""
|
|
2
|
+
|
|
3
|
+
from .base import BasePublisherStrategy
|
|
4
|
+
from .registry import StrategyRegistry
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@StrategyRegistry.register
|
|
8
|
+
class CopernicusStrategy(BasePublisherStrategy):
|
|
9
|
+
name = "Copernicus"
|
|
10
|
+
aliases = ("copernicus", "egu")
|
|
11
|
+
doi_prefixes = ("10.5194/",)
|
|
12
|
+
base_domains = ("copernicus.org",)
|
|
13
|
+
sample_dois = ("10.5194/hess-22-3433-2018",)
|
|
14
|
+
article_url_template = "https://doi.org/{doi}"
|
|
15
|
+
pdf_url_templates = (
|
|
16
|
+
"https://www.copernicus.org/publications/{doi}",
|
|
17
|
+
"https://www.copernicus.org/articles/{doi}",
|
|
18
|
+
)
|
|
19
|
+
success_url_markers = ("copernicus.org/",)
|
|
20
|
+
auth_url_markers = ()
|
|
21
|
+
sso_text_markers = ()
|
|
22
|
+
sso_url_patterns = ()
|
|
23
|
+
institution_input_selectors = ()
|
|
24
|
+
institution_result_selectors = ()
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"""Elsevier / ScienceDirect / Cell Press publisher strategy."""
|
|
2
|
+
|
|
3
|
+
from .base import BasePublisherStrategy
|
|
4
|
+
from .registry import StrategyRegistry
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@StrategyRegistry.register
|
|
8
|
+
class ElsevierStrategy(BasePublisherStrategy):
|
|
9
|
+
name = "Elsevier"
|
|
10
|
+
aliases = ("elsevier", "sciencedirect", "cellpress")
|
|
11
|
+
doi_prefixes = (
|
|
12
|
+
"10.1016/",
|
|
13
|
+
"10.1016/j.",
|
|
14
|
+
"10.1016/j.cell",
|
|
15
|
+
"10.1016/j.oneear",
|
|
16
|
+
"10.1016/j.cels",
|
|
17
|
+
"10.1016/j.cub",
|
|
18
|
+
"10.1016/j.neuron",
|
|
19
|
+
"10.1016/j.molcel",
|
|
20
|
+
"10.1016/j.devcel",
|
|
21
|
+
"10.1016/j.immuni",
|
|
22
|
+
"10.1016/j.chom",
|
|
23
|
+
"10.1016/j.cmet",
|
|
24
|
+
"10.1016/j.stem",
|
|
25
|
+
"10.1016/j.celrep",
|
|
26
|
+
"10.1016/j.isci",
|
|
27
|
+
"10.1016/j.xcr",
|
|
28
|
+
"10.1016/j.heliyon",
|
|
29
|
+
"10.1016/j.ajhg",
|
|
30
|
+
)
|
|
31
|
+
base_domains = (
|
|
32
|
+
"sciencedirect.com",
|
|
33
|
+
"linkinghub.elsevier.com",
|
|
34
|
+
"cell.com",
|
|
35
|
+
"elsevier.com",
|
|
36
|
+
)
|
|
37
|
+
sample_dois = ("10.1016/j.cell.2022.01.001",)
|
|
38
|
+
article_url_template = "https://doi.org/{doi}"
|
|
39
|
+
pdf_url_templates = (
|
|
40
|
+
"https://www.sciencedirect.com/science/article/pii/{doi_suffix}/pdfft",
|
|
41
|
+
)
|
|
42
|
+
success_url_markers = (
|
|
43
|
+
"sciencedirect.com/science/article/pii/",
|
|
44
|
+
"cell.com/",
|
|
45
|
+
)
|
|
46
|
+
auth_url_markers = (
|
|
47
|
+
"id.tsinghua.edu.cn",
|
|
48
|
+
"idp.tsinghua.edu.cn",
|
|
49
|
+
"login.openathens.net",
|
|
50
|
+
"shibboleth",
|
|
51
|
+
)
|
|
52
|
+
sso_text_markers = (
|
|
53
|
+
"Access through your institution",
|
|
54
|
+
"Institutional access",
|
|
55
|
+
"Login via your institution",
|
|
56
|
+
)
|
|
57
|
+
sso_url_patterns = ("/shibboleth", "/institutional")
|
|
58
|
+
institution_input_selectors = (
|
|
59
|
+
"#institution-search",
|
|
60
|
+
"input[name='query']",
|
|
61
|
+
"#bdd-email",
|
|
62
|
+
)
|
|
63
|
+
institution_result_selectors = (
|
|
64
|
+
"#institution-search",
|
|
65
|
+
"input[name='query']",
|
|
66
|
+
)
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"""Generic fallback publisher strategy for unknown publishers."""
|
|
2
|
+
|
|
3
|
+
from .base import BasePublisherStrategy
|
|
4
|
+
from .registry import StrategyRegistry
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@StrategyRegistry.register
|
|
8
|
+
class GenericStrategy(BasePublisherStrategy):
|
|
9
|
+
"""Fallback strategy used when no publisher-specific strategy matches."""
|
|
10
|
+
|
|
11
|
+
name = "Generic"
|
|
12
|
+
aliases = ("generic", "unknown")
|
|
13
|
+
doi_prefixes = ()
|
|
14
|
+
base_domains = ()
|
|
15
|
+
sample_dois = ()
|
|
16
|
+
article_url_template = "https://doi.org/{doi}"
|
|
17
|
+
pdf_url_templates = ()
|
|
18
|
+
success_url_markers = ()
|
|
19
|
+
auth_url_markers = (
|
|
20
|
+
"id.tsinghua.edu.cn",
|
|
21
|
+
"idp.tsinghua.edu.cn",
|
|
22
|
+
"login.openathens.net",
|
|
23
|
+
"shibboleth",
|
|
24
|
+
)
|
|
25
|
+
sso_text_markers = ("Access through your institution", "Institutional login")
|
|
26
|
+
sso_url_patterns = (
|
|
27
|
+
"/ssostart",
|
|
28
|
+
"/shibboleth",
|
|
29
|
+
"/saml",
|
|
30
|
+
"/institutional-login",
|
|
31
|
+
"/federation",
|
|
32
|
+
)
|
|
33
|
+
institution_input_selectors = (
|
|
34
|
+
"#searchInstitution",
|
|
35
|
+
"input[name='query']",
|
|
36
|
+
"input[name='search']",
|
|
37
|
+
"#institution-search",
|
|
38
|
+
)
|
|
39
|
+
institution_result_selectors = ("#searchInstitution",)
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"""IEEE publisher strategy."""
|
|
2
|
+
|
|
3
|
+
from .base import BasePublisherStrategy
|
|
4
|
+
from .registry import StrategyRegistry
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@StrategyRegistry.register
|
|
8
|
+
class IEEEStrategy(BasePublisherStrategy):
|
|
9
|
+
name = "IEEE"
|
|
10
|
+
aliases = ("ieee",)
|
|
11
|
+
doi_prefixes = ("10.1109/",)
|
|
12
|
+
base_domains = ("ieeexplore.ieee.org", "ieee.org")
|
|
13
|
+
sample_dois = ("10.1109/5.771073",)
|
|
14
|
+
article_url_template = "https://ieeexplore.ieee.org/document/{doi}"
|
|
15
|
+
pdf_url_templates = ()
|
|
16
|
+
success_url_markers = ("ieeexplore.ieee.org/document/",)
|
|
17
|
+
auth_url_markers = (
|
|
18
|
+
"id.tsinghua.edu.cn",
|
|
19
|
+
"idp.tsinghua.edu.cn",
|
|
20
|
+
"login.openathens.net",
|
|
21
|
+
)
|
|
22
|
+
sso_text_markers = ("Institutional Sign In", "Access through your institution")
|
|
23
|
+
sso_url_patterns = ("/shibboleth", "/institutional")
|
|
24
|
+
institution_input_selectors = (
|
|
25
|
+
"input[name='idpSearch']",
|
|
26
|
+
"#searchInstitution",
|
|
27
|
+
)
|
|
28
|
+
institution_result_selectors = ("input[name='idpSearch']",)
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"""IOP (Institute of Physics) publisher strategy."""
|
|
2
|
+
|
|
3
|
+
from .base import BasePublisherStrategy
|
|
4
|
+
from .registry import StrategyRegistry
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@StrategyRegistry.register
|
|
8
|
+
class IOPStrategy(BasePublisherStrategy):
|
|
9
|
+
name = "IOP"
|
|
10
|
+
aliases = ("iop",)
|
|
11
|
+
doi_prefixes = ("10.1088/",)
|
|
12
|
+
base_domains = ("iopscience.iop.org", "iop.org")
|
|
13
|
+
sample_dois = ("10.1088/1361-6463/ab60e7",)
|
|
14
|
+
article_url_template = "https://iopscience.iop.org/article/{doi}"
|
|
15
|
+
pdf_url_templates = (
|
|
16
|
+
"https://iopscience.iop.org/article/{doi}/pdf",
|
|
17
|
+
)
|
|
18
|
+
success_url_markers = ("iopscience.iop.org/article/",)
|
|
19
|
+
auth_url_markers = (
|
|
20
|
+
"id.tsinghua.edu.cn",
|
|
21
|
+
"idp.tsinghua.edu.cn",
|
|
22
|
+
"login.openathens.net",
|
|
23
|
+
)
|
|
24
|
+
sso_text_markers = ("Access through your institution",)
|
|
25
|
+
sso_url_patterns = ("/shibboleth", "/institutional")
|
|
26
|
+
institution_input_selectors = ("input[name='search']", "#searchInstitution")
|
|
27
|
+
institution_result_selectors = ("input[name='search']",)
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"""Nature / Nature Portfolio publisher strategy."""
|
|
2
|
+
|
|
3
|
+
from .base import BasePublisherStrategy
|
|
4
|
+
from .registry import StrategyRegistry
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@StrategyRegistry.register
|
|
8
|
+
class NatureStrategy(BasePublisherStrategy):
|
|
9
|
+
name = "Nature"
|
|
10
|
+
aliases = ("nature",)
|
|
11
|
+
doi_prefixes = ("10.1038/",)
|
|
12
|
+
base_domains = ("nature.com",)
|
|
13
|
+
sample_dois = ("10.1038/s41586-020-2649-2",)
|
|
14
|
+
article_url_template = "https://doi.org/{doi}"
|
|
15
|
+
pdf_url_templates = (
|
|
16
|
+
"https://www.nature.com/articles/{doi_suffix}.pdf",
|
|
17
|
+
)
|
|
18
|
+
success_url_markers = ("nature.com/articles/",)
|
|
19
|
+
auth_url_markers = (
|
|
20
|
+
"id.tsinghua.edu.cn",
|
|
21
|
+
"idp.tsinghua.edu.cn",
|
|
22
|
+
"login.openathens.net",
|
|
23
|
+
)
|
|
24
|
+
sso_text_markers = ("Access through your institution",)
|
|
25
|
+
sso_url_patterns = ("/shibboleth", "/institutional")
|
|
26
|
+
institution_input_selectors = ("input[name='idpSearch']", "#searchInstitution")
|
|
27
|
+
institution_result_selectors = ("input[name='idpSearch']",)
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"""Oxford Academic publisher strategy."""
|
|
2
|
+
|
|
3
|
+
from .base import BasePublisherStrategy
|
|
4
|
+
from .registry import StrategyRegistry
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@StrategyRegistry.register
|
|
8
|
+
class OxfordStrategy(BasePublisherStrategy):
|
|
9
|
+
name = "Oxford"
|
|
10
|
+
aliases = ("oxford", "oup")
|
|
11
|
+
doi_prefixes = ("10.1093/",)
|
|
12
|
+
base_domains = ("academic.oup.com", "oup.com")
|
|
13
|
+
sample_dois = ("10.1093/bioinformatics/btz076",)
|
|
14
|
+
article_url_template = "https://doi.org/{doi}"
|
|
15
|
+
pdf_url_templates = (
|
|
16
|
+
"https://academic.oup.com/downloadpdf/{doi}",
|
|
17
|
+
)
|
|
18
|
+
success_url_markers = ("academic.oup.com/",)
|
|
19
|
+
auth_url_markers = (
|
|
20
|
+
"id.tsinghua.edu.cn",
|
|
21
|
+
"idp.tsinghua.edu.cn",
|
|
22
|
+
"login.openathens.net",
|
|
23
|
+
)
|
|
24
|
+
sso_text_markers = ("Access through your institution",)
|
|
25
|
+
sso_url_patterns = ("/shibboleth", "/institutional")
|
|
26
|
+
institution_input_selectors = ("#searchInstitution", "input[name='query']")
|
|
27
|
+
institution_result_selectors = ("#searchInstitution",)
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"""Auto-discovery registry for publisher strategies.
|
|
2
|
+
|
|
3
|
+
Every publisher module registers itself on import via ``StrategyRegistry.register``.
|
|
4
|
+
Callers resolve strategies by DOI prefix, publisher name, or domain.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
from typing import TYPE_CHECKING
|
|
10
|
+
|
|
11
|
+
if TYPE_CHECKING:
|
|
12
|
+
from .base import BasePublisherStrategy
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class StrategyRegistry:
|
|
16
|
+
"""Global registry of publisher strategies.
|
|
17
|
+
|
|
18
|
+
Strategies auto-register by calling ``StrategyRegistry.register(MyStrategy)``
|
|
19
|
+
at module level. The registry is keyed by name (lowercase), DOI prefix,
|
|
20
|
+
and base domain.
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
_by_name: dict[str, "BasePublisherStrategy"] = {}
|
|
24
|
+
_by_doi_prefix: dict[str, "BasePublisherStrategy"] = {}
|
|
25
|
+
_by_domain: dict[str, "BasePublisherStrategy"] = {}
|
|
26
|
+
|
|
27
|
+
@classmethod
|
|
28
|
+
def register(cls, strategy_cls: type["BasePublisherStrategy"]) -> type["BasePublisherStrategy"]:
|
|
29
|
+
"""Register a strategy class (called at module import time)."""
|
|
30
|
+
instance = strategy_cls()
|
|
31
|
+
name_key = instance.name.lower()
|
|
32
|
+
cls._by_name[name_key] = instance
|
|
33
|
+
for alias in instance.aliases:
|
|
34
|
+
cls._by_name[alias.lower()] = instance
|
|
35
|
+
for prefix in instance.doi_prefixes:
|
|
36
|
+
cls._by_doi_prefix[prefix] = instance
|
|
37
|
+
for domain in instance.base_domains:
|
|
38
|
+
cls._by_domain[domain] = instance
|
|
39
|
+
return strategy_cls # allow use as decorator
|
|
40
|
+
|
|
41
|
+
@classmethod
|
|
42
|
+
def get_for_doi(cls, doi: str) -> "BasePublisherStrategy | None":
|
|
43
|
+
"""Find the strategy whose DOI prefix matches *doi*.
|
|
44
|
+
|
|
45
|
+
Falls back to the Generic strategy (doi.org landing page) when no
|
|
46
|
+
publisher-specific prefix matches, so unknown prefixes still get an
|
|
47
|
+
article URL instead of being dropped before any network I/O.
|
|
48
|
+
"""
|
|
49
|
+
for prefix, strategy in cls._by_doi_prefix.items():
|
|
50
|
+
if doi.startswith(prefix):
|
|
51
|
+
return strategy
|
|
52
|
+
return cls._by_name.get("generic")
|
|
53
|
+
|
|
54
|
+
@classmethod
|
|
55
|
+
def get_by_name(cls, name: str) -> "BasePublisherStrategy | None":
|
|
56
|
+
"""Look up a strategy by publisher name (case-insensitive)."""
|
|
57
|
+
return cls._by_name.get(name.lower())
|
|
58
|
+
|
|
59
|
+
@classmethod
|
|
60
|
+
def get_for_url(cls, url: str) -> "BasePublisherStrategy | None":
|
|
61
|
+
"""Find the strategy whose base domain appears in *url*."""
|
|
62
|
+
for domain, strategy in cls._by_domain.items():
|
|
63
|
+
if domain in url:
|
|
64
|
+
return strategy
|
|
65
|
+
return None
|
|
66
|
+
|
|
67
|
+
@classmethod
|
|
68
|
+
def list_all(cls) -> list["BasePublisherStrategy"]:
|
|
69
|
+
"""Return all registered strategies (deduplicated)."""
|
|
70
|
+
seen: set[int] = set()
|
|
71
|
+
result: list["BasePublisherStrategy"] = []
|
|
72
|
+
for s in cls._by_name.values():
|
|
73
|
+
if id(s) not in seen:
|
|
74
|
+
seen.add(id(s))
|
|
75
|
+
result.append(s)
|
|
76
|
+
return result
|
|
77
|
+
|
|
78
|
+
@classmethod
|
|
79
|
+
def clear(cls) -> None:
|
|
80
|
+
"""Clear the registry (mainly for tests)."""
|
|
81
|
+
cls._by_name.clear()
|
|
82
|
+
cls._by_doi_prefix.clear()
|
|
83
|
+
cls._by_domain.clear()
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"""Royal Society Publishing strategy."""
|
|
2
|
+
|
|
3
|
+
from .base import BasePublisherStrategy
|
|
4
|
+
from .registry import StrategyRegistry
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@StrategyRegistry.register
|
|
8
|
+
class RoyalSocietyStrategy(BasePublisherStrategy):
|
|
9
|
+
name = "Royal Society"
|
|
10
|
+
aliases = ("royalsociety", "royal_society", "royalsocietypublishing")
|
|
11
|
+
doi_prefixes = ("10.1098/",)
|
|
12
|
+
base_domains = ("royalsocietypublishing.org",)
|
|
13
|
+
sample_dois = ("10.1098/rspa.2019.0567",)
|
|
14
|
+
article_url_template = "https://doi.org/{doi}"
|
|
15
|
+
pdf_url_templates = (
|
|
16
|
+
"https://royalsocietypublishing.org/doi/pdf/{doi}",
|
|
17
|
+
"https://royalsocietypublishing.org/doi/epdf/{doi}",
|
|
18
|
+
)
|
|
19
|
+
success_url_markers = ("royalsocietypublishing.org/doi/",)
|
|
20
|
+
auth_url_markers = (
|
|
21
|
+
"id.tsinghua.edu.cn",
|
|
22
|
+
"idp.tsinghua.edu.cn",
|
|
23
|
+
"login.openathens.net",
|
|
24
|
+
)
|
|
25
|
+
sso_text_markers = ("Access through your institution",)
|
|
26
|
+
sso_url_patterns = ("/shibboleth", "/institutional")
|
|
27
|
+
institution_input_selectors = ("input[name='search']", "#searchInstitution")
|
|
28
|
+
institution_result_selectors = ("input[name='search']",)
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"""RSC (Royal Society of Chemistry) publisher strategy."""
|
|
2
|
+
|
|
3
|
+
from .base import BasePublisherStrategy
|
|
4
|
+
from .registry import StrategyRegistry
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@StrategyRegistry.register
|
|
8
|
+
class RSCStrategy(BasePublisherStrategy):
|
|
9
|
+
name = "RSC"
|
|
10
|
+
aliases = ("rsc",)
|
|
11
|
+
doi_prefixes = ("10.1039/",)
|
|
12
|
+
base_domains = ("pubs.rsc.org", "rsc.org")
|
|
13
|
+
sample_dois = ("10.1039/C5CS00900D",)
|
|
14
|
+
article_url_template = "https://doi.org/{doi}"
|
|
15
|
+
pdf_url_templates = (
|
|
16
|
+
"https://pubs.rsc.org/en/content/articlepdf/{doi}",
|
|
17
|
+
)
|
|
18
|
+
success_url_markers = ("pubs.rsc.org/en/content/",)
|
|
19
|
+
auth_url_markers = (
|
|
20
|
+
"id.tsinghua.edu.cn",
|
|
21
|
+
"idp.tsinghua.edu.cn",
|
|
22
|
+
"login.openathens.net",
|
|
23
|
+
)
|
|
24
|
+
sso_text_markers = ("Access through your institution",)
|
|
25
|
+
sso_url_patterns = ("/shibboleth", "/institutional")
|
|
26
|
+
institution_input_selectors = ("input[name='search']", "#searchInstitution")
|
|
27
|
+
institution_result_selectors = ("input[name='search']",)
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"""SAGE Journals publisher strategy."""
|
|
2
|
+
|
|
3
|
+
from .base import BasePublisherStrategy
|
|
4
|
+
from .registry import StrategyRegistry
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@StrategyRegistry.register
|
|
8
|
+
class SAGEStrategy(BasePublisherStrategy):
|
|
9
|
+
name = "SAGE"
|
|
10
|
+
aliases = ("sage",)
|
|
11
|
+
doi_prefixes = ("10.1177/",)
|
|
12
|
+
base_domains = ("journals.sagepub.com", "sagepub.com", "sage.cnpereading.com")
|
|
13
|
+
sample_dois = ("10.1177/0956797615570357",)
|
|
14
|
+
article_url_template = "https://doi.org/{doi}"
|
|
15
|
+
pdf_url_templates = (
|
|
16
|
+
"https://journals.sagepub.com/doi/pdf/{doi}?download=true",
|
|
17
|
+
"https://journals.sagepub.com/doi/pdf/{doi}",
|
|
18
|
+
)
|
|
19
|
+
success_url_markers = ("journals.sagepub.com/doi/", "sage.cnpereading.com/doi/")
|
|
20
|
+
auth_url_markers = (
|
|
21
|
+
"id.tsinghua.edu.cn",
|
|
22
|
+
"idp.tsinghua.edu.cn",
|
|
23
|
+
"login.openathens.net",
|
|
24
|
+
"sp-sagecnpiec.carsi.edu.cn",
|
|
25
|
+
"carsi.edu.cn",
|
|
26
|
+
)
|
|
27
|
+
sso_text_markers = ("Access through your institution", "CARSI", "机构登录")
|
|
28
|
+
sso_url_patterns = ("/shibboleth", "/institutional", "carsi")
|
|
29
|
+
institution_input_selectors = ("input[name='search']", "#searchInstitution")
|
|
30
|
+
institution_result_selectors = ("input[name='search']",)
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"""Science / AAAS publisher strategy."""
|
|
2
|
+
|
|
3
|
+
from .base import BasePublisherStrategy
|
|
4
|
+
from .registry import StrategyRegistry
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@StrategyRegistry.register
|
|
8
|
+
class ScienceStrategy(BasePublisherStrategy):
|
|
9
|
+
name = "Science"
|
|
10
|
+
aliases = ("science", "aaas")
|
|
11
|
+
doi_prefixes = ("10.1126/",)
|
|
12
|
+
base_domains = ("science.org", "sciencemag.org")
|
|
13
|
+
sample_dois = ("10.1126/science.abc1234",)
|
|
14
|
+
article_url_template = "https://doi.org/{doi}"
|
|
15
|
+
pdf_url_templates = (
|
|
16
|
+
"https://www.science.org/doi/pdf/{doi}",
|
|
17
|
+
)
|
|
18
|
+
success_url_markers = ("science.org/doi/",)
|
|
19
|
+
auth_url_markers = (
|
|
20
|
+
"id.tsinghua.edu.cn",
|
|
21
|
+
"idp.tsinghua.edu.cn",
|
|
22
|
+
"login.openathens.net",
|
|
23
|
+
)
|
|
24
|
+
sso_text_markers = ("Access through your institution",)
|
|
25
|
+
sso_url_patterns = ("/shibboleth", "/institutional")
|
|
26
|
+
institution_input_selectors = ("input[name='search']", "#searchInstitution")
|
|
27
|
+
institution_result_selectors = ("input[name='search']",)
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"""Springer / Springer Nature publisher strategy."""
|
|
2
|
+
|
|
3
|
+
from .base import BasePublisherStrategy
|
|
4
|
+
from .registry import StrategyRegistry
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@StrategyRegistry.register
|
|
8
|
+
class SpringerStrategy(BasePublisherStrategy):
|
|
9
|
+
name = "Springer"
|
|
10
|
+
aliases = ("springer",)
|
|
11
|
+
doi_prefixes = ("10.1007/", "10.1023/")
|
|
12
|
+
base_domains = ("link.springer.com", "springer.com")
|
|
13
|
+
sample_dois = ("10.1007/s00216-019-01847-0",)
|
|
14
|
+
article_url_template = "https://link.springer.com/article/{doi}"
|
|
15
|
+
pdf_url_templates = (
|
|
16
|
+
"https://link.springer.com/content/pdf/{doi}.pdf",
|
|
17
|
+
)
|
|
18
|
+
success_url_markers = ("link.springer.com/",)
|
|
19
|
+
auth_url_markers = (
|
|
20
|
+
"id.tsinghua.edu.cn",
|
|
21
|
+
"idp.tsinghua.edu.cn",
|
|
22
|
+
"login.openathens.net",
|
|
23
|
+
)
|
|
24
|
+
sso_text_markers = (
|
|
25
|
+
"Access through your institution",
|
|
26
|
+
"Log in via your institution",
|
|
27
|
+
)
|
|
28
|
+
sso_url_patterns = ("/shibboleth", "/institutional-login")
|
|
29
|
+
institution_input_selectors = (
|
|
30
|
+
"#idp-search",
|
|
31
|
+
"input[name='idpSearch']",
|
|
32
|
+
"#searchInstitution",
|
|
33
|
+
)
|
|
34
|
+
institution_result_selectors = ("#idp-search",)
|