Compare commits
2 Commits
master
...
missing-ca
Author | SHA1 | Date | |
---|---|---|---|
![]() |
cd39080c01 | ||
![]() |
00e5f694b5 |
23
Makefile
23
Makefile
@ -1,23 +1,20 @@
|
|||||||
CONVERTER = python3 src/converter.py
|
CONVERTER = python3 src/converter.py
|
||||||
BLOCKLISTS = seo-nonsense reflink-spam satire mirror
|
|
||||||
TARGET_FORMATS = adguard ublacklist
|
|
||||||
|
|
||||||
TARGETS = $(foreach blocklist, $(BLOCKLISTS), $(foreach targetformat, $(TARGET_FORMATS), dist/$(blocklist)/$(targetformat).txt))
|
# AdGuard
|
||||||
|
dist/seo-nonsense/adguard.txt:: src/seo-source.json
|
||||||
|
$(CONVERTER) --inputfile src/seo-source.json --targetformat adguard --outputfile dist/seo-nonsense/adguard.txt
|
||||||
|
dist/reflink-spam/adguard.txt:: src/reflink-spam-source.json
|
||||||
|
$(CONVERTER) --inputfile src/reflink-spam-source.json --targetformat adguard --outputfile dist/reflink-spam/adguard.txt
|
||||||
|
dist/satire/adguard.txt:: src/satire-source.json
|
||||||
|
$(CONVERTER) --inputfile src/satire-source.json --targetformat adguard --outputfile dist/satire/adguard.txt
|
||||||
|
dist/mirror/adguard.txt:: src/mirror-source.json
|
||||||
|
$(CONVERTER) --inputfile src/mirror-source.json --targetformat adguard --outputfile dist/mirror/adguard.txt
|
||||||
|
|
||||||
build: $(TARGETS)
|
|
||||||
|
|
||||||
dist/%/adguard.txt: src/%-source.json
|
build: dist/seo-nonsense/adguard.txt dist/reflink-spam/adguard.txt dist/satire/adguard.txt dist/mirror/adguard.txt
|
||||||
mkdir -p dist/$*
|
|
||||||
$(CONVERTER) --inputfile src/$*-source.json --targetformat adguard --outputfile $@
|
|
||||||
|
|
||||||
dist/%/ublacklist.txt: src/%-source.json
|
|
||||||
mkdir -p dist/$*
|
|
||||||
$(CONVERTER) --inputfile src/$*-source.json --targetformat ublacklist --outputfile $@
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf dist/*
|
rm -rf dist/*
|
||||||
|
|
||||||
all: build
|
all: build
|
||||||
|
|
||||||
.PHONY: build clean all
|
|
||||||
|
|
||||||
|
2
dist/mirror/adguard.txt
vendored
2
dist/mirror/adguard.txt
vendored
@ -1,2 +0,0 @@
|
|||||||
! Blocking list automatically generated at 2025-05-25 19:55:20 UTC+0000
|
|
||||||
! Created with ❤️ by internet-czas-dzialac.pl
|
|
2
dist/mirror/ublacklist.txt
vendored
2
dist/mirror/ublacklist.txt
vendored
@ -1,2 +0,0 @@
|
|||||||
# Blocking list automatically generated at 2025-05-25 19:55:20 UTC+0000
|
|
||||||
# Created with ❤️ by internet-czas-dzialac.pl
|
|
2
dist/reflink-spam/adguard.txt
vendored
2
dist/reflink-spam/adguard.txt
vendored
@ -1,2 +0,0 @@
|
|||||||
! Blocking list automatically generated at 2025-05-25 19:55:22 UTC+0000
|
|
||||||
! Created with ❤️ by internet-czas-dzialac.pl
|
|
2
dist/reflink-spam/ublacklist.txt
vendored
2
dist/reflink-spam/ublacklist.txt
vendored
@ -1,2 +0,0 @@
|
|||||||
# Blocking list automatically generated at 2025-05-25 19:55:22 UTC+0000
|
|
||||||
# Created with ❤️ by internet-czas-dzialac.pl
|
|
2
dist/satire/adguard.txt
vendored
2
dist/satire/adguard.txt
vendored
@ -1,2 +0,0 @@
|
|||||||
! Blocking list automatically generated at 2025-05-25 19:55:24 UTC+0000
|
|
||||||
! Created with ❤️ by internet-czas-dzialac.pl
|
|
2
dist/satire/ublacklist.txt
vendored
2
dist/satire/ublacklist.txt
vendored
@ -1,2 +0,0 @@
|
|||||||
# Blocking list automatically generated at 2025-05-25 19:55:24 UTC+0000
|
|
||||||
# Created with ❤️ by internet-czas-dzialac.pl
|
|
@ -52,7 +52,7 @@ def parse_arguments() -> argparse.Namespace:
|
|||||||
"--targetformat",
|
"--targetformat",
|
||||||
required=True,
|
required=True,
|
||||||
metavar="TARGET_FORMAT",
|
metavar="TARGET_FORMAT",
|
||||||
help="Target output format (supported formats: adguard, ublacklist)",
|
help="Target output format (e.g., adguard)",
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--outputfile",
|
"--outputfile",
|
||||||
@ -76,8 +76,6 @@ def convert(data: dict, last_modified: datetime, target_format: str) -> str:
|
|||||||
match target_format:
|
match target_format:
|
||||||
case "adguard":
|
case "adguard":
|
||||||
return adguard_conversion(last_modified, data)
|
return adguard_conversion(last_modified, data)
|
||||||
case "ublacklist":
|
|
||||||
return ublacklist_conversion(last_modified, data)
|
|
||||||
case _:
|
case _:
|
||||||
raise UnsupportedTargetFormatError
|
raise UnsupportedTargetFormatError
|
||||||
|
|
||||||
@ -99,23 +97,6 @@ def adguard_conversion(last_modified: datetime, data: dict) -> list[str]:
|
|||||||
return "\n".join(output)
|
return "\n".join(output)
|
||||||
|
|
||||||
|
|
||||||
def ublacklist_conversion(last_modified: datetime, data: dict) -> list[str]:
|
|
||||||
header_lines: list[str] = [
|
|
||||||
f"# Blocking list automatically generated at {last_modified.strftime('%Y-%m-%d %H:%M:%S %Z%z')}",
|
|
||||||
"# Created with ❤️ by internet-czas-dzialac.pl",
|
|
||||||
]
|
|
||||||
|
|
||||||
output: list[str] = list(header_lines)
|
|
||||||
|
|
||||||
for entry in data["domains"]:
|
|
||||||
fqdn = entry["fqdn"]
|
|
||||||
if entry.get("exclude", False):
|
|
||||||
continue
|
|
||||||
output.append(f"*://*.{fqdn}/*")
|
|
||||||
|
|
||||||
return "\n".join(output)
|
|
||||||
|
|
||||||
|
|
||||||
def dump_output(data: str, output_file: str) -> None:
|
def dump_output(data: str, output_file: str) -> None:
|
||||||
try:
|
try:
|
||||||
directory = os.path.dirname(output_file)
|
directory = os.path.dirname(output_file)
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"domains": []
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"domains": []
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"domains": []
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user