Commit 637d2a95 authored by Vitaly Lipatov's avatar Vitaly Lipatov

epm play common.sh: implement get_json_value and use it

parent 7c278aa9
......@@ -151,6 +151,12 @@ parse_json_value()
epm tool json -b | grep -m1 -F "$field" | sed -e 's|.*[[:space:]]||' | sed -e 's|"\(.*\)"|\1|g'
}
# URL/file ["version"]
get_json_value()
{
eget -q -O- "$1" | parse_json_value "$2"
}
snap_get_pkgurl()
{
local SNAPNAME="$1"
......@@ -163,7 +169,7 @@ snap_get_pkgurl()
get_latest_version()
{
local ver
local epmver="$(epm --short --version)"
local epmver="$(epm --short --version 2>/dev/null)"
local URL
epmver=$(echo "$epmver" | sed -e 's|\.[0-9]*$||')
for URL in "https://eepm.ru/releases/$epmver/app-versions" "https://eepm.ru/app-versions" ; do
......
......@@ -11,8 +11,7 @@ URL="https://www.cursor.com/"
warn_version_is_not_supported
arch="$(epm print info --arch-arch)"
JSON="https://www.cursor.com/api/download?platform=linux-$arch&releaseTrack=stable"
PKGURL="$(eget -O- "$JSON" | parse_json_value "downloadUrl")"
PKGURL="$(get_json_value "https://www.cursor.com/api/download?platform=linux-$arch&releaseTrack=stable" "downloadUrl")"
install_pkgurl
......@@ -10,7 +10,8 @@ URL="https://radicle.xyz/"
warn_version_is_not_supported
VERSION=$(eget -q -O- "https://files.radicle.xyz/releases/radicle-httpd/latest/radicle-httpd.json" | epm tool json -b | grep version | awk 'gsub(/"/, "", $2) {print $2}')
VERSION="$(get_json_value "https://files.radicle.xyz/releases/radicle-httpd/latest/radicle-httpd.json" "version")"
[ -n "$VERSION" ] || fatal "Can't get version"
PKGURL="https://files.radicle.xyz/releases/radicle-httpd/latest/radicle-httpd-$VERSION-x86_64-unknown-linux-musl.tar.xz"
......
......@@ -10,7 +10,7 @@ URL="https://radicle.xyz/"
warn_version_is_not_supported
VERSION=$(eget -q -O- "https://files.radicle.xyz/releases/latest/radicle.json" | epm tool json -b | grep version | awk 'gsub(/"/, "", $2) {print $2}')
VERSION="$(get_json_value "https://files.radicle.xyz/releases/latest/radicle.json" "version")"
[ -n "$VERSION" ] || fatal "Can't get version"
PKGURL="https://files.radicle.xyz/releases/latest/radicle-$VERSION-x86_64-unknown-linux-musl.tar.xz"
......
......@@ -9,7 +9,7 @@ URL="https://yougile.com"
. $(dirname $0)/common.sh
if [ "$VERSION" = "*" ] ; then
VERSION="$(eget -O- https://dist.yougile.com/app/latest.json | grep -o '"version":[^,}]*' | sed 's/[^0-9.]//g')"
VERSION="$(get_json_value https://dist.yougile.com/app/latest.json version)"
fi
PKGURL="https://dist.yougile.com/app/YouGile-$VERSION-x86_64.AppImage"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment