This repository was archived by the owner on Mar 30, 2026. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathbuild_local.sh
More file actions
134 lines (112 loc) · 4.33 KB
/
Copy pathbuild_local.sh
File metadata and controls
134 lines (112 loc) · 4.33 KB
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
#!/usr/bin/env bash
#This script allows you to build the blocklist locally
echo """
_____ __ _ ____ ___ __ __ _ __
/ ___/____ ____ / /_(_) __/_ __ / | ____/ /____ / / (_)____/ /_
\__ \/ __ \/ __ \/ __/ / /_/ / / / / /| |/ __ / ___/ / / / / ___/ __/
___/ / /_/ / /_/ / /_/ / __/ /_/ / / ___ / /_/ (__ ) / /___/ (__ ) /_
/____/ .___/\____/\__/_/_/ \__, / /_/ |_\__,_/____/ /_____/_/____/\__/
/_/ /____/
License: https://github.com/Isaaker/Spotify-AdsList/blob/main/LICENSE.txt
"""
echo "---------------------------------------------"
echo "Checking the environment before running..."
echo "---------------------------------------------"
set -euo pipefail
IFS=$'\n\t'
# Logging helpers
info() { echo "INFO: $*"; }
warn() { echo "WARN: $*"; }
error() { echo "ERROR: $*" >&2; exit 1; }
echo "Verifying Python 3"
# -------------------------
# Check for Python 3
# -------------------------
PYBIN=""
if command -v python3 >/dev/null 2>&1; then
PYBIN=python3
elif command -v python >/dev/null 2>&1; then
# check if 'python' is Python 3
if python -c 'import sys; sys.exit(0 if sys.version_info[0] >= 3 else 1)' >/dev/null 2>&1; then
PYBIN=python
fi
fi
if [ -z "$PYBIN" ]; then
error "Python 3 not found in PATH. Install Python 3 or add it to PATH."
fi
PYVER=$($PYBIN -c 'import sys; print("{}.{}.{}".format(*sys.version_info[:3]))')
PYMAJOR=$($PYBIN -c 'import sys; print(sys.version_info[0])')
if [ "$PYMAJOR" -lt 3 ]; then
error "Found $PYBIN ($PYVER) but it is not Python 3."
fi
info "Python verified: $PYBIN $PYVER"
echo "Verifying SpotifyAdsList scripts and directory"
# -------------------------
# For this repository the directory MUST be the current working directory "./"
# -------------------------
SPOTIFY_ADS_DIR="./"
if [ ! -d "$SPOTIFY_ADS_DIR" ]; then
error "Current directory ($SPOTIFY_ADS_DIR) does not exist or is not a directory."
fi
info "Using current directory as project directory: $SPOTIFY_ADS_DIR"
# Check for common top-level files for this project
check_topfile() {
local f="$1"
if [ -f "$SPOTIFY_ADS_DIR/$f" ]; then
info "Found $f"
else
warn "$f not found at repository root"
fi
}
check_topfile "README.md"
check_topfile "./Lists/BLACKLIST.txt"
check_topfile "./Lists/WHITELIST.txt"
check_topfile "./scripts/add_default-ads-blocklist.py"
check_topfile "./scripts/update_lists.py"
echo "Verifying write permissions"
# -------------------------
# Check write permissions on current directory
# -------------------------
CWD_OK=false
if touch "$SPOTIFY_ADS_DIR/.__writable_test__" >/dev/null 2>&1; then
rm -f "$SPOTIFY_ADS_DIR/.__writable_test__"
CWD_OK=true
fi
if $CWD_OK; then
info "Write permission in current directory: OK"
else
warn "No write permission in current directory ($SPOTIFY_ADS_DIR). If the script needs to write files, adjust permissions (chmod/chown) or run as appropriate user."
fi
echo "Checking Python requests library..."
if ! python3 -c "import requests" >/dev/null 2>&1; then
echo "ERROR: Python 'requests' library is not installed."
echo "Please install it using: pip3 install requests. Do not use requirements.txt, that would install other packages."
exit 1
fi
echo "Python 'requests' library is installed."
echo "Environment check completed."
echo "---------------------------------------------"
echo "Spotify Ads List build ready for running!"
echo "---------------------------------------------"
echo ""
echo "---------------------------------------------"
echo "Starting to build..."
echo "---------------------------------------------"
echo "Remove duplicated domains"
python3 ./scripts/check_whitelist.py
echo "Download and mix default add blocklist"
python3 ./scripts/add_default-ads-blocklist.py
echo "Remove whitelist domains from WHITELIST-mixed.txt"
python3 ./scripts/check_whitelist_mixed.py
echo "Remove domain exclusion domains from WHITELIST-mixed.txt"
python3 ./scripts/domain_exclusion.py
echo "Build blocklist"
python3 ./scripts/update_lists.py
echo "Build blocklist mixed"
python3 ./scripts/update_list_mixed.py
echo "---------------------------------------------"
echo "Spotify Ads List built succesfully"
echo "Check LISTS at: ./Lists/"
echo "---------------------------------------------"
echo "DONE"
echo "---------------------------------------------"