mirror of
https://github.com/nickspaargaren/no-google.git
synced 2023-12-13 21:00:26 +01:00
Add AdGuard important list (#172)
* Add adguard-important list command * Add adguard-important list command to github workflow
This commit is contained in:
parent
616fbc732c
commit
c779dc4b96
2 changed files with 17 additions and 2 deletions
3
.github/workflows/automated-updates.yml
vendored
3
.github/workflows/automated-updates.yml
vendored
|
@ -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
|
||||
|
|
16
convert.py
16
convert.py
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue