-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpokeget.sh
More file actions
52 lines (37 loc) · 1.09 KB
/
pokeget.sh
File metadata and controls
52 lines (37 loc) · 1.09 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
#!/usr/bin/env bash
# Please do not submit feature requests for pokeget lite, as it is meant to be extremely simple.
# Color variables
CYAN="\x1B[36m"
RED="\x1B[31m"
BOLD="\x1B[1m"
RESET="\x1B[0m"
if [ "$1" = "" ]; then
echo -e "${CYAN}[!]${RESET} Use ${BOLD}pokeget-lite [pokemon national dex id/pokemon name]${RESET}."
exit 0
else
rawId=$1
# Parse the ID/Name
if [[ $rawId =~ ^[0-9]+$ ]]; then
id=$rawId
length=${#id}
# Loop until the pokemon ID's length is three. This makes '3' '003', '25' '025', etc...
while ((length < 3)); do
id=0$id
length=${#id}
done
# Get final sprite
r=$(curl -s -L "https://raw.githubusercontent.com/talwat/pokeget-sprites/main/pokemon_vanilla/small/${id}.txt")
else
id=$(echo "$rawId" | tr '[:upper:]' '[:lower:]')
# Get final sprite
r=$(curl -s -L "https://raw.githubusercontent.com/talwat/pokeget-sprites/main/pokemon_vanilla_named/small/${id}.txt")
fi
# Print output or 404 message
if [[ $r == *"404"* ]]; then
echo -e "${RED}[!]${RESET} Pokemon could not be found (404 Error)$RESET"
exit 1
else
echo -e "$r$RESET"
exit 0
fi
fi