diff --git a/porkbun_ddns.py b/porkbun_ddns.py index 4d6f638..2adcf54 100644 --- a/porkbun_ddns.py +++ b/porkbun_ddns.py @@ -62,7 +62,7 @@ class PorkbunAPI: return response.status_code - def find_record(self, _type: "str" = None, name: "str" = None, content: "str" = None, verbose: "bool" = True): + def find_record(self, _type: "str" = None, name: "str" = None, content: "str" = None, ttl: "int" = None, verbose: "bool" = True): records = {} def filter_fun(x): @@ -72,6 +72,8 @@ class PorkbunAPI: return False if content is not None and self.__records[x]["content"] != content: return False + if ttl is not None and int(self.__records[x]["ttl"]) != ttl: + return False return True for i in filter(filter_fun, self.__records): @@ -174,9 +176,9 @@ class PorkbunAPI: print("response code is ", response.status_code) print(response.json()) - def edit_A_with_name(self, name: "str", content: "str" = "1.1.1.1"): + def edit_A_with_name(self, name: "str", content: "str" = "1.1.1.1", ttl: "int" = None): self.retrieve(verbose=False) - result = self.find_record(_type="A", name=name, verbose=False) + result = self.find_record(_type="A", name=name, ttl=ttl, verbose=False) if len(result) != 1: print("Multiple records are selected") self.find_record(_type="A", name=name)