define __str__ for objects of WaybackMachineAvailabilityAPI class, the check for self.JSON ensures that the API was atleast called.
This commit is contained in:
parent
1d751b942b
commit
cc3628ae18
@ -31,10 +31,16 @@ class WaybackMachineAvailabilityAPI:
|
|||||||
self.headers = {"User-Agent": self.user_agent}
|
self.headers = {"User-Agent": self.user_agent}
|
||||||
self.payload = {"url": "{url}".format(url=self.url)}
|
self.payload = {"url": "{url}".format(url=self.url)}
|
||||||
self.endpoint = "https://archive.org/wayback/available"
|
self.endpoint = "https://archive.org/wayback/available"
|
||||||
|
self.JSON = None
|
||||||
|
|
||||||
def unix_timestamp_to_wayback_timestamp(self, unix_timestamp):
|
def unix_timestamp_to_wayback_timestamp(self, unix_timestamp):
|
||||||
return datetime.utcfromtimestamp(int(unix_timestamp)).strftime("%Y%m%d%H%M%S")
|
return datetime.utcfromtimestamp(int(unix_timestamp)).strftime("%Y%m%d%H%M%S")
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
if not self.JSON:
|
||||||
|
return None
|
||||||
|
return self.archive_url
|
||||||
|
|
||||||
def json(self):
|
def json(self):
|
||||||
self.request_url = full_url(self.endpoint, self.payload)
|
self.request_url = full_url(self.endpoint, self.payload)
|
||||||
self.response = requests.get(self.request_url, self.headers)
|
self.response = requests.get(self.request_url, self.headers)
|
||||||
|
Loading…
Reference in New Issue
Block a user