Skip to content

Fix DASH progress bar and check that the remux succeeded - #1

Merged
joshtheclipper merged 1 commit into
joshtheclipper:devfrom
sjbrownrigg:contrib/dash-progress-and-remux-check
Aug 25, 2026
Merged

Fix DASH progress bar and check that the remux succeeded#1
joshtheclipper merged 1 commit into
joshtheclipper:devfrom
sjbrownrigg:contrib/dash-progress-and-remux-check

Conversation

@sjbrownrigg

Copy link
Copy Markdown

As offered in my comment on #1024 — here are the two fixes, on top of your dev.

Worth saying: the hard part was yours. Working out that Tidal serves HI_RES_LOSSLESS as an MPEG-DASH manifest, and that the old code was silently falling back to a lower quality when the JSON parse failed, is the reason this works at all. These are just two rough edges I hit while running it.

1. Progress bar shows every track as instantly complete

TidalDASHDownloadable inherits size(), which HEADs self.url — for a DASH track that's only the init segment, a few hundred bytes against a track of tens of MB. So the progress total is tiny and the first chunk takes it past 100%:

Track 5 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100.0% • 3.9 MB/s • 0:00:00
Track 6 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100.0% • 5.5 MB/s • 0:00:00

Now sums the init segment plus every media segment.

One detail that cost me a debugging cycle, in case it looks over-engineered: issuing one HEAD per segment concurrently got roughly half of them refused, and treating a refusal as zero bytes reported 17.0 MB for a track that downloaded 34.6 MB — so the bar was then wrong in the other direction. Hence the semaphore, and estimating any stragglers from the average rather than dropping them.

Verified by counting bytes handed to the progress callback: 34.59 MB reported against 34.59 MB delivered.

2. A failed remux is treated as a successful download

If ffmpeg fails, the temp file is removed, no output is written, and _download returns normally — so the caller counts the track as downloaded with nothing on disk. On current dev that also records it in the downloads database, so it's skipped on every future run and the track is quietly missing for good.

Now checks the exit status and that the output exists, and raises NonStreamableError otherwise, with ffmpeg's stderr in the message.

Notes

  • No new dependencies; asyncio and os were already imported at module level, so I dropped the two function-local imports.
  • Test suite is unchanged at 59 passed / 1 failed, and that failure (test_meta.py::test_album_metadata_qobuz, a genre assertion) also fails on an unmodified nathom/streamrip dev, so it's not from this.
  • I left README.md alone. My only thought there is that the "Changes from upstream / 🚨 End Fork Changes 🚨" section reads as fork documentation, so it may attract review comments if this goes upstream — entirely your call.

Tested against a Tidal "Max" subscription: q=2 returns AAC 320kbps in an m4a, q=4 with your changes returns 24-bit FLAC (96kHz on one album, 48kHz on another), decoding cleanly.

Happy to change anything here, or split it into two if you'd rather take them separately.

Two fixes for the DASH download path.

TidalDASHDownloadable inherits size(), which HEADs self.url -- for a DASH
track that is only the init segment, a few hundred bytes against a track
of tens of MB. The progress bar's total was therefore tiny, so the first
chunk took it past 100% and every track appeared to start finished:

    Track 5 ━━━━━━━━━━━━━━━━━━━━━━━━━ 100.0% • 3.9 MB/s • 0:00:00
    Track 6 ━━━━━━━━━━━━━━━━━━━━━━━━━ 100.0% • 5.5 MB/s • 0:00:00

Sum the init segment and every media segment instead. The requests are
bounded to 8 at a time: issuing one per segment at once got about half
of them refused, and counting a refusal as zero put the total at half
the real size (17.0 MB reported against 34.6 MB downloaded). Segments
that still do not answer are estimated at the average of those that did.
Verified against the progress callback: 34.59 MB reported, 34.59 MB
delivered.

Separately, the remux discarded ffmpeg's exit status. If ffmpeg failed
the temp file was removed, no output was written, and _download returned
normally -- so the caller counted the track as downloaded with nothing
on disk, and on current dev recorded it in the downloads database, which
means it is skipped on every later run. Check the exit status and that
the output exists, and raise NonStreamableError otherwise.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@joshtheclipper
joshtheclipper merged commit 5fe496b into joshtheclipper:dev Aug 25, 2026
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