Skip to content
This repository was archived by the owner on Jan 12, 2025. It is now read-only.

Commit 57d3850

Browse files
authored
v0.3
1 parent 3b08524 commit 57d3850

2 files changed

Lines changed: 70 additions & 23 deletions

File tree

README.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,16 @@
22

33
An All-In-One AdGuard Home blocklist and allowlist generated locally on your PC using Python.
44

5-
Version: 0.2
5+
Version: 0.3
66

7-
Updated (AEST): 2024-06-14 01:32:25AM
7+
Updated (AEST): 2024-07-15 05:38:23PM
8+
9+
## ✨ What's New in 0.3
10+
- added fix to skip blocking subdomains
11+
- added color text output using "rich" package
12+
- added more lists
13+
- fixed datetime now to be local time
14+
- improved output
815

916
## ✨ What's New in 0.2
1017
- Added new must-have requirement of a Python package named [__requests__](https://pypi.org/project/requests/)
@@ -18,7 +25,7 @@ Updated (AEST): 2024-06-14 01:32:25AM
1825
- The blocklist will make AdGuard Home's RAM usage increase to around **775MB**
1926
- Do not use these lists on older hardware with fewer than **4 CPU cores** or **IOT** devices
2027
- Be prepared to make your own whitelist additions within AdGuard Home, depending on your needs
21-
- I attempted and tested using **GitHub Codespaces** and **github LFS** but moved away from both due to filesize restrictions
28+
- I attempted and tested using **GitHub Codespaces** and **github LFS** but moved away from both due to annoying filesize restrictions
2229

2330
## ⛔ Included Blocklists
2431

@@ -64,10 +71,11 @@ Updated (AEST): 2024-06-14 01:32:25AM
6471
## ⚒️ Setup
6572

6673
1. Install [Python](https://www.python.org) on your device
67-
2. Install a required Python package "requests" by running:
74+
2. Install two required Python packages by running:
6875

6976
```
7077
python -m pip install requests
78+
python -m pip install rich
7179
```
7280

7381
- The python script `create_list.py` can be used to generate `aio_blocklist_final.txt` on a local machine that has Python

create_list.py

Lines changed: 58 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,32 @@
77

88
# FOR ADGUARD HOME ONLY
99

10-
# Required Packages
11-
# A python package called "requests" is required to handle 403 errors (install that package first by running: python -m pip install requests)
10+
# Tested and working on Python for Windows Python 3.12.4 or later.
1211

13-
# Version: 0.2
14-
# Date: 2024-06-14 01:20:58AM
12+
# Required Python Packages:
13+
# - "requests" is required to handle 403 errors (install that package first by running: python -m pip install requests)
14+
# - "rich" is required for colored text output
15+
16+
# Version: 0.3
17+
# Date: 2024-07-15 05:33:16PM
1518

1619
# Imports
1720
from time import gmtime, strftime
21+
from datetime import datetime, timezone
1822
from urllib.request import urlretrieve
1923
import requests
24+
from rich import print
25+
import glob
26+
import os
27+
# from tqdm import tqdm
2028
#from urllib.request import Request, urlopen
2129
#import requests
2230
#from random import seed
23-
import glob
24-
import os
2531

2632
#CURRENTWORKINGDIRECTORY = os.getcwd() + "\\"
2733
CURRENTWORKINGDIRECTORY = "C:\\Users\\Dean\\Documents\\Important\\MEGASync\\GitHub\\CodeLibrary\\Python\\AdGuard-Home-AIO-List-main\\"
2834

29-
NOW = strftime("%Y-%m-%d %H:%M:%S", gmtime())
35+
# NOW = strftime("%Y-%m-%d %H:%M:%S", gmtime())
3036

3137
URLS = [
3238
# AdGuard Simplified Domain Names filter
@@ -218,6 +224,11 @@
218224
"https://blocklist.sefinek.net/generated/v1/adguard/tracking-and-telemetry/quidsup/trackers-hosts.fork.txt",
219225
"https://blocklist.sefinek.net/generated/v1/adguard/useless-websites/jarelllama/parked-domains.fork.txt",
220226
"https://blocklist.sefinek.net/generated/v1/adguard/useless-websites/sefinek.hosts.txt",
227+
"https://blocklist.sefinek.net/generated/v1/adguard/dating-services/ShadowWhisperer/dating.fork.txt", # Testing 0.3
228+
"https://blocklist.sefinek.net/generated/v1/adguard/dating-services/sefinek.hosts.txt", # Testing 0.3
229+
"https://blocklist.sefinek.net/generated/v1/adguard/malicious/ShadowWhisperer/malware.fork.txt", # Testing 0.3
230+
"https://blocklist.sefinek.net/generated/v1/adguard/scam/ShadowWhisperer/scam.fork.txt", # Testing 0.3
231+
"https://blocklist.sefinek.net/generated/v1/adguard/tracking-and-telemetry/ShadowWhisperer/tracking.fork.txt", # Testing 0.3
221232

222233
#"https://hosts.anudeep.me/mirror/adservers.txt"
223234
# LostAd [TOO BIG]
@@ -238,19 +249,34 @@
238249
#"https://adguardteam.github.io/AdGuardSDNSFilter/Filters/filter.txt"
239250
]
240251

241-
NOW = strftime("%Y-%m-%d %H:%M:%S", gmtime())
252+
UTC_DT = datetime.now(timezone.utc) # UTC time
253+
NOW = str(UTC_DT.astimezone()) # local time
254+
255+
def refreshDateTimeToNow():
256+
UTC_DT = datetime.now(timezone.utc) # UTC time
257+
NOW = str(UTC_DT.astimezone()) # local time
258+
return NOW
259+
260+
NOW = refreshDateTimeToNow()
261+
262+
#pbarCollection = tqdm(URLS)
242263

243264
# Downloads the individual lists
244265
for URL in URLS:
245266
LIST_INDEX = URLS.index(URL)
246267
FILENAME = CURRENTWORKINGDIRECTORY + "downloaded_lists\\blocklist" + str(LIST_INDEX) + ".txt"
247-
# print(NOW+" - "+"Downloading: " + URL + " >> " + FILENAME)
268+
#print(NOW+" - "+"Downloading: " + URL + " >> " + FILENAME)
248269
# urlretrieve(URL, FILENAME)
249270
# NOW = strftime("%Y-%m-%d %H:%M:%S", gmtime())
250271

272+
#pbarCollection.set_description("Downloading List " + str(LIST_INDEX))
273+
#print("\n")
274+
251275
# Uses a workaround for 403 errors by applying a better "User-Agent" header to the request
252276
if URL.startswith("https://blocklist.sefinek.net/"):
253-
print(NOW+" - "+"Downloading: " + URL + " >> " + FILENAME)
277+
print(NOW+" - "+"Downloading: " + URL)
278+
print("to: " + FILENAME)
279+
# print("\n")
254280
HEADERS = {
255281
'User-Agent': 'Mozilla 5.0',
256282
}
@@ -259,11 +285,14 @@
259285
if RESPONSE.status_code == 200:
260286
with open(FILENAME, "w", encoding='utf8') as file:
261287
file.write(CONTENT)
262-
NOW = strftime("%Y-%m-%d %H:%M:%S", gmtime())
288+
NOW = refreshDateTimeToNow()
263289
else:
264-
print(NOW+" - "+"Downloading: " + URL + " >> " + FILENAME)
290+
print(NOW+" - "+"Downloading: " + URL)
291+
print("to: " + FILENAME)
292+
#print("\n")
265293
urlretrieve(URL, FILENAME)
266-
NOW = strftime("%Y-%m-%d %H:%M:%S", gmtime())
294+
NOW = refreshDateTimeToNow()
295+
# os.system('cls')
267296

268297
# Merges lists into one file
269298
# Source: https://bobbyhadz.com/blog/merge-text-files-in-python#how-to-merge-text-files-in-python
@@ -273,7 +302,7 @@
273302
with open(file_path, 'r', encoding='utf-8') as input_file:
274303
output_file.write(input_file.read() + '\n')
275304

276-
NOW = strftime("%Y-%m-%d %H:%M:%S", gmtime())
305+
NOW = refreshDateTimeToNow()
277306

278307
# Removes individual text files
279308
I = 0
@@ -282,7 +311,7 @@
282311
os.remove(CURRENTWORKINGDIRECTORY + "downloaded_lists/blocklist"+str(I)+".txt")
283312
I = I + 1
284313

285-
NOW = strftime("%Y-%m-%d %H:%M:%S", gmtime())
314+
NOW = refreshDateTimeToNow()
286315

287316
# Cleans aio_blocklist.txt file
288317
print(NOW+" - "+"Cleaning aio_blocklist.txt, please wait..")
@@ -293,7 +322,7 @@
293322
# Removes duplicates from from text file
294323
CLEANEDOUTPUT = open(CURRENTWORKINGDIRECTORY + 'aio_blocklist.txt', 'w', encoding='utf-8').writelines(UNIQUELINES)
295324

296-
NOW = strftime("%Y-%m-%d %H:%M:%S", gmtime())
325+
NOW = refreshDateTimeToNow()
297326

298327
# Removes all junk from aio_blocklist.txt file
299328
print(NOW+" - "+"Removing junk lines from aio_blocklist.txt, please wait..")
@@ -318,11 +347,12 @@
318347
line = line.replace('^','^$important')
319348
line = line.replace('||||','||')
320349
line = line.replace('|||','||')
350+
line = line.replace('||','|') # Implemented a fix to skip subdomain blocking
321351
line = line.replace('$important$important','$important')
322352
new_f.write(line)
323353
os.remove(CURRENTWORKINGDIRECTORY + "aio_blocklist.txt")
324354

325-
NOW = strftime("%Y-%m-%d %H:%M:%S", gmtime())
355+
NOW = refreshDateTimeToNow()
326356

327357
# Cleans aio_blocklist_final.txt file
328358
print(NOW+" - "+"Cleaning aio_blocklist_final.txt, please wait..")
@@ -335,12 +365,21 @@
335365
# Removes duplicates from from text file
336366
CLEANEDOUTPUT = open(CURRENTWORKINGDIRECTORY + 'aio_blocklist_final.txt', 'w', encoding='utf-8').writelines(UNIQUELINES)
337367

338-
NOW = strftime("%Y-%m-%d %H:%M:%S", gmtime())
368+
NOW = refreshDateTimeToNow()
339369
print(NOW+" - "+"AIO list has been generated as: aio_blocklist_final.txt")
340370

341371
# Writes to HISTORY.md file
342372
with open(CURRENTWORKINGDIRECTORY + "HISTORY.md", "a", encoding='utf-8') as HISTORYFILE:
343373
HISTORYFILE.write("- Updated "+NOW+"\n")
344374

345-
NOW = strftime("%Y-%m-%d %H:%M:%S", gmtime())
375+
NOW = refreshDateTimeToNow()
376+
# NOW = strftime("%Y-%m-%d %H:%M:%S", gmtime())
346377
print(NOW+" - "+"Updated: HISTORY.md")
378+
379+
# Version 0.3 changes:
380+
# - added fix to skip blocking subdomains
381+
# - added color text output using "rich" package
382+
# - added more lists
383+
# - fixed datetime now to be local time
384+
# - improved output
385+
#

0 commit comments

Comments
 (0)