Updated structure and addition handling

This commit is contained in:
2022-09-04 07:41:15 +02:00
parent a24807af23
commit 32767c4627
19 changed files with 503 additions and 546 deletions

49
combine_lists.py Normal file
View File

@@ -0,0 +1,49 @@
import os
from datetime import datetime
combined_list = []
combined_count = 0
expanded_list = []
expanded_count = 0
blocklists = [f for f in os.listdir("partials")]
for blocklist in blocklists:
count = 0
templist = []
f = open("partials/" + blocklist, "r")
for line in f:
line = line.replace("\n", "").replace("\r", "")
if line.count(".") == 1:
expanded_list.append("www." + line)
expanded_count += 1
templist.append(line)
count += 1
templist.sort()
combined_list.append("# [" + blocklist[:-4] + "]" + " - " + str(count))
combined_list += templist
combined_list.append("")
combined_count += count
full_list = [
"# Host file to block ads, tracking, etc.",
"# Title: Marvins Blacklist",
"# Expires: 1 days",
"# Hosts contributed by Marvin Scham <dev@marvinscham.de>",
"# Domains: "
+ str(combined_count + expanded_count)
+ " ("
+ str(combined_count)
+ " unique)",
"# Last Update: " + datetime.today().strftime("%Y-%m-%d"),
"# ======================================================",
"\n",
]
full_list += combined_list
full_list.append("# [Expanded] - " + str(expanded_count))
expanded_list.sort()
full_list += expanded_list
with open("adlist.txt", "w") as outfile:
outfile.write("\n".join(str(item) for item in full_list))