dynamic video loading

This commit is contained in:
Simon
2026-06-19 22:03:49 +00:00
parent 95b75bf999
commit a97f7e7b0f
5 changed files with 240 additions and 111 deletions

View File

@@ -13,23 +13,39 @@ POLL=60 # how often to check on the app
# Upgrade yt-dlp only if PyPI has a newer version.
# Returns 0 if an update was installed, 1 otherwise (incl. errors / up to date).
# Versions are compared numerically: the installed version can be zero-padded
# (e.g. 2026.06.09) while PyPI reports the normalized form (e.g. 2026.6.9).
check_and_update() {
current=$(python -c "import yt_dlp; print(yt_dlp.version.__version__)" 2>/dev/null) || return 1
latest=$(python -c "import json,urllib.request; print(json.load(urllib.request.urlopen('https://pypi.org/pypi/yt-dlp/json', timeout=30))['info']['version'])" 2>/dev/null) || {
echo "Could not reach PyPI to check for yt-dlp updates; will retry."
return 1
}
if python3 - <<'PY'
import json, sys, urllib.request
try:
import yt_dlp
current = yt_dlp.version.__version__
latest = json.load(urllib.request.urlopen(
'https://pypi.org/pypi/yt-dlp/json', timeout=30))['info']['version']
except Exception as e:
print(f"Could not check for yt-dlp updates ({e}); will retry.")
sys.exit(1)
if [ "$current" = "$latest" ]; then
echo "yt-dlp is up to date ($current)."
return 1
fi
def key(v):
try:
return tuple(int(p) for p in v.split('.'))
except ValueError:
return None
echo "New yt-dlp available: $current -> $latest. Updating..."
if pip install --upgrade --quiet --root-user-action=ignore "yt-dlp[default,curl-cffi]"; then
return 0
ck, lk = key(current), key(latest)
newer = (lk > ck) if (ck and lk) else (current != latest)
if newer:
print(f"New yt-dlp available: {current} -> {latest}. Updating...")
sys.exit(0)
print(f"yt-dlp is up to date ({current}).")
sys.exit(1)
PY
then
pip install --upgrade --quiet --root-user-action=ignore "yt-dlp[default,curl-cffi]" \
&& return 0
echo "yt-dlp update failed; continuing with the installed version."
fi
echo "yt-dlp update failed; continuing with the installed version."
return 1
}