-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathextgetter
More file actions
executable file
·32 lines (27 loc) · 869 Bytes
/
extgetter
File metadata and controls
executable file
·32 lines (27 loc) · 869 Bytes
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
#!/usr/bin/bash
# Usage:
# extgetter apk aniwatch -> gets aniwatch apk
# extgetter id aniwatch -> gets aniwatch id
# extgetter [id/apk] aniwatch reload -> updates the extensions list before doing any actions
type=$1
name=$2
REPO=aniyomiorg/aniyomi-extensions
INDEX_PATH=${TMPDIR:-/tmp}/index.min.json
if [[ ! -e $INDEX_PATH ]] || [[ $3 == "reload" ]]; then
wget "https://raw.githubusercontent.com/$REPO/repo/index.min.json" -O $INDEX_PATH
fi
testname="test(\"$name\"; \"i\")"
selector="map(select((.name | $testname) or (.pkg | $testname)))[0]"
if [[ $type == "apk" ]]; then
selector+=".apk"
fi
data=$(jq -r "$selector" $INDEX_PATH)
if [[ "$data" == "null" ]] || [[ -z "$data" ]]; then
echo "not found"
exit
fi
if [[ $type == "id" ]]; then
echo $data | jq .sources
else
wget "https://github.com/$REPO/raw/repo/apk/$data" -O "$name.apk"
fi