feat(fdroid): download newers apks
This commit is contained in:
parent
9f03ababcf
commit
62cc5a37d7
@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
(cd /repo/
|
||||
(cd /repo/ || exit 1
|
||||
fdroid init
|
||||
|
||||
sed -i \
|
||||
|
@ -3,6 +3,31 @@
|
||||
SCRIPT_PATH="$(dirname "$0")"
|
||||
APK_FILE=/apks.txt
|
||||
|
||||
function is_newer() {
|
||||
local url="$1"
|
||||
local remote_date local_date
|
||||
local headers; headers="$(curl -sSLI "$url")"
|
||||
local file; file="$(grep -Po '(?<=filename=).*\.apk' <<< "$headers")"
|
||||
|
||||
if ! [ -f "$file" ]; then
|
||||
return 0
|
||||
fi
|
||||
remote_date="$(sed -n 's/last-modified: //p' <<< "$headers")"
|
||||
local_date="$(stat "$file" | sed -n 's/^Modify: //p')"
|
||||
[ "$(date -d "$remote_date" '+%s')" -gt "$(date -d "$local_date" '+%s')" ]
|
||||
}
|
||||
|
||||
function filter_links() {
|
||||
links=()
|
||||
|
||||
for link in "$@"; do
|
||||
if is_newer "$link"; then
|
||||
links+=("$link")
|
||||
fi
|
||||
done
|
||||
echo "${links[@]}"
|
||||
}
|
||||
|
||||
function get_links() {
|
||||
local file="$1"
|
||||
local url
|
||||
@ -22,13 +47,16 @@ function get_links() {
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
done < <(awk 'NF && $1!~/^#/' "$file")
|
||||
done < <(awk 'NF && $1!~/^#/' "$file" | sort -u)
|
||||
}
|
||||
|
||||
function main() {
|
||||
local links; links="$(get_links "$APK_FILE")"
|
||||
local links
|
||||
|
||||
(cd /repo/repo/ && xargs -n1 -P8 curl -LOC- <<< "$LINKS")
|
||||
readarray -t links < <(get_links "$APK_FILE" | sort -u)
|
||||
read -ra links < <(filter_links "${links[@]}")
|
||||
|
||||
(cd /repo/repo/ && xargs -n1 -P8 curl -sSLO <<< "${links[@]}")
|
||||
(cd /repo/ && fdroid update -c)
|
||||
|
||||
if [ -n "$PUID" ]; then
|
||||
|
@ -6,14 +6,14 @@ function get_tag_urls() {
|
||||
local repo="$1"
|
||||
local tag="$2"
|
||||
|
||||
curl -L "$API/projects/$repo/releases/$tag" | \
|
||||
curl -sSL "$API/projects/$repo/releases/$tag" | \
|
||||
jq -r '.assets.links[] | select(.name | test(".apk$")) | .url'
|
||||
}
|
||||
|
||||
function get_urls() {
|
||||
local repo="$1"
|
||||
|
||||
curl -L "$API/projects/$repo/releases" | \
|
||||
curl -sSL "$API/projects/$repo/releases" | \
|
||||
jq -r '.[0].assets.links[] | select(.name | test(".apk$")) | .url'
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user