mirror of
https://github.com/KaringX/karing-ruleset.git
synced 2025-06-12 04:24:13 +08:00
SOURCE_REPLACE_DICT for oisd
This commit is contained in:
parent
b13590994c
commit
13b57bb847
@ -26,14 +26,14 @@ from helper.helper import (
|
||||
SING_BOX_EXEC_PATH = None
|
||||
|
||||
ADGUARD_CONFIG_FILTER_LIST = [
|
||||
{
|
||||
'name': 'AdGuardFilter',
|
||||
'source': 'https://raw.githubusercontent.com/AdguardTeam/AdGuardSDNSFilter/master/configuration.json',
|
||||
},
|
||||
{
|
||||
'name': 'PopupFilter',
|
||||
'source': 'https://raw.githubusercontent.com/AdguardTeam/AdGuardSDNSFilter/master/configuration_popup_filter.json',
|
||||
},
|
||||
# {
|
||||
# 'name': 'AdGuardFilter',
|
||||
# 'source': 'https://raw.githubusercontent.com/AdguardTeam/AdGuardSDNSFilter/master/configuration.json',
|
||||
# },
|
||||
# {
|
||||
# 'name': 'PopupFilter',
|
||||
# 'source': 'https://raw.githubusercontent.com/AdguardTeam/AdGuardSDNSFilter/master/configuration_popup_filter.json',
|
||||
# },
|
||||
{
|
||||
'name': 'ppfeuferFilter',
|
||||
'source': 'https://raw.githubusercontent.com/ppfeufer/adguard-filter-list/master/hostlist-compiler-config.json',
|
||||
@ -42,7 +42,7 @@ ADGUARD_CONFIG_FILTER_LIST = [
|
||||
|
||||
SOURCE_REPLACE_DICT = {
|
||||
# # Get OISD list, since the HostlistCompiler can't fetch it for whatever reason » https://github.com/AdguardTeam/HostlistCompiler/issues/58
|
||||
'../oisd.txt': 'https://big.oisd.nl/',
|
||||
"../oisd.txt": "https://big.oisd.nl/",
|
||||
}
|
||||
|
||||
|
||||
@ -100,8 +100,6 @@ def main(out_path: str = None):
|
||||
|
||||
def compile_filterlist(out_path: str, item: dict):
|
||||
source = item['source']
|
||||
if source in SOURCE_REPLACE_DICT:
|
||||
source = SOURCE_REPLACE_DICT[source]
|
||||
|
||||
name = correct_name(item['name'])
|
||||
out_path2 = os.path.join(out_path, name)
|
||||
@ -133,9 +131,11 @@ def compile_filterlist(out_path: str, item: dict):
|
||||
|
||||
|
||||
def compile_filterone(out_path: str, item: dict) -> bool:
|
||||
name = correct_name(item['name'])
|
||||
source = item['source']
|
||||
if source in SOURCE_REPLACE_DICT:
|
||||
source = SOURCE_REPLACE_DICT[source]
|
||||
|
||||
name = correct_name(item['name'])
|
||||
debug_log(f"\n\tdownloading [ {name} ] => {source}")
|
||||
content = get_url_content(source)
|
||||
if content is None:
|
||||
|
@ -59,13 +59,16 @@ def correct_name(text: str) -> str:
|
||||
# Apply the replacements
|
||||
replaced_text = ''.join(replacements.get(c, c) for c in text)
|
||||
|
||||
# Collapse consecutive "-" into a single "-"
|
||||
# Collapse consecutive "-" or "_" into a single "_"
|
||||
collapsed_text = re.sub(r'-+', '-', replaced_text)
|
||||
collapsed_text = re.sub(r'_+', '_', collapsed_text)
|
||||
|
||||
# Remove trailing "-" or "_"
|
||||
final_text = re.sub(r'[-_]+$', '', collapsed_text)
|
||||
|
||||
# Replace "-_" and "_-" with "_"
|
||||
final_text = re.sub(r'-_|_-', '_', final_text)
|
||||
|
||||
return final_text
|
||||
|
||||
|
||||
@ -78,6 +81,7 @@ def remove_ansi_escape_codes(text: str) -> str:
|
||||
if __name__ == '__main__':
|
||||
# text = "example string//with spaces---and////slashes"
|
||||
text = 'uBlock-filters-–-Resource-abuse-'
|
||||
text = 'Dandelion-Sprouts-Anti-Malware-List-_for-AdGuard-Home-and-for-AdGuard-for-Android_Windows-DNS-filtering'
|
||||
print(correct_name(text))
|
||||
|
||||
# text = '\x1b[36mINFO\x1b[0m[0000] parsed rules: 778/1450'
|
||||
|
Loading…
x
Reference in New Issue
Block a user