-
Notifications
You must be signed in to change notification settings - Fork 0
/
animefolder
executable file
·50 lines (40 loc) · 1.27 KB
/
animefolder
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
#!/bin/bash
getimage() {
if [ -f .realname ]; then
name=$(cat .realname)
else
name=$(pwd | awk -F/ '{ print $(NF) }')
fi
if [[ $name == Season* ]]; then
name=$(pwd | awk -F/ '{ print $(NF-1) " " $(NF) }')
fi
if [[ $name == S[0-9] ]]; then
name=$(pwd | awk -F/ '{ print $(NF-1) " " $(NF) }')
fi
html=$(curl -s -G --data-urlencode "q=$name" https://myanimelist.net/anime.php)
echo "$name"
# Check for exact match
if echo "$html" | grep -q "<strong>$name</strong>"; then
echo "Exact name found"
image=$(echo "$html" | grep -B 10 "<strong>$name</strong>" | grep 100x140 | head -n1 | \
sed 's|.*https://|https://|' | sed 's|?.*||' | sed 's|/r/100x140||')
else
echo "Using first search result"
image=$(echo "$html" | grep 100x140 | grep -v Special | grep -v OVA | head -n1 | \
sed 's|.*https://|https://|' | sed 's|?.*||' | sed 's|/r/100x140||')
fi
convert "$image" .folder.png
printf "[Desktop Entry]\nIcon=./.folder.png\n" > .directory
echo ""
}
base=$(pwd)
if [ "$1" == "all" ]; then
for x in *; do
if [ ! -f "$base/$x"/.directory ]; then
cd "$base/$x"
getimage
fi
done
else
getimage
fi