defined __str__ for Url objects, print func should print the url.

This commit is contained in:
Akash Mahanty 2022-01-16 21:22:43 +05:30
parent ce869177fd
commit c8d0ad493a

View File

@ -9,10 +9,16 @@ class Url:
def __init__(self, url, user_agent=DEFAULT_USER_AGENT): def __init__(self, url, user_agent=DEFAULT_USER_AGENT):
self.url = url self.url = url
self.user_agent = str(user_agent) self.user_agent = str(user_agent)
self.archive_url = None
self.wayback_machine_availability_api = WaybackMachineAvailabilityAPI( self.wayback_machine_availability_api = WaybackMachineAvailabilityAPI(
self.url, user_agent=self.user_agent self.url, user_agent=self.user_agent
) )
def __str__(self):
if not self.archive_url:
self.newest()
return self.archive_url
def save(self): def save(self):
self.wayback_machine_save_api = WaybackMachineSaveAPI( self.wayback_machine_save_api = WaybackMachineSaveAPI(
self.url, user_agent=self.user_agent self.url, user_agent=self.user_agent