Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support datetime.timedelta for target_window in get_memento() #55

Open
Mr0grog opened this issue Oct 19, 2020 · 1 comment
Open

Support datetime.timedelta for target_window in get_memento() #55

Mr0grog opened this issue Oct 19, 2020 · 1 comment
Labels
enhancement New feature or request good first issue Good for newcomers
Milestone

Comments

@Mr0grog
Copy link
Member

Mr0grog commented Oct 19, 2020

The WaybackClient.get_memento() method has a target_window parameter, which is used when a memento does not exist at the requested time. If the parameter exact=False, get_memento() returns the nearest-in-time memento, but only if it is within the number of seconds specified in target_window.

wayback/wayback/_client.py

Lines 717 to 719 in c066e04

def get_memento(self, url, datetime=None, mode=Mode.original, *,
exact=True, exact_redirects=None,
target_window=24 * 60 * 60, follow_redirects=True):

Since Python has a built in datetime.timedelta type to represent exactly this kind of concept, we should also accept it instead of an integer for target_window. (Really, I’m not sure why we didn’t do this originally!)

@Mr0grog Mr0grog added enhancement New feature or request good first issue Good for newcomers labels Oct 19, 2020
@Mr0grog
Copy link
Member Author

Mr0grog commented Oct 19, 2020

This is useful because it provides a more readable way to set timeframes. For example:

# 4 hour window as an integer:
get_memento(url, exact=False, target_window=4 * 60 * 60)

# 4 hour window as a timedelta:
get_memento(url, exact=False, target_window=timedelta(hours=4))

@Mr0grog Mr0grog added this to the v0.4.x milestone Nov 10, 2022
@Mr0grog Mr0grog moved this to Backlog in Wayback Roadmap Dec 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
Status: Backlog
Development

No branches or pull requests

1 participant