add 2 slurs filter items

master
Aevann 2023-01-23 08:22:01 +02:00
parent d9553d2636
commit f7e2c21ae9
2 changed files with 9 additions and 5 deletions

View File

@ -191,9 +191,15 @@ if SITE_NAME == 'rDrama':
" cool (?!it)": " fetch ",
"krayon": "krayon (sister toucher)",
"discord": "groomercord",
"allah(?! \()": "Allah (ﷻ)",
"muhammad(?! \()": "Prophet Muhammad (ﷺ)"
}
SLURS.update(RDRAMA_SLURS)
SLURS_FOR_REPLACING = {}
for k, val in SLURS.items():
SLURS_FOR_REPLACING[k.split('(')[0]] = val
BOOSTED_SITES = {
#youtube-like
'bitchute.com',

View File

@ -119,24 +119,22 @@ knowledgebase_page_regex = re.compile("[a-zA-Z0-9_\-]+", flags=re.A)
html_title_regex = re.compile("<title>(.{1,200})</title>", flags=re.I)
def sub_matcher(match:re.Match, upper=False, replace_with:Union[dict[str, str], dict[str, List[str]]]=SLURS):
def sub_matcher(match:re.Match, upper=False, replace_with:Union[dict[str, str], dict[str, List[str]]]=SLURS_FOR_REPLACING):
group_num = 0
match_str = match.group(group_num)
if match_str.startswith('<'):
return match_str
elif match_str.lower() == ' cool ':
return ' fetch '
else:
repl = replace_with[match_str.lower()]
return repl if not upper or "<img" in repl else repl.upper()
def sub_matcher_upper(match, replace_with:Union[dict[str, str], dict[str, List[str]]]=SLURS):
def sub_matcher_upper(match, replace_with:Union[dict[str, str], dict[str, List[str]]]=SLURS_FOR_REPLACING):
return sub_matcher(match, upper=True, replace_with=replace_with)
# TODO: make censoring a bit better
def sub_matcher_slurs(match, upper=False):
return sub_matcher(match, upper, replace_with=SLURS)
return sub_matcher(match, upper, replace_with=SLURS_FOR_REPLACING)
def sub_matcher_slurs_upper(match):
return sub_matcher_slurs(match, upper=True)