feat: blacklist
This commit is contained in:
+8
-10
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user