feat: blacklist

This commit is contained in:
2026-06-16 00:24:40 +02:00
parent 3df8cfffc7
commit 015eebd6ed
6 changed files with 1315 additions and 25 deletions
+8 -10
View File
@@ -5,7 +5,8 @@ import typing
import requests
import unidecode
from .cache import Cache
from cool_domain.cache import Cache
from cool_domain.constants import BLACKLIST
class TLDError(Exception):
@@ -29,21 +30,18 @@ class TLDList:
raw_lines = response.content.decode().split("\n")
out_lines = []
for line in raw_lines:
stripped_line = line.strip()
stripped_line = line.strip().lower()
if (
len(stripped_line)
and not stripped_line.startswith("//")
and not stripped_line.startswith("*")
and not stripped_line.startswith("#")
and not stripped_line.startswith("xn--")
and "." not in stripped_line
and unidecode.unidecode(stripped_line) == stripped_line
and stripped_line not in BLACKLIST
):
if "." in stripped_line:
for other in out_lines:
if stripped_line.endswith(other):
break
else:
out_lines += [stripped_line]
else:
out_lines += [stripped_line]
out_lines += [stripped_line]
return out_lines
def load(self) -> None: