mirror of
https://git.sr.ht/~joren/streamrip-go
synced 2026-06-17 15:05:39 +02:00
unify folder naming with resolved audio profiles across providers
This commit is contained in:
@@ -288,13 +288,30 @@ func (c *Client) GetDownloadable(ctx context.Context, item string, _ int) (*prov
|
||||
if ext == "" {
|
||||
ext = "m4a"
|
||||
}
|
||||
return &provider.Downloadable{URL: streamURL, Extension: ext, Source: "soundcloud"}, nil
|
||||
return &provider.Downloadable{URL: streamURL, Extension: ext, Source: "soundcloud", Audio: soundcloudAudioProfile(ext)}, nil
|
||||
}
|
||||
|
||||
func (c *Client) Close() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func soundcloudAudioProfile(ext string) provider.AudioProfile {
|
||||
switch strings.ToLower(strings.TrimSpace(ext)) {
|
||||
case "mp3":
|
||||
return provider.AudioProfile{Container: "MP3", Codec: "MP3", Quality: "LOSSY", BitDepth: 16, SamplingRate: "44.1"}
|
||||
case "flac":
|
||||
return provider.AudioProfile{Container: "FLAC", Codec: "FLAC", Quality: "LOSSLESS", BitDepth: 16, SamplingRate: "44.1"}
|
||||
case "m4a", "aac":
|
||||
return provider.AudioProfile{Container: "M4A", Codec: "AAC", Quality: "LOSSY", BitDepth: 16, SamplingRate: "44.1"}
|
||||
default:
|
||||
container := strings.ToUpper(strings.TrimSpace(ext))
|
||||
if container == "" {
|
||||
container = "M4A"
|
||||
}
|
||||
return provider.AudioProfile{Container: container, Codec: container, Quality: "LOSSY", BitDepth: 16, SamplingRate: "44.1"}
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Client) trackInfo(ctx context.Context, item string) (map[string]any, error) {
|
||||
if strings.TrimSpace(item) == "" {
|
||||
return nil, errors.New("empty soundcloud item")
|
||||
|
||||
@@ -43,6 +43,9 @@ func TestGetTrackMetadataAndDownloadable(t *testing.T) {
|
||||
if d.URL != "https://cdn.example/audio.m4a" || d.Extension != "m4a" {
|
||||
t.Fatalf("unexpected downloadable: %+v", d)
|
||||
}
|
||||
if d.Audio.Container != "M4A" || d.Audio.Codec != "AAC" {
|
||||
t.Fatalf("unexpected audio profile: %+v", d.Audio)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetPlaylistMetadata(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user