-
Notifications
You must be signed in to change notification settings - Fork 0
/
chumbi-image-downloader.sh
157 lines (146 loc) · 3.78 KB
/
chumbi-image-downloader.sh
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
#!/bin/bash
# Chumbi Image Downloader
# By Rasmez
# Script Version
VERSION="1.1"
# Image Sizes // Sticker:320px MAX // Emoji:128px MAX
S_SIZE="320"
E_SIZE="128"
# Set working dir to current directory
dir=$(cd -P -- "$(dirname -- "$0")" && pwd -P) || exit
# Download directories
E_DIR="${dir%/}/emojis/"
S_DIR="${dir%/}/stickers/"
# Image Lists
E_FILE="${dir%/}/chumbi-emoji-list.txt"
S_FILE="${dir%/}/chumbi-sticker-list.txt"
# GUI Constants
DIALOG_CANCEL=1
DIALOG_ESC=255
HEIGHT=0
WIDTH=0
# Automatic Mode (no gui)
if [ "$1" == "auto" ]; then
printf "Automatic mode engaged!"
if [ ! -d "$E_DIR" ]; then
mkdir "$E_DIR"
fi
if test -f "$E_FILE"; then
input="$E_FILE"
while IFS= read -r line
do
URL="https://media.discordapp.net/emojis/"
URL+="$line"
URL+="?size="
URL+="$E_SIZE"
wget -q -c --show-progress -O "$E_DIR/$line" "$URL"
done < "$input"
else
display_result "ERROR, $E_FILE not found!"
fi
if [ ! -d "$S_DIR" ]; then
mkdir "$S_DIR"
fi
if test -f "$S_FILE"; then
input="$S_FILE"
while IFS= read -r line
do
URL="https://media.discordapp.net/stickers/"
URL+="$line"
URL+="?size="
URL+="$S_SIZE"
wget -q -c --show-progress -O "$S_DIR/$line" "$URL"
done < "$input"
else
display_result "ERROR, $S_FILE not found!"
fi
# Manual Mode
else
printf "ERROR! Invalid argument"
display_result() {
dialog --title "$1" \
--no-collapse \
--msgbox "$result" 0 0
}
while true; do
exec 3>&1
selection=$(dialog \
--backtitle "Chumbi Image Downloader v$VERSION" \
--title "Menu" \
--clear \
--cancel-label "Exit" \
--menu "Please select:" $HEIGHT $WIDTH 4 \
"1" "Download Chumbi Emojis" \
"2" "Download Chumbi Stickers" \
"3" "Check for Emoji and Sticker Lists" \
2>&1 1>&3)
exit_status=$?
exec 3>&-
case $exit_status in
$DIALOG_CANCEL)
clear
echo "Program terminated."
exit
;;
$DIALOG_ESC)
clear
echo "Program aborted." >&2
exit 1
;;
esac
case $selection in
1 )
if [ ! -d "$E_DIR" ]; then
mkdir "$E_DIR"
fi
if test -f "$E_FILE"; then
input="$E_FILE"
while IFS= read -r line
do
URL="https://media.discordapp.net/emojis/"
URL+="$line"
URL+="?size="
URL+="$E_SIZE"
wget -q -c --progress=dot --show-progress -O "$E_DIR/$line" "$URL" 2>&1 |\
grep "%" |\
sed -u -e "s,\.,,g" | awk '{print $2}' | sed -u -e "s,\%,,g" | dialog --gauge "Downloading $line..." 10 100
done < "$input"
else
display_result "ERROR, $E_FILE not found!"
fi
;;
2 )
if [ ! -d "$S_DIR" ]; then
mkdir "$S_DIR"
fi
if test -f "$S_FILE"; then
input="$S_FILE"
while IFS= read -r line
do
URL="https://media.discordapp.net/stickers/"
URL+="$line"
URL+="?size="
URL+="$S_SIZE"
wget -q -c --progress=dot --show-progress -O "$S_DIR/$line" "$URL" 2>&1 |\
grep "%" |\
sed -u -e "s,\.,,g" | awk '{print $2}' | sed -u -e "s,\%,,g" | dialog --gauge "Downloading $line..." 10 100
done < "$input"
else
display_result "ERROR, $S_FILE not found!"
fi
;;
3 )
if test -f "$E_FILE"; then
display_result "The Emoji List is installed!"
else
display_result "ERROR, $E_FILE list not found! You can get it here: https://github.com/Rasmez/chumbi-image-downloader"
fi
if test -f "$S_FILE"; then
display_result "The Sticker List is installed!"
else
display_result "ERROR, $S_FILE not found! You can get it here: https://github.com/Rasmez/chumbi-image-downloader"
fi
;;
esac
done
fi