-
-
Save scriptsandthings/9789fc83bea7188a8a6b48032448f16f to your computer and use it in GitHub Desktop.
This script adds a plain list of adlists to the adguard configuration AdGuardHome.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
import yaml | |
# load AdGuardHome.yaml | |
with open('AdGuardHome.yaml', 'r') as file: | |
data = yaml.load(file, Loader=yaml.FullLoader) | |
# load file with adlist sources | |
with open('adlists.txt', 'r') as file: | |
urls = file.readlines() | |
new_entries = [] | |
starting_id = 3 # adjust the starting ID as needed | |
for url in urls: | |
url = url.strip() | |
new_filter = { | |
"enabled": True, | |
"url": url, | |
"name": url, | |
"id": starting_id | |
} | |
starting_id += 1 | |
new_entries.append(new_filter) | |
# append the new entries to the existing filters | |
data['filters'] += new_entries | |
# save the new AdGuardHome.yaml_migrated | |
with open('AdGuardHome.yaml_migrated', 'w') as file: | |
yaml.dump(data, file, default_flow_style=False) | |
print("new file created. please compare it to the old file.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment