Skip to content

Conversation

Hp-Ro
Copy link

@Hp-Ro Hp-Ro commented Jul 3, 2025

Problem

When using the SoundCloud plugin (@distube/soundcloud) with DisTube, the getStreamURL() method internally calls this.soundcloud.util.streamLink(song.url) to get the stream URL.
However, in some cases — especially after a track is resolved via a search — streamLink() returns null, which triggers a misleading SOUNDCLOUD_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 by streamLink, or due to the wrong protocol (e.g., hls instead of progressive) being selected.


Fix

This PR modifies getStreamURL(song) to:

  • First try streamLink(song.url) as usual.
  • If that fails (returns null), fallback to resolving the track manually using this.soundcloud.resolve.get(song.url, true).
  • From the resolved track object, pick the progressive transcoding (if available), and use the client_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

  • No external libraries were used.
  • Doesn't modify any utility methods or other core logic.
  • Preserves original return type.

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