Skip to content

Improve yt-dlp video format presentation - #51

Merged
thsnkhn merged 11 commits into
thsnkhn:mainfrom
QZGao:yt-dlp-fix
Jul 31, 2026
Merged

Improve yt-dlp video format presentation#51
thsnkhn merged 11 commits into
thsnkhn:mainfrom
QZGao:yt-dlp-fix

Conversation

@QZGao

@QZGao QZGao commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

When implementing #50, I found that the yt-dlp pipeline is not very intuitive. Therefore this PR works on its features and presentation.

Changelist

Improve yt-dlp eligibility validation using checked format metadata instead of file extensions, extractor names, or known-host assumptions.

  • Reject unknown codecs, possible DRM formats, audio-only results, and ordinary files incorrectly identified by yt-dlp’s Generic extractor.
  • Probe all currently downloadable formats using --check-all-formats.
  • Convert raw yt-dlp streams into meaningful output options:
    • Keep combined video/audio formats.
    • Pair video-only formats with compatible checked audio.
    • Preserve distinct resolution, codec, bitrate, frame-rate, HDR, container, and size variants.
    • Remove equivalent duplicate outputs.
    • Support checked silent-video formats without inventing audio.

Improve presentation for yt-dlp downloads:

  • Present available formats as a scrollable radio list in the Add Download sheet.
  • Migrate the removed legacy Best MP4 preference to Original. Default every media download to Original.
  • Store exact selected format IDs with each download.
  • Pass exact selectors such as 137+140 to yt-dlp without silently falling back to another format.
  • Report an error when a previously selected format is no longer available.
  • Show media preview, format selection, and ownership confirmation only after yt-dlp verifies a video source.

Fixes several bugs:

  • Prevent known media hosts from silently falling back to downloading an HTML page through URLSession.
  • Keep unverified ordinary URLs on the direct URLSession backend.
  • Make loading, preview, error, and pending media rows mutually exclusive.

Verification: built and tested locally.

I did not implement #40; currently the toggle defaults to OFF. If you prefer, we can set the default to ON -- or if you are a different idea on how to address it.

@QZGao QZGao changed the title feat: validate/optimize yt-dlp video formats Improve yt-dlp video format presentation Jul 24, 2026
# Conflicts:
#	Harbor/Services/MediaDownloadService.swift
#	Harbor/ViewModels/DownloadCenter.swift
@thsnkhn

thsnkhn commented Jul 27, 2026

Copy link
Copy Markdown
Owner

@QZGao I think keeping the toggle defaults to ON is good for now. I'll think of better UI for whole add download sheet.

@thsnkhn thsnkhn left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a few thoughts inline. The exact format work is useful — I think we can keep it while making the routing a bit simpler and preserving the media types Harbor already supports.

Comment thread Harbor/Services/MediaDownloadService.swift Outdated
Comment thread Harbor/Views/AddDownloadSheet.swift
Comment thread Harbor/ViewModels/DownloadCenter.swift Outdated
Comment thread Harbor/Views/AddDownloadSheet.swift Outdated
Comment thread Harbor/Models/MediaDownloadMetadata.swift
Comment thread Harbor/Views/AddDownloadSheet.swift Outdated
@QZGao

QZGao commented Jul 29, 2026

Copy link
Copy Markdown
Contributor Author

I just asked Codex to do a code review and found several issues.

  1. YouTube recently incorporates AI slop dub so now some popular videos can contain multiple audio tracks. We cannot arbitrarily select best available audio in this case. Therefore auto-merging video-only with audio-only formats is no longer preferable. Instead, I am working on separating those formats and let users pick what audio-only and video-only formats they like.

@QZGao

QZGao commented Jul 29, 2026

Copy link
Copy Markdown
Contributor Author

The new GUI for yt-dlp format selection:

image image image image

@QZGao

QZGao commented Jul 29, 2026

Copy link
Copy Markdown
Contributor Author
  1. Failed “Best available” downloads could lose format recovery after relaunch.
  2. Retrying an exact format can retain the wrong total size. (Now that we have separated audio and video, we can make the estimate more accurate.)
  3. A refreshed catalog can leave the Picker with no matching selection.
  4. A legacy selector does not necessarily receive its promised fresh probe.

I am working on fixing each of the issues identified.

@QZGao

QZGao commented Jul 29, 2026

Copy link
Copy Markdown
Contributor Author

Okay, the aforementioned issues have been fixed.

@thsnkhn

thsnkhn commented Jul 30, 2026

Copy link
Copy Markdown
Owner

I liked your designs. let me take a pull to test it out

@QZGao

QZGao commented Jul 31, 2026

Copy link
Copy Markdown
Contributor Author

YouTube recently incorporates AI slop dub so now some popular videos can contain multiple audio tracks.

Side note: Currently Harbor's bundled yt-dlp 2026.06.09 can only return original voice tracks. This is an upstream issue from yt-dlp/yt-dlp#15756 and its fix was just merged on July 20th in yt-dlp/yt-dlp#17261. To actually have Harbor display multiple-language tracks, we need to either update the bundled yt-dlp to the latest unstable/nightly build, or wait for the next stable release.

(P.S. This issue hardly matters anyway. Few people would want to download those AI slop dubs so we can just call it day and wait for the next yt-dlp stable release.)

@thsnkhn
thsnkhn merged commit f027430 into thsnkhn:main Jul 31, 2026
@thsnkhn

thsnkhn commented Jul 31, 2026

Copy link
Copy Markdown
Owner

im gonna merge it now. will use the app to see overall UX, improve if needed otherwise will be releasing it. thanks for your efforts

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