-
Notifications
You must be signed in to change notification settings - Fork 3
/
create_list.py
385 lines (354 loc) · 24.5 KB
/
create_list.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
"""Creates a consolidated blocklist for many source files."""
# Downloads blocklists, combines them to one list,
# sorts all lines, makes lines unique, and then removes comment lines
# The final AIO list is: aio_blocklist_final.txt
# FOR ADGUARD HOME ONLY
# Tested and working on Python for Windows Python 3.12.4 or later.
# Required Python Packages:
# - "requests" is required to handle 403 errors (install that package first by running: python -m pip install requests)
# - "rich" is required for colored text output
# Version: 0.3
# Date: 2024-07-15 05:33:16PM
# Imports
from time import gmtime, strftime
from datetime import datetime, timezone
from urllib.request import urlretrieve
import requests
from rich import print
import glob
import os
# from tqdm import tqdm
#from urllib.request import Request, urlopen
#import requests
#from random import seed
#CURRENTWORKINGDIRECTORY = os.getcwd() + "\\"
CURRENTWORKINGDIRECTORY = "C:\\Users\\Dean\\Documents\\Important\\MEGASync\\GitHub\\CodeLibrary\\Python\\AdGuard-Home-AIO-List-main\\"
# NOW = strftime("%Y-%m-%d %H:%M:%S", gmtime())
URLS = [
# AdGuard Simplified Domain Names filter
"https://adguardteam.github.io/AdGuardSDNSFilter/Filters/filter.txt",
# 🔮 Most Abused TLDs
"https://raw.githubusercontent.com/hagezi/dns-blocklists/main/adblock/spam-tlds.txt",
# 1Hosts (Lite)
"https://adguardteam.github.io/HostlistsRegistry/assets/filter_24.txt",
# AdGuard DNS filter
"https://adguardteam.github.io/HostlistsRegistry/assets/filter_1.txt",
# OISD Blocklist Small
"https://adguardteam.github.io/HostlistsRegistry/assets/filter_5.txt",
# Phishing URL Blocklist (PhishTank and OpenPhish)
"https://adguardteam.github.io/HostlistsRegistry/assets/filter_30.txt",
# Scam Blocklist by DurableNapkin
"https://adguardteam.github.io/HostlistsRegistry/assets/filter_10.txt",
# The Big List of Hacked Malware Web Sites
"https://adguardteam.github.io/HostlistsRegistry/assets/filter_9.txt",
# Malicious URL Blocklist (URLHaus)
"https://adguardteam.github.io/HostlistsRegistry/assets/filter_11.txt",
# Phishing Army
"https://adguardteam.github.io/HostlistsRegistry/assets/filter_18.txt",
# ShadowWhisperer's Malware List
"https://adguardteam.github.io/HostlistsRegistry/assets/filter_42.txt",
# Stalkerware Indicators List
"https://adguardteam.github.io/HostlistsRegistry/assets/filter_31.txt",
# uBlock₀ filters - Badware risks
"https://adguardteam.github.io/HostlistsRegistry/assets/filter_50.txt",
# Steven Black's List
"https://adguardteam.github.io/HostlistsRegistry/assets/filter_33.txt",
# Peter Lowe's Blocklist
"https://adguardteam.github.io/HostlistsRegistry/assets/filter_3.txt",
# Dandelion Sprout's Anti Push Notifications
"https://adguardteam.github.io/HostlistsRegistry/assets/filter_39.txt",
# AdAway Default Blocklist
"https://adguardteam.github.io/HostlistsRegistry/assets/filter_2.txt",
# Dan Pollock's List
"https://adguardteam.github.io/HostlistsRegistry/assets/filter_4.txt",
# WindowsSpyBlocker - Hosts spy rules
"https://adguardteam.github.io/HostlistsRegistry/assets/filter_23.txt",
# Dandelion Sprout's Anti-Malware List
"https://adguardteam.github.io/HostlistsRegistry/assets/filter_12.txt",
# ph00lt0 / blocklist : https://github.com/ph00lt0/blocklist
"https://raw.githubusercontent.com/ph00lt0/blocklists/master/blocklist.txt",
# Deanoman - tracker_list_adguard_home
"https://raw.githubusercontent.com/hl2guide/AdGuard-Home-AIO-List/main/tracker_list_adguard_home.txt",
# blocklistproject ads-ags.txt : https://github.com/blocklistproject/Lists
"https://blocklistproject.github.io/Lists/adguard/ads-ags.txt",
# blocklistproject crypto-ags.txt : https://github.com/blocklistproject/Lists
"https://blocklistproject.github.io/Lists/adguard/crypto-ags.txt",
# blocklistproject drugs-ags.txt : https://github.com/blocklistproject/Lists
"https://blocklistproject.github.io/Lists/adguard/drugs-ags.txt",
# blocklistproject fraud-ags.txt : https://github.com/blocklistproject/Lists
"https://blocklistproject.github.io/Lists/adguard/fraud-ags.txt",
# blocklistproject phishing-ags.txt : https://github.com/blocklistproject/Lists
"https://blocklistproject.github.io/Lists/adguard/phishing-ags.txt",
# blocklistproject ransomware-ags.txt : https://github.com/blocklistproject/Lists
"https://blocklistproject.github.io/Lists/adguard/ransomware-ags.txt",
# blocklistproject scam-ags.txt : https://github.com/blocklistproject/Lists
"https://blocklistproject.github.io/Lists/adguard/scam-ags.txt",
# blocklistproject tracking-ags.txt : https://github.com/blocklistproject/Lists
"https://blocklistproject.github.io/Lists/adguard/tracking-ags.txt",
# Multi PRO - Extended protection : https://github.com/hagezi/dns-blocklists
"https://raw.githubusercontent.com/hagezi/dns-blocklists/main/adblock/pro.txt",
# Anudeep's Blacklist : https://github.com/anudeepND/blacklist
"https://raw.githubusercontent.com/anudeepND/blacklist/master/adservers.txt",
# romainmarcoux / malicious-ip : https://github.com/romainmarcoux/malicious-ip
"https://raw.githubusercontent.com/romainmarcoux/malicious-ip/main/full-40k.txt",
# borestad / blocklist-abuseipdb : https://github.com/borestad/blocklist-abuseipdb
"https://raw.githubusercontent.com/borestad/blocklist-abuseipdb/main/abuseipdb-s100-60d.ipv4",
# ipsum : https://github.com/stamparm/ipsum
"https://raw.githubusercontent.com/stamparm/ipsum/master/levels/3.txt",
# Sefinek-Blocklist-Collection (many lists) - https://sefinek.net/blocklist-generator/adguard
"https://blocklist.sefinek.net/generated/v1/adguard/abuse/blocklistproject/hosts.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/abuse/urlhaus.abuse.ch/hostfile.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/ads/0Zinc/easylist.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/ads/DandelionSprout.GameConsoleAdblockList.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/ads/FadeMind/UncheckyAds.fork.txt",
#"https://blocklist.sefinek.net/generated/v1/adguard/ads/MajkiIT/SmartTV-ads.fork.txt", # Testing Samsung TV login issues 05.06.2024
"https://blocklist.sefinek.net/generated/v1/adguard/ads/ShadowWhisperer/Ads.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/ads/adaway/hosts.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/ads/anudeepND/adservers.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/ads/blocklistproject/hosts.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/ads/blocklistproject/youtube.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/ads/craiu/mobiletrackers.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/ads/crazy-max/spy.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/ads/disconnectme/simple-ad.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/ads/firebog/AdguardDNS.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/ads/firebog/Admiral.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/ads/firebog/Easylist.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/ads/firebog/Prigent-Ads.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/ads/jerryn70/GoodbyeAds.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/ads/r-a-y/AdguardMobileAds.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/ads/sefinek.hosts.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/ads/yoyo/ads-trackers-etc.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/amp/developerdan/amp-hosts-extended.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/amp/ente-dev/google-amp-hosts.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/anime/myanimelist.net.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/anime/shinden.pl.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/apps/whatsapp.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/crypto/cryptojacking/Snota418/Crypto-streams.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/crypto/cryptojacking/firebog/Prigent/Crypto.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/crypto/cryptojacking/hoshsadiq/adblock-nocoin-list.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/crypto/cryptojacking/zerodot1/CoinBlockerLists-hosts.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/crypto/sites/sefinek.hosts.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/dating-services/developerdan/extended.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/dead-domains/jarelllama/dead-domains.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/drugs/blocklistproject/drugs.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/extensions/FadeMind/add-2o7Net.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/extensions/MajkiIT/adguard-host.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/extensions/MajkiIT/easy-privacy-host.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/extensions/cbuijs/adult-domains-24733.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/extensions/deathbybandaid/CountryCodesLists-France.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/extensions/deathbybandaid/ParsedBlacklists-EasyList-Liste-FR.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/extensions/deathbybandaid/ParsedBlacklists-EasyList.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/extensions/hagezi/pro.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/extensions/justdomains/adguarddns-justdomains.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/extensions/oisd/big.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/extensions/r-a-y/AdguardApps.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/extensions/r-a-y/AdguardMobileSpyware.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/fakenews/StevenBlack/hosts.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/fakenews/marktron/hosts.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/fraud/blocklistproject/hosts.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/gambling/MajkiIT/gambling-hosts.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/gambling/StevenBlack/hosts.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/gambling/TrustPositif/gambling-indonesia.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/gambling/blocklistproject/hosts.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/gambling/sefinek.hosts.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/games/league-of-legends.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/games/valorant.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/hate-and-junk/developerdan/extended.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/malicious/AssoEchap/stalkerware-indicators.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/malicious/DandelionSprout-AntiMalwareHosts.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/malicious/RPiList/Malware.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/malicious/Spam404/main-blacklist.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/malicious/bigdargon/hostsVN.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/malicious/blocklistproject/malware.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/malicious/digitalside/latestdomains.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/malicious/disconnectme/simple-malvertising.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/malicious/malware-filter/urlhaus-filter-hosts-online.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/malicious/phishing.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/malicious/quidsup/notrack-malware.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/malicious/reported-by-norton.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/malicious/sefinek.hosts1.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/malicious/sefinek.hosts2.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/malicious/suspicious.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/malicious/web-attacks.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/phishing/Dogino/Discord-Phishing-URLs-phishing.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/phishing/RPiList/Phishing-Angriffe.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/phishing/blocklistproject/phishing.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/phishing/phishing.army/blocklist-extended.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/porn/4skinSkywalker/hosts.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/porn/Sinfonietta/pornography-hosts.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/porn/StevenBlack/porn.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/porn/blocklistproject/porn.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/porn/chadmayfield/pi-blocklist-porn-all.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/porn/oisd/nsfw.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/porn/sefinek.hosts.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/ransomware/blocklistproject/ransomware.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/redirect/blocklistproject/redirect.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/scam/Dogino/Discord-Phishing-URLs-scam.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/scam/blocklistproject/scam.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/scam/durablenapkin/scamblocklist.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/scam/jarelllama/scam.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/sites/booth.pm.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/sites/gamebanana.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/sites/omegle.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/sites/patreon.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/sites/pinterest.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/sites/pixiv.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/sites/riotgames.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/social/facebook.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/social/instagram.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/social/snapchat.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/social/tiktok.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/social/twitter.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/spam/FadeMind/add-Spam.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/spam/RPiList/spam-mails.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/spam/stopforumspam/toxic-domains-whole.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/suspicious/FadeMind/add-Risk.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/suspicious/firebog/w3kbl.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/test.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/tracking-and-telemetry/0Zinc/easyprivacy.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/tracking-and-telemetry/MajkiIT/adguard-mobile-host.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/tracking-and-telemetry/ente-dev/tv.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/tracking-and-telemetry/frogeye/firstparty-trackers-hosts.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/tracking-and-telemetry/mitchellkrogza/INACTIVE.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/tracking-and-telemetry/neodevpro/host.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/tracking-and-telemetry/quidsup/trackers-hosts.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/useless-websites/jarelllama/parked-domains.fork.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/useless-websites/sefinek.hosts.txt",
"https://blocklist.sefinek.net/generated/v1/adguard/dating-services/ShadowWhisperer/dating.fork.txt", # Testing 0.3
"https://blocklist.sefinek.net/generated/v1/adguard/dating-services/sefinek.hosts.txt", # Testing 0.3
"https://blocklist.sefinek.net/generated/v1/adguard/malicious/ShadowWhisperer/malware.fork.txt", # Testing 0.3
"https://blocklist.sefinek.net/generated/v1/adguard/scam/ShadowWhisperer/scam.fork.txt", # Testing 0.3
"https://blocklist.sefinek.net/generated/v1/adguard/tracking-and-telemetry/ShadowWhisperer/tracking.fork.txt", # Testing 0.3
#"https://hosts.anudeep.me/mirror/adservers.txt"
# LostAd [TOO BIG]
#"https://raw.githubusercontent.com/lennihein/LostAd/main/lostad_dns.txt",
# ppfeufer / adguard-filter-list [TOO BIG]
#"https://raw.githubusercontent.com/ppfeufer/adguard-filter-list/master/blocklist",
# HaGeZi's Pro DNS Blocklist [TOO BIG]
#"https://raw.githubusercontent.com/hagezi/dns-blocklists/main/adblock/pro.txt",
# HaGeZi's The World's Most Abused TLDs
#"https://raw.githubusercontent.com/hagezi/dns-blocklists/main/adblock/spam-tlds.txt",
# HaGeZi's Gambling DNS Blocklist [TOO BIG]
#"https://raw.githubusercontent.com/hagezi/dns-blocklists/main/adblock/gambling.txt",
# Steven Black's List [INCLUDED ALREADY]
#"https://adguardteam.github.io/HostlistsRegistry/assets/filter_33.txt",
# OISD Blockist Big
#"https://adguardteam.github.io/HostlistsRegistry/assets/filter_27.txt",
# AdGuard Simplified Domain Names filter
#"https://adguardteam.github.io/AdGuardSDNSFilter/Filters/filter.txt"
]
UTC_DT = datetime.now(timezone.utc) # UTC time
NOW = str(UTC_DT.astimezone()) # local time
def refreshDateTimeToNow():
UTC_DT = datetime.now(timezone.utc) # UTC time
NOW = str(UTC_DT.astimezone()) # local time
return NOW
NOW = refreshDateTimeToNow()
#pbarCollection = tqdm(URLS)
# Downloads the individual lists
for URL in URLS:
LIST_INDEX = URLS.index(URL)
FILENAME = CURRENTWORKINGDIRECTORY + "downloaded_lists\\blocklist" + str(LIST_INDEX) + ".txt"
#print(NOW+" - "+"Downloading: " + URL + " >> " + FILENAME)
# urlretrieve(URL, FILENAME)
# NOW = strftime("%Y-%m-%d %H:%M:%S", gmtime())
#pbarCollection.set_description("Downloading List " + str(LIST_INDEX))
#print("\n")
# Uses a workaround for 403 errors by applying a better "User-Agent" header to the request
if URL.startswith("https://blocklist.sefinek.net/"):
print(NOW+" - "+"Downloading: " + URL)
print("to: " + FILENAME)
# print("\n")
HEADERS = {
'User-Agent': 'Mozilla 5.0',
}
RESPONSE = requests.get(URL, headers=HEADERS)
CONTENT = RESPONSE.text
if RESPONSE.status_code == 200:
with open(FILENAME, "w", encoding='utf8') as file:
file.write(CONTENT)
NOW = refreshDateTimeToNow()
else:
print(NOW+" - "+"Downloading: " + URL)
print("to: " + FILENAME)
#print("\n")
urlretrieve(URL, FILENAME)
NOW = refreshDateTimeToNow()
# os.system('cls')
# Merges lists into one file
# Source: https://bobbyhadz.com/blog/merge-text-files-in-python#how-to-merge-text-files-in-python
file_paths = glob.glob(CURRENTWORKINGDIRECTORY + 'downloaded_lists/*.txt')
with open(CURRENTWORKINGDIRECTORY + 'aio_blocklist.txt', 'w', encoding='utf-8') as output_file:
for file_path in file_paths:
with open(file_path, 'r', encoding='utf-8') as input_file:
output_file.write(input_file.read() + '\n')
NOW = refreshDateTimeToNow()
# Removes individual text files
I = 0
while I < len(URLS):
print(NOW+" - "+"Removing: downloaded_lists/blocklist"+str(I)+".txt")
os.remove(CURRENTWORKINGDIRECTORY + "downloaded_lists/blocklist"+str(I)+".txt")
I = I + 1
NOW = refreshDateTimeToNow()
# Cleans aio_blocklist.txt file
print(NOW+" - "+"Cleaning aio_blocklist.txt, please wait..")
# Open the file
UNIQUELINES = set(open(CURRENTWORKINGDIRECTORY + 'aio_blocklist.txt', 'r', encoding='utf-8').readlines())
# Sort all lines in the set
UNIQUELINES = sorted(UNIQUELINES)
# Removes duplicates from from text file
CLEANEDOUTPUT = open(CURRENTWORKINGDIRECTORY + 'aio_blocklist.txt', 'w', encoding='utf-8').writelines(UNIQUELINES)
NOW = refreshDateTimeToNow()
# Removes all junk from aio_blocklist.txt file
print(NOW+" - "+"Removing junk lines from aio_blocklist.txt, please wait..")
with open(CURRENTWORKINGDIRECTORY + "aio_blocklist.txt", "r", encoding='utf-8') as f:
LINES = f.readlines()
with open(CURRENTWORKINGDIRECTORY + "aio_blocklist_final.txt", "w", encoding='utf-8') as new_f:
for line in LINES:
if not line.startswith("!") and not line.startswith("#") and not line.startswith("@@") \
and not line.startswith("$removeparam=") and not line.startswith("*") \
and not line.startswith("-") and not line.startswith(".") and not line.startswith("/"):
# Removes line prefixes
line = line.replace('0.0.0.0 ','')
line = line.replace('127.0.0.1 ','')
if line.endswith('^'):
line = line.replace('^','^$important')
if not line.startswith("/") and not line.startswith("||") and not line.startswith("*") \
and not line.startswith("-") and not line.startswith("."):
line = '||' + line
line = line.replace('||||','||')
line = line.replace('^','^$important')
if not (line == '') and not (line == ' ') and not (line == '||') and not (line == '##'):
line = line.replace('^','^$important')
line = line.replace('||||','||')
line = line.replace('|||','||')
line = line.replace('||','|') # Implemented a fix to skip subdomain blocking
line = line.replace('$important$important','$important')
new_f.write(line)
os.remove(CURRENTWORKINGDIRECTORY + "aio_blocklist.txt")
NOW = refreshDateTimeToNow()
# Cleans aio_blocklist_final.txt file
print(NOW+" - "+"Cleaning aio_blocklist_final.txt, please wait..")
# Open the file
UNIQUELINES = set(open(CURRENTWORKINGDIRECTORY + 'aio_blocklist_final.txt', 'r', encoding='utf-8').readlines())
# Sort all lines in the set
UNIQUELINES = sorted(UNIQUELINES)
# Remove invalid line = ||
#UNIQUELINES.remove("\|\|")
# Removes duplicates from from text file
CLEANEDOUTPUT = open(CURRENTWORKINGDIRECTORY + 'aio_blocklist_final.txt', 'w', encoding='utf-8').writelines(UNIQUELINES)
NOW = refreshDateTimeToNow()
print(NOW+" - "+"AIO list has been generated as: aio_blocklist_final.txt")
# Writes to HISTORY.md file
with open(CURRENTWORKINGDIRECTORY + "HISTORY.md", "a", encoding='utf-8') as HISTORYFILE:
HISTORYFILE.write("- Updated "+NOW+"\n")
NOW = refreshDateTimeToNow()
# NOW = strftime("%Y-%m-%d %H:%M:%S", gmtime())
print(NOW+" - "+"Updated: HISTORY.md")
# Version 0.3 changes:
# - added fix to skip blocking subdomains
# - added color text output using "rich" package
# - added more lists
# - fixed datetime now to be local time
# - improved output
#