Download videos from almost any website. Lightweight, self-hosted media downloader with a clean web UI.
HTML
Fix multi-video JSON parse and auto-update yt-dlp
averygan1d161d15a4fe
diff --git a/Dockerfile b/Dockerfileindex 335a41c..4a5ce8c 100644--- a/Dockerfile+++ b/Dockerfile@@ -19,6 +19,10 @@ RUN useradd -m -u 1000 reclip && \chown -R reclip:reclip /appUSER reclip+# Put the reclip user's --user installs first so startup yt-dlp updates take effect.+ENV PATH=/home/reclip/.local/bin:$PATH+EXPOSE 8899+ENTRYPOINT ["sh", "/app/docker-entrypoint.sh"]CMD ["gunicorn", "-b", "0.0.0.0:8899", "-w", "1", "--threads", "4", "--timeout", "600", "--access-logfile", "-", "app:app"]diff --git a/app.py b/app.pyindex 45f1b94..2b5eaa5 100644--- a/app.py+++ b/app.py@@ -13,6 +13,22 @@ os.makedirs(DOWNLOAD_DIR, exist_ok=True)jobs = {}+def parse_ytdlp_json(stdout):+ """Parse yt-dlp JSON output.++ With ``-j`` yt-dlp prints one JSON object per line. Some extractors+ emit multiple videos even with ``--no-playlist``, so stdout contains+ several objects and a plain ``json.loads`` raises "Extra data".+ Return the first valid object.+ """+ for line in stdout.splitlines():+ line = line.strip()+ if not line:+ continue+ return json.loads(line)+ raise ValueError("yt-dlp returned no data")++def run_download(job_id, url, format_choice, format_id):job = jobs[job_id]out_template = os.path.join(DOWNLOAD_DIR, f"{job_id}.%(ext)s")@@ -91,7 +107,7 @@ def get_info():if result.returncode != 0:return jsonify({"error": result.stderr.strip().split("\n")[-1]}), 400- info = json.loads(result.stdout)+ info = parse_ytdlp_json(result.stdout)# Build quality options — keep best format per resolutionbest_by_height = {}diff --git a/docker-entrypoint.sh b/docker-entrypoint.shnew file mode 100755index 0000000..3ec60de--- /dev/null+++ b/docker-entrypoint.sh@@ -0,0 +1,11 @@+#!/bin/sh+# Keep yt-dlp fresh on container start — sites (Instagram, Facebook, etc.) break+# its extractors frequently, and the usual fix is simply updating yt-dlp.+# Installs into the reclip user's ~/.local (first on PATH). Skip with RECLIP_NO_UPDATE=1.+if [ -z "$RECLIP_NO_UPDATE" ]; then+ echo "Updating yt-dlp..."+ pip install --user --no-cache-dir -q -U yt-dlp || \+ echo " (couldn't update yt-dlp — continuing with the installed version)"+fi++exec "$@"diff --git a/reclip.sh b/reclip.shindex cd20d50..328fd45 100755--- a/reclip.sh+++ b/reclip.sh@@ -40,6 +40,13 @@ elsesource venv/bin/activatefi+# Keep yt-dlp fresh — sites (Instagram, Facebook, etc.) break its extractors+# frequently, and the usual fix is simply updating yt-dlp. Skip with RECLIP_NO_UPDATE=1.+if [ -z "$RECLIP_NO_UPDATE" ]; then+ echo "Updating yt-dlp..."+ pip install -q -U yt-dlp || echo " (couldn't update yt-dlp — continuing with the installed version)"+fi+PORT="${PORT:-8899}"export PORT