Skip to content

ytdlp source: playback 403s because range is sent as a query param, not a Range header #345

Open

Description

@m-9-k

Describe the bug

ytdlp source playback (introduced ~4.8.0) fails almost every track with a 403 during streaming, thrown from YoutubePersistentHttpStream (via YtdlpAudioTrack.process), even though the URL yt-dlp extracted is valid and playable.

Root cause (reproduced)

YoutubePersistentHttpStream overrides useHeadersForRange() to return false, so range requests are sent as a range=<start>-<end> query parameter appended to the googlevideo.com URL instead of a normal Range: header. YouTube's CDN now rejects that query-param form with 403, while a standard Range: header on the exact same URL succeeds.

Verified directly against the URL yt-dlp itself returned for a track (filesize/ext etc. all present, so this isn't an extraction failure):

$ curl -s -o /dev/null -w '%{http_code}\n' -H 'Range: bytes=0-1000' "$URL"
206

$ curl -s -o /dev/null -w '%{http_code}\n' "${URL}&range=0-11862014"
403

Same URL, same server/IP, same request otherwise — User-Agent doesn't matter either (tested with yt-dlp's own reported http_headers.User-Agent, a plain Apache-HttpClient-style UA, and no UA at all; all three return 403 with the query-param form and 206 with the header form).

This looks like a leftover from an older youtube-source technique for avoiding CDN throttling that YouTube has since started blocking outright — the same anti-bot shift that's currently breaking dev.lavalink.youtube (lavalink-devs/youtube-source#216, #217).

Lavalink logs

ERROR --- [back-1-thread-1] c.s.d.l.t.p.LocalAudioTrackExecutor : Error in playback of <videoId>
com.sedmelluq.discord.lavaplayer.tools.FriendlyException: Something broke when playing the track.
Caused by: java.lang.RuntimeException: Not success status code: 403
	at com.github.topi314.lavasrc.ytdlp.YtdlpAudioTrack.process(YtdlpAudioTrack.java:61)

To Reproduce

  1. Configure the ytdlp LavaSrc source (plugins.lavasrc.sources.ytdlp: true) as the sole YouTube playback path.
  2. Play basically any non-live YouTube track.
  3. Playback starts loading, then fails partway through with the 403 above.

Expected behavior

Track streams normally.

Environment

  • Lavalink 4 (ghcr.io/lavalink-devs/lavalink:4-alpine)
  • lavasrc-plugin 4.8.3
  • yt-dlp 2026.07.04 (current latest release)

Suggested fix

YoutubePersistentHttpStream.useHeadersForRange() should return true (or the override should be removed entirely, falling back to the parent PersistentHttpStream's header-based ranging).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions