Streams and transcodings
August 2, 2026 · View on GitHub
resolve_stream
url = sc.resolve_stream(track_url, prefer="progressive")
url = sc.resolve_stream(track_url, prefer="hls")
prefer accepts only "progressive" or "hls". Any other value raises a
ValueError.
resolve_stream returns the direct audio URL as a string, or None when
resolution fails.
SoundCloudAPI path
SoundCloudAPI.resolve_stream: nuvem_de_som/__init__.py:660
- Calls
GET /resolve?url=<track_url>to get the track JSON. - Reads
media.transcodings[], and sorts by preferred protocol first, then any. - For each transcoding entry, calls
GET <transcoding.url>?client_id=<cid>. - Returns the
urlfield from the first successful response.
No yt-dlp is involved at any point.
SoundCloudYTDLP path
SoundCloudYTDLP.resolve_stream: nuvem_de_som/__init__.py:1330
Runs yt_dlp.YoutubeDL.extract_info(track_url) without downloading, then
walks info["formats"] in reverse (highest quality last). It maps:
prefer="progressive"toformat.protocol == "https"prefer="hls"toformat.protocol == "m3u8_native"
It falls back to the last format entry, or to info["url"], if no match is found.
SoundCloudHTML
resolve_stream raises NotImplementedError. SoundCloud's signed stream
URLs are not present in the page HTML.
_parse_transcodings: codec and bitrate on Release
_parse_transcodings: nuvem_de_som/__init__.py:150
SoundCloudAPI._parse_track calls this on the media.transcodings[] array
from the API. It returns (codec, bitrate):
- Filters to
protocol == "progressive"entries. If none exist, it uses all entries. - Sorts by
quality:hq(0) beforesq(1) before anything else. - Reads the best entry:
codec = format.mime_type(for example"audio/mpeg"), andbitrate = "256"forhqor"128"forsq.
These values populate Release.codec, Release.bitrate, and
Release.audio_channels ("stereo" whenever a codec is known, "" otherwise).
Progressive vs HLS
| Type | prefer= | Format | Seekable | Notes |
|---|---|---|---|---|
| Progressive | "progressive" | MP3 / AAC direct URL | Yes | Default |
| HLS | "hls" | .m3u8 playlist | Player-dependent | Useful for live/DRM content |
SoundCloud serves most tracks in both formats. Progressive is the default and works directly in any HTTP-capable media player.