Skip to content

feat: show live download speed and progress - #66

Open
guoshulin1992-prog wants to merge 6 commits into
averygan:mainfrom
guoshulin1992-prog:feature/download-progress
Open

guoshulin1992-prog wants to merge 6 commits into
averygan:mainfrom
guoshulin1992-prog:feature/download-progress

Conversation

@guoshulin1992-prog

Copy link
Copy Markdown

Summary

  • Stream yt-dlp output while a download is running instead of waiting for the subprocess to finish.
  • Expose structured current-stream progress, downloaded bytes, total bytes, speed, and ETA through the job status API.
  • Show honest download, finalizing, processing, complete, and failed states in the web UI.
  • Add bounded subprocess lifecycle handling so silent, stalled, or very noisy child processes do not block the worker indefinitely.

Details

  • Uses yt-dlp --progress-template with a private line prefix and JSON payload rather than parsing human-readable progress text.
  • Keeps unknown totals unknown and marks estimated totals separately; a later real total takes precedence.
  • Treats each video/audio stream as its own current-stream progress and clears speed/ETA when the stream is finished.
  • Shows an indeterminate bar when no trustworthy percentage exists and hides stale speed/ETA values after the progress update becomes old.
  • Uses a single polling loop per card with a request timeout and generation guard, preventing overlapping polls and late responses from overwriting a retry.
  • Keeps subprocess invocation shell-free and preserves the URL safety behavior from PR Fix: prevent yt-dlp argument injection via unsanitized URL (RCE) #58, including the -- URL separator.
  • Keeps the Docker service bound to the local host in the supplied Compose configuration.

Tests

Executed locally on 2026-09-02:

  • 21 Python unit/integration tests passed with -W error::ResourceWarning.
  • 3 Node.js frontend tests passed.
  • py_compile passed for app.py, progress.py, and download_process.py.
  • git diff --check passed.
  • Both structured --progress-template arguments were accepted by the installed yt-dlp (2026.08.19).
  • Docker image build succeeded; an isolated container served the UI on a loopback-only test port.
  • Local browser smoke test with a user-authorized Bilibili video showed changing percentage, current-stream size, speed, and ETA, and the download completed successfully.

Relationship to existing work

Known limitations

  • Platform/site behavior still depends on the current yt-dlp extractor and the target site's access rules.
  • Full automated browser E2E coverage and a broad matrix of media sites are not included in this first contribution.
  • The PR does not change authentication, cookies, or public exposure policy; local deployments should continue to bind to 127.0.0.1 unless the operator deliberately chooses otherwise.

robomello and others added 6 commits September 2, 2026 15:04
The url field from POST /api/download, /api/info, and /api/playlist
was passed straight into the yt-dlp argv list. Since these endpoints
are unauthenticated, a caller could pass a value like
"--exec=<cmd>" instead of a real URL; yt-dlp parses any argv item
starting with "-" as an option rather than a positional URL, so
this allowed arbitrary command execution on the host after a
(fake) download.

Fixes:
- Add is_safe_url() to require an http(s) scheme + host, rejecting
  anything that could be interpreted as a CLI flag.
- Insert a "--" argv separator before the URL in every yt-dlp
  invocation so option parsing stops regardless of URL content
  (defense in depth alongside the scheme check).
- Apply the check on all three endpoints that accept a URL.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants