Fix fallback in getStreamURL to avoid fake rate limit when streamLink returns null #14
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
When using the SoundCloud plugin (
@distube/soundcloud
) with DisTube, thegetStreamURL()
method internally callsthis.soundcloud.util.streamLink(song.url)
to get the stream URL.However, in some cases — especially after a track is resolved via a search —
streamLink()
returnsnull
, which triggers a misleadingSOUNDCLOUD_PLUGIN_RATE_LIMITED
error.This issue doesn't happen when playing the same track by URL (after being resolved via
.resolve.get()
), which indicates that it's not an actual rate limit.It's likely caused by incomplete or malformed
media.transcodings
on the object returned bystreamLink
, or due to the wrong protocol (e.g.,hls
instead ofprogressive
) being selected.Fix
This PR modifies
getStreamURL(song)
to:streamLink(song.url)
as usual.this.soundcloud.resolve.get(song.url, true)
.progressive
transcoding (if available), and use theclient_id
to fetch the actual stream URL.The function still returns a raw
string
(URL) just like before, so this change is non-breaking and safe for the rest of the plugin's consumers.Why it matters
Right now, users of DisTube who rely on this plugin get occasional
SOUNDCLOUD_PLUGIN_RATE_LIMITED
errors when playing SoundCloud tracks fetched via search, even though there's no real rate limit applied.This fallback ensures a smoother experience and avoids breaking playback on valid tracks.
Notes