define __str__ for objects of WaybackMachineAvailabilityAPI class, the check for self.JSON ensures that the API was atleast called.
This commit is contained in:
		@@ -31,10 +31,16 @@ class WaybackMachineAvailabilityAPI:
 | 
			
		||||
        self.headers = {"User-Agent": self.user_agent}
 | 
			
		||||
        self.payload = {"url": "{url}".format(url=self.url)}
 | 
			
		||||
        self.endpoint = "https://archive.org/wayback/available"
 | 
			
		||||
        self.JSON = None
 | 
			
		||||
 | 
			
		||||
    def unix_timestamp_to_wayback_timestamp(self, unix_timestamp):
 | 
			
		||||
        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):
 | 
			
		||||
        self.request_url = full_url(self.endpoint, self.payload)
 | 
			
		||||
        self.response = requests.get(self.request_url, self.headers)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user