Add AdGuard important list (#172)

* Add adguard-important list command

* Add adguard-important list command to github workflow
This commit is contained in:
Nick Spaargaren 2023-05-01 21:39:33 +02:00 committed by GitHub
parent 616fbc732c
commit c779dc4b96
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 2 deletions

View File

@ -20,9 +20,10 @@ jobs:
- name: Update categories
run: |
python3 convert.py categories
- name: Update AdGuard list
- name: Update AdGuard lists
run: |
python3 convert.py adguard
python3 convert.py adguard-important
- name: Update parsed list
run: |
python3 convert.py pihole

View File

@ -12,6 +12,7 @@ class DomainBlocklistConverter:
PIHOLE_FILE = "google-domains"
UNBOUND_FILE = "pihole-google-unbound.conf"
ADGUARD_FILE = "pihole-google-adguard.txt"
ADGUARD_IMPORTANT_FILE = "pihole-google-adguard-important.txt"
CATEGORIES_PATH = "categories"
BLOCKLIST_ABOUT = "This blocklist helps to restrict access to Google and its domains. Contribute at https://github.com/nickspaargaren/no-google"
@ -83,6 +84,19 @@ class DomainBlocklistConverter:
if entry != "":
f.write(f"||{entry}^\n")
def adguard_important(self):
"""
Produce blocklist for AdGuard including important syntax.
"""
with open(self.ADGUARD_IMPORTANT_FILE, "w") as f:
f.write(f"! {self.BLOCKLIST_ABOUT}\n")
f.write(f"! Last updated: {self.timestamp}\n")
for category, entries in self.data.items():
f.write(f"! {category}\n")
for entry in entries:
if entry != "":
f.write(f"||{entry}^$important\n")
def categories(self):
"""
Produce individual per-category blocklist files.
@ -163,7 +177,7 @@ def run(action: str):
if __name__ == "__main__":
# Read subcommand from command line, with error handling.
action_candidates = ["pihole", "unbound", "adguard", "categories"]
action_candidates = ["pihole", "unbound", "adguard", "adguard_important", "categories"]
special_candidates = ["all", "duplicates", "json"]
subcommand = None
try: