2018-02-04 12:55:21 +00:00
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
|
|
|
|
TOOLS="$(ls -d ${ANDROID_HOME}/build-tools/* | tail -1)"
|
|
|
|
|
|
|
|
mkdir -p repo/apk
|
|
|
|
mkdir -p repo/icon
|
|
|
|
|
2021-11-28 23:06:26 +00:00
|
|
|
cd repo
|
2018-02-04 12:55:21 +00:00
|
|
|
|
2021-11-28 23:06:26 +00:00
|
|
|
APKS=( ../apk/*".apk" )
|
2021-11-28 20:46:06 +00:00
|
|
|
|
2021-11-28 23:06:26 +00:00
|
|
|
for APK in ${APKS[@]}; do
|
2024-01-09 03:14:00 +00:00
|
|
|
cp $APK apk/
|
2018-02-04 12:55:21 +00:00
|
|
|
FILENAME=$(basename ${APK})
|
2020-08-08 19:59:03 +00:00
|
|
|
BADGING="$(${TOOLS}/aapt dump --include-meta-data badging $APK)"
|
2018-02-04 12:55:21 +00:00
|
|
|
|
|
|
|
PACKAGE=$(echo "$BADGING" | grep package:)
|
2020-06-27 19:21:46 +00:00
|
|
|
PKGNAME=$(echo $PACKAGE | grep -Po "package: name='\K[^']+")
|
2018-02-04 12:55:21 +00:00
|
|
|
VCODE=$(echo $PACKAGE | grep -Po "versionCode='\K[^']+")
|
|
|
|
VNAME=$(echo $PACKAGE | grep -Po "versionName='\K[^']+")
|
2020-08-08 19:59:03 +00:00
|
|
|
NSFW=$(echo $BADGING | grep -Po "tachiyomi.extension.nsfw' value='\K[^']+")
|
2022-01-22 14:48:52 +00:00
|
|
|
HASREADME=$(echo $BADGING | grep -Po "tachiyomi.extension.hasReadme' value='\K[^']+")
|
|
|
|
HASCHANGELOG=$(echo $BADGING | grep -Po "tachiyomi.extension.hasChangelog' value='\K[^']+")
|
2018-02-04 12:55:21 +00:00
|
|
|
|
|
|
|
APPLICATION=$(echo "$BADGING" | grep application:)
|
|
|
|
LABEL=$(echo $APPLICATION | grep -Po "label='\K[^']+")
|
|
|
|
|
|
|
|
LANG=$(echo $APK | grep -Po "tachiyomi-\K[^\.]+")
|
|
|
|
|
|
|
|
ICON=$(echo "$BADGING" | grep -Po "application-icon-320.*'\K[^']+")
|
2023-07-16 18:55:51 +00:00
|
|
|
unzip -p $APK $ICON > icon/${PKGNAME}.png
|
|
|
|
|
|
|
|
# TODO: legacy icons; remove after a while
|
|
|
|
cp icon/${PKGNAME}.png icon/${FILENAME%.*}.png
|
2018-02-04 12:55:21 +00:00
|
|
|
|
2021-08-02 14:28:45 +00:00
|
|
|
SOURCE_INFO=$(jq ".[\"$PKGNAME\"]" < ../output.json)
|
2021-11-29 03:45:12 +00:00
|
|
|
|
2021-08-03 13:05:57 +00:00
|
|
|
# Fixes the language code without needing to update the packages.
|
|
|
|
SOURCE_LEN=$(echo $SOURCE_INFO | jq length)
|
|
|
|
|
|
|
|
if [ $SOURCE_LEN = "1" ]; then
|
2021-11-29 03:45:12 +00:00
|
|
|
SOURCE_LANG=$(echo $SOURCE_INFO | jq -r '.[0].lang')
|
2021-08-03 13:05:57 +00:00
|
|
|
|
2021-11-29 03:45:12 +00:00
|
|
|
if [ $SOURCE_LANG != $LANG ] && [ $SOURCE_LANG != "all" ] && [ $SOURCE_LANG != "other" ] && [ $LANG != "all" ] && [ $LANG != "other" ]; then
|
|
|
|
LANG=$SOURCE_LANG
|
|
|
|
fi
|
2021-08-03 13:05:57 +00:00
|
|
|
fi
|
2021-08-02 14:28:45 +00:00
|
|
|
|
2018-02-04 12:55:21 +00:00
|
|
|
jq -n \
|
|
|
|
--arg name "$LABEL" \
|
|
|
|
--arg pkg "$PKGNAME" \
|
|
|
|
--arg apk "$FILENAME" \
|
|
|
|
--arg lang "$LANG" \
|
|
|
|
--argjson code $VCODE \
|
|
|
|
--arg version "$VNAME" \
|
2020-08-08 19:59:03 +00:00
|
|
|
--argjson nsfw $NSFW \
|
2022-01-22 14:48:52 +00:00
|
|
|
--argjson hasReadme $HASREADME \
|
|
|
|
--argjson hasChangelog $HASCHANGELOG \
|
2021-08-02 14:28:45 +00:00
|
|
|
--argjson sources "$SOURCE_INFO" \
|
2022-01-22 14:48:52 +00:00
|
|
|
'{name:$name, pkg:$pkg, apk:$apk, lang:$lang, code:$code, version:$version, nsfw:$nsfw, hasReadme:$hasReadme, hasChangelog:$hasChangelog, sources:$sources}'
|
2018-02-04 12:55:21 +00:00
|
|
|
|
2020-08-02 22:55:14 +00:00
|
|
|
done | jq -sr '[.[]]' > index.json
|
|
|
|
|
2020-11-29 20:44:17 +00:00
|
|
|
# Alternate minified copy
|
2024-01-09 10:21:53 +00:00
|
|
|
jq -c 'map(del(.hasReadme, .hasChangelog, .sources[]["versionId", "hasCloudflare"]))' < index.json > index.min.json
|
2020-11-29 20:44:17 +00:00
|
|
|
|
2020-06-27 19:21:46 +00:00
|
|
|
cat index.json
|