Skip to content

Commit 02a0a30

Browse files
committed
Go
1 parent 2af8330 commit 02a0a30

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

savepagenow/api.py

+19-2
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ def capture(
131131
def capture_or_cache(
132132
target_url: str,
133133
user_agent: str = DEFAULT_USER_AGENT,
134+
authenticate: bool = False,
134135
):
135136
"""
136137
Archive the provided URL using archive.org's Wayback Machine, unless the page has been recently captured.
@@ -143,9 +144,25 @@ def capture_or_cache(
143144
in the previous minutes.
144145
"""
145146
try:
146-
return capture(target_url, user_agent=user_agent, accept_cache=False), True
147+
return (
148+
capture(
149+
target_url,
150+
user_agent=user_agent,
151+
accept_cache=False,
152+
authenticate=authenticate,
153+
),
154+
True,
155+
)
147156
except CachedPage:
148-
return capture(target_url, user_agent=user_agent, accept_cache=True), False
157+
return (
158+
capture(
159+
target_url,
160+
user_agent=user_agent,
161+
accept_cache=True,
162+
authenticate=authenticate,
163+
),
164+
False,
165+
)
149166

150167

151168
@click.command()

tests/test_capture.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@ def test_capture():
2323
def test_auth_capture():
2424
"""Test the retrieval of URL from Wayback with authentication."""
2525
url = random.choice(SITE_LIST)
26-
archive_url, c = savepagenow.capture(url, authenticate=True)
26+
archive_url = savepagenow.capture(url, authenticate=True)
2727
assert archive_url.startswith("https://web.archive.org/")

0 commit comments

Comments
 (0)