Documentation
¶
Index ¶
Constants ¶
const ( // Downloads the HLS stream on the backend, and restreams it to frontend as a file. Requires no JS, but less stable client-side RestreamPlayer string = "restream" // Downloads the HLS stream on the frontend (proxying can be enabled). Requires JS, more stable client-side HLSPlayer string = "hls" // Disables the song player NonePlayer string = "none" )
const ( // Just plays every song in order, one after another AutoplayNormal string = "normal" // Randomly selects a song to play from the playlist AutoplayRandom string = "random" )
const ( // choose best for quality/size (AudioAAC over AudioOpus over AudioMP3) AudioBest string = "best" // 160kbps m4a AAC audio, rarely available (fallback to AudioMP3 if unavailable) AudioAAC string = "aac" // 72kbps ogg opus audio, usually available 99% of the time (fallback to AudioMP3 if unavailable) AudioOpus string = "opus" // 128kbps mp3 audio, always available, good for compatibility AudioMP3 string = "mpeg" )
const Commit = "unknown"
const CommitURL = "unknown"
const Debug = false
const HLSAACCDN = "playback.media-streaming.soundcloud.cloud"
const HLSCDN = "cf-hls-media.sndcdn.com"
const ImageCDN = "i1.sndcdn.com"
seems soundcloud has 4 of these (i1, i2, i3, i4) they point to the same ip from my observations, and they all serve the same files
const MaxIdleConnDuration = 4 * time.Hour
Note: we don't need DialDualStack for clients, soundcloud has no ipv6 support and operates only over http1.1 :D
const Repo = "unknown"
Variables ¶
var Addr = ":4664"
run soundcloak on this address (localhost:4664 by default)
var ClientIDTTL = 4 * time.Hour
time-to-live for clientid cache larger number will improve performance (no need to recheck everytime) but might make soundcloak briefly unusable for a larger amount of time if the client id is invalidated I went with 4 hours, since those clientids still remain active for quite some time, even after soundcloud updates it
var CodegenConfig = false
generate code for config (run soundcloakctl config codegen or use docker image - it runs it for you)
var DNSCacheTTL = 60 * time.Minute
time-to-live for dns cache
var EmbedFiles = false
use static files embedded in binary
var False = false
var GetWebProfiles = true
Retrieve links users set in their profile (social media, website, etc)
var ImageCacheControl = "max-age=600, public, immutable" // browser-side 10 minutes cache by default, only used for proxied images
var InstanceInfo = true
enable /_/info endpoint (shows if some settings are enabled/disabled)
var Network = "tcp4"
where to listen can be tcp4 (bind to ipv4 address), tcp6 (bind to ipv6 address) or unix (bind to unix socket)
var PlaylistCacheCleanDelay = PlaylistTTL / 4
delay between cleanup of playlist cache
var PlaylistTTL = 20 * time.Minute
time-to-live for playlist cache
var Prefork = false
run multiple instances of soundcloak locally to be able to handle more requests each one will be a separate process, so they will have separate cache
var ProxyImages = false
proxy images (user avatars, track/playlist covers)
var ProxyStreams = false
proxy streams (hls playlist files and track parts)
var Restream = false
restream the HLS playlist as just a file, makes soundcloak usable with zero JS If this setting is set to true, ProxyStreams and FullyPreloadTrack will be ignored (you could count this as a replacement for having both as true, also should be a bit more effective) You can also easily download the songs this way (right click => save audio as..., the only downside is that there is no metadata)
var RestreamCacheControl = "max-age=3600, public, immutable"
var TrackCacheCleanDelay = TrackTTL / 4
delay between cleanup of track cache
var TrackTTL = 20 * time.Minute
time-to-live for track cache
var True = true
var TrustedProxies = []string{}
list of ips or ip ranges of trusted proxies (check above)
var TrustedProxyCheck = true
use X-Forwarded-* headers ONLY when ip is in TrustedProxies list when disabled, the X-Forwarded-* headers will be blindly used
var UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.3"
default fasthttp one was causing connections to be stuck? todo make it cycle browser useragents or just choose random at startup
var UserCacheCleanDelay = UserTTL / 4
delay between cleanup of user cache
var UserTTL = 20 * time.Minute
time-to-live for user profile cache
Functions ¶
Types ¶
type Preferences ¶
type Preferences struct { Player *string ProxyStreams *bool // fully loads the track on page load // this option is here since the stream expires after some time (5 minutes? correct me if im wrong) // if the stream isn't fully loaded before it expires - you'll need to reload the page FullyPreloadTrack *bool ProxyImages *bool // Highlight @username, https://example.com and email@example.com in text as clickable links ParseDescriptions *bool // Automatically play next track in playlists AutoplayNextTrack *bool // Automatically play next related track AutoplayNextRelatedTrack *bool DefaultAutoplayMode *string // "normal" or "random" // Check above for more info // Probably best to keep all at "mpeg" by default for compatibility HLSAudio *string // Please don't use "opus" or "best". hls.js doesn't work with ogg/opus RestreamAudio *string // You can actually use anything here DownloadAudio *string // "aac" may not play well with some players ShowAudio *bool // display audio (aac, opus, mpeg etc) under track player SearchSuggestions *bool // load search suggestions on main page DynamicLoadComments *bool // dynamic comments loader without leaving track page KeepPlayerFocus *bool // keep player element in focus }
var DefaultPreferences Preferences
Default preferences. You can override those preferences in the config file, otherwise they default to values depending on your config (so, if you have ProxyStreams enabled - it will be enabled for the user by default and etc, or if you enabled Restream, the default player will be RestreamPlayer instead of HLSPlayer)