Skip to content

Commit 8f17915

Browse files
committed
Rework mac logic to fallback to new semver used by osexperts
1 parent c21c9dd commit 8f17915

1 file changed

Lines changed: 31 additions & 4 deletions

File tree

‎.github/actions/setup-ffmpeg/action.yml‎

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ runs:
2323
local binary_name="${2:-FFmpeg}"
2424
local output_file="$(echo "$binary_name" | tr '[:upper:]' '[:lower:]').zip"
2525
26-
if curl -sS -f -L --retry 3 --retry-delay 5 "$url" -o "$output_file"; then
26+
if curl -sS -f -L --retry 3 --retry-delay 8 --retry-all-errors "$url" -o "$output_file"; then
2727
echo "Downloaded $binary_name from $url"
2828
unzip -q "$output_file"
2929
rm -f "$output_file"
@@ -33,6 +33,13 @@ runs:
3333
fi
3434
}
3535
36+
is_binary_available() {
37+
local url="$1"
38+
local status=$(curl -sS -o /dev/null -L -A "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36" \
39+
-w "%{http_code}" "$url" 2>/dev/null || echo "404")
40+
[[ "$status" == "200" ]]
41+
}
42+
3643
if [[ "${{ runner.os }}" == "Linux" ]]; then
3744
docker pull mwader/static-ffmpeg:$FF_VERSION
3845
CID=$(docker create mwader/static-ffmpeg:$FF_VERSION)
@@ -42,10 +49,30 @@ runs:
4249
chmod +x "$INSTALL_DIR/"*
4350
4451
elif [[ "${{ runner.os }}" == "macOS" ]]; then
45-
FF_VERSION=$(echo "$FF_VERSION" | awk -F. '{print $1 $2}')
46-
download_binary "https://www.osxexperts.net/ffmpeg${FF_VERSION}arm.zip"
52+
major=$(echo "$FF_VERSION" | cut -d. -f1)
53+
minor=$(echo "$FF_VERSION" | cut -d. -f2 | sed 's/^0*//')
54+
concatenated_version="${major}${minor:-0}"
55+
56+
ffmpeg_url="https://www.osxexperts.net/ffmpeg${concatenated_version}arm.zip"
57+
ffmpeg_fallback_url="https://www.osxexperts.net/ffmpeg${major}arm.zip"
58+
if is_binary_available "$ffmpeg_url"; then
59+
download_binary "$ffmpeg_url"
60+
elif is_binary_available "$ffmpeg_fallback_url"; then
61+
download_binary "$ffmpeg_fallback_url"
62+
else
63+
echo "No Mac FFmpeg binary found for $FF_VERSION" && exit 1
64+
fi
4765
mv ffmpeg "$INSTALL_DIR/ffmpeg"
48-
download_binary "https://www.osxexperts.net/ffprobe${FF_VERSION}arm.zip" "FFprobe"
66+
67+
ffprobe_url="https://www.osxexperts.net/ffprobe${concatenated_version}arm.zip"
68+
ffprobe_fallback_url="https://www.osxexperts.net/ffprobe${major}arm.zip"
69+
if is_binary_available "$ffprobe_url"; then
70+
download_binary "$ffprobe_url" "FFprobe"
71+
elif is_binary_available "$ffprobe_fallback_url"; then
72+
download_binary "$ffprobe_fallback_url" "FFprobe"
73+
else
74+
echo "No Mac FFprobe binary found for $FF_VERSION" && exit 1
75+
fi
4976
mv ffprobe "$INSTALL_DIR/ffprobe"
5077
chmod +x "$INSTALL_DIR/"*
5178

0 commit comments

Comments
 (0)