-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-entrypoint.sh
More file actions
35 lines (32 loc) · 1.13 KB
/
Copy pathdocker-entrypoint.sh
File metadata and controls
35 lines (32 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/sh
# Refresh yt-dlp on container start when newer than the image-bundled build.
# Fly machines keep running without redeploys; this picks up yt-dlp releases after restarts.
# Set YTDLP_AUTO_UPDATE=0 to skip (use only the Dockerfile-pinned binary).
if [ "${YTDLP_AUTO_UPDATE:-1}" != "0" ]; then
url="${YTDLP_UPDATE_URL:-https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp_linux}"
current="$(/usr/local/bin/yt-dlp --version 2>/dev/null || true)"
latest="$(
curl -fsSL "https://api.github.com/repos/yt-dlp/yt-dlp/releases/latest" 2>/dev/null |
node -e "
let d = '';
process.stdin.on('data', (c) => { d += c; });
process.stdin.on('end', () => {
try {
const t = JSON.parse(d).tag_name;
if (t) process.stdout.write(String(t));
} catch {}
});
" 2>/dev/null || true
)"
if [ -n "$latest" ] && [ "$current" = "$latest" ]; then
:
else
tmp="/tmp/yt-dlp.$$.new"
if curl -fSL "$url" -o "$tmp" 2>/dev/null && chmod a+rx "$tmp" && mv "$tmp" /usr/local/bin/yt-dlp; then
:
else
rm -f "$tmp"
fi
fi
fi
exec "$@"