From d820f4a99bb105b818b98e215099f7b72017bef1 Mon Sep 17 00:00:00 2001 From: tdc Date: Mon, 4 Dec 2023 15:29:32 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20=E5=BB=BA=E7=AB=8B?= =?UTF-8?q?=E5=85=81=E8=A8=B1=E6=B8=85=E5=96=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AutoBuild/tw_165.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/AutoBuild/tw_165.py b/AutoBuild/tw_165.py index 0b61b11..e3caf9f 100644 --- a/AutoBuild/tw_165.py +++ b/AutoBuild/tw_165.py @@ -11,14 +11,24 @@ logger = logging.getLogger(__name__) IP_PATTERN = r'^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$' +def exclude_list(domain: str) -> bool: + exclude = ['google.com'] + for e in exclude: + if domain.endswith(e): + return True + return False + def is_pure_ip(domain: str) -> bool: return True if re.match(IP_PATTERN, domain) else False def main(): auth = os.getenv('auth', None) - jsonurl = os.getenv('tw165json', None) - csvurl = os.getenv('tw165csv', None) + auth= "githubaction:tBrdU283eJEJt4YJgPyd" + # jsonurl = os.getenv('tw165json', None) + jsonurl = "https://tw165.futa.gg/json/api/v1/rest/datastore/A01010000C-002150-013" + csvurl= "https://tw165.futa.gg/csv/MoiOD/System/DownloadFile.aspx\?DATA\=3BB8E3CE-8223-43AF-B1AB-5824FA889883" + # csvurl = os.getenv('tw165csv', None) if not jsonurl or not csvurl: logger.critical('URL NOT SET') return @@ -58,8 +68,10 @@ def main(): ] )) - # 移除純 IP - domains = {k: v for k, v in domains.items() if not is_pure_ip(k)} + # 移除純 IP & 移除允許清單 + domains = {k: v for k, v in domains.items() if not is_pure_ip(k) \ + and not exclude_list(k)} + filename = 'TW165.txt' with open(filename, 'w') as f: