From 62b5be0b0c8066a65871d1ffa942dc79cc099e78 Mon Sep 17 00:00:00 2001 From: marques <20172333133@m.scnu.edu.cn> Date: Sun, 20 Nov 2022 22:05:49 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=AD=9B=E9=80=89=E6=9D=A1?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- porkbun_ddns.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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)