akamhy / waybackpy

Wayback Machine API interface & a command-line tool
https://pypi.org/project/waybackpy/
MIT License
462 stars 34 forks source link

allow near() to be called with a timestamp #67

Closed dequeued0 closed 3 years ago

dequeued0 commented 3 years ago

Instead of having to convert timestamps into year, month, day, hour, and minutes and then pass all of those parameters separately like wayback_url_obj.near(year=year, month=month, day=day, hour=hour, minute=minute), it would be great if it was possible to just pass in a Unix timestamp (either integer or floating point seconds since epoch like time.time()) and have that automatically rounded to the nearest minute and converted internally into the appropriate format.

Then the call could just be like wayback_url_obj.near(my_timestamp) or if you prefer a named parameter wayback_url_obj.near(timestamp=my_timestamp).

akamhy commented 3 years ago

Will add support for unix_timestamp.

wayback_url_obj.near(unix_timestamp=), can not use timestamp as a parameter name as we support other OS and don't want to confuse UNIX timestamp with wayback machine timestamp.

akamhy commented 3 years ago

Done in https://github.com/akamhy/waybackpy/commit/5a7bd735654c65188899e109328d98f717ab226d

dequeued0 commented 3 years ago

Awesome, thanks! My only comment is that I'm not sure I'd call the parameter unix_timestamp. The datetime and time modules just call it "timestamp" or "time" in most places. Seconds since epoch (i.e., the 1970 epoch) is a fairly standard thing for Python and various other things outside of the realm of Unix.