Update to use new Minecraft API for download URL instead of restify (#525)
This commit is contained in:
1 parent
de15d694e5
commit
1369abe0a6
1 file changed
+26
-25
+26
-25
@@ -23,22 +23,30 @@ function replace_version_in_url() {
|
|||||||
|
|
||||||
function lookupVersion() {
|
function lookupVersion() {
|
||||||
platform=${1:?Missing required platform indicator}
|
platform=${1:?Missing required platform indicator}
|
||||||
customVersion=${2:-}
|
# TODO need to find out API call to lookup custom version
|
||||||
|
# customVersion=${2:-}
|
||||||
|
|
||||||
# shellcheck disable=SC2034
|
DOWNLOAD_URL=$(
|
||||||
for i in {1..3}; do
|
curl -fsSL "${getUrlPage}" |
|
||||||
DOWNLOAD_URL=$(restify --user-agent=itzg/minecraft-bedrock-server --headers "accept-language:*" --attribute=data-platform="${platform}" "${downloadPage}" 2> restify.err | jq -r '.[0].href' || echo '')
|
jq --arg platform serverBedrockLinux -rR '
|
||||||
[[ -n "${DOWNLOAD_URL}" ]] && break
|
try(fromjson) catch({}) |
|
||||||
sleep 1
|
.result.links // halt_error(1) |
|
||||||
done
|
map(
|
||||||
if [[ -z ${DOWNLOAD_URL} ]]; then
|
select(.downloadType == $platform)
|
||||||
DOWNLOAD_URL=$(curl -s https://mc-bds-helper.vercel.app/api/latest)
|
) |
|
||||||
fi
|
if length > 0 then
|
||||||
|
first |
|
||||||
if [[ -n "${customVersion}" && -n "${DOWNLOAD_URL}" ]]; then
|
.downloadUrl
|
||||||
DOWNLOAD_URL=$(replace_version_in_url "${DOWNLOAD_URL}" "${customVersion}")
|
else
|
||||||
return
|
(
|
||||||
fi
|
"Error: could not find platform (\($platform))\n" |
|
||||||
|
stderr |
|
||||||
|
"" |
|
||||||
|
halt_error(2)
|
||||||
|
)
|
||||||
|
end
|
||||||
|
'
|
||||||
|
)
|
||||||
|
|
||||||
# shellcheck disable=SC2012
|
# shellcheck disable=SC2012
|
||||||
if [[ ${DOWNLOAD_URL} =~ http.*/.*-(.*)\.zip ]]; then
|
if [[ ${DOWNLOAD_URL} =~ http.*/.*-(.*)\.zip ]]; then
|
||||||
@@ -46,18 +54,10 @@ function lookupVersion() {
|
|||||||
elif [[ $(ls -rv bedrock_server-* 2> /dev/null|head -1) =~ bedrock_server-(.*) ]]; then
|
elif [[ $(ls -rv bedrock_server-* 2> /dev/null|head -1) =~ bedrock_server-(.*) ]]; then
|
||||||
VERSION=${BASH_REMATCH[1]}
|
VERSION=${BASH_REMATCH[1]}
|
||||||
echo "WARN Minecraft download page failed, so using existing download of $VERSION"
|
echo "WARN Minecraft download page failed, so using existing download of $VERSION"
|
||||||
cat restify.err
|
|
||||||
else
|
else
|
||||||
if [[ -f restify.err ]]; then
|
echo "Failed to lookup download URL: ${DOWNLOAD_URL}"
|
||||||
echo "Failed to extract download URL '${DOWNLOAD_URL}' from ${downloadPage}"
|
|
||||||
cat restify.err
|
|
||||||
rm restify.err
|
|
||||||
else
|
|
||||||
echo "Failed to lookup download URL: ${DOWNLOAD_URL}"
|
|
||||||
fi
|
|
||||||
exit 2
|
exit 2
|
||||||
fi
|
fi
|
||||||
rm -f restify.err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if [[ ${DEBUG^^} == TRUE ]]; then
|
if [[ ${DEBUG^^} == TRUE ]]; then
|
||||||
@@ -69,7 +69,8 @@ fi
|
|||||||
|
|
||||||
export HOME="${PWD}"
|
export HOME="${PWD}"
|
||||||
|
|
||||||
downloadPage=https://www.minecraft.net/en-us/download/server/bedrock
|
# Looks like both net and net-secondary hostnames work
|
||||||
|
getUrlPage=https://net-secondary.web.minecraft-services.net/api/v1.0/download/links
|
||||||
|
|
||||||
if [[ ${EULA^^} != TRUE ]]; then
|
if [[ ${EULA^^} != TRUE ]]; then
|
||||||
echo
|
echo
|
||||||
|
|||||||
Reference in new issue
Block a user