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:
@@ -308,7 +308,14 @@ func (c *Client) GetDownloadable(ctx context.Context, item string, _ int) (*prov
|
||||
if trackID == "" {
|
||||
trackID = strings.TrimSpace(item)
|
||||
}
|
||||
return &provider.Downloadable{URL: media.URL, Extension: ext, Source: "deezer", Cipher: media.Cipher, TrackID: trackID}, nil
|
||||
return &provider.Downloadable{
|
||||
URL: media.URL,
|
||||
Extension: ext,
|
||||
Source: "deezer",
|
||||
Cipher: media.Cipher,
|
||||
TrackID: trackID,
|
||||
Audio: audioProfileForFormat(media.Format),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (c *Client) apiGet(ctx context.Context, path string, params url.Values) (map[string]any, error) {
|
||||
@@ -1223,6 +1230,55 @@ func extensionForFormat(format string) string {
|
||||
}
|
||||
}
|
||||
|
||||
func audioProfileForFormat(format string) provider.AudioProfile {
|
||||
profile := provider.AudioProfile{}
|
||||
switch strings.ToUpper(strings.TrimSpace(format)) {
|
||||
case "FLAC":
|
||||
profile.Container = "FLAC"
|
||||
profile.Codec = "FLAC"
|
||||
profile.Quality = "LOSSLESS"
|
||||
profile.BitDepth = 16
|
||||
profile.SamplingRate = "44.1"
|
||||
case "MP3_320":
|
||||
profile.Container = "MP3"
|
||||
profile.Codec = "MP3"
|
||||
profile.Quality = "HIGH"
|
||||
profile.BitrateKbps = 320
|
||||
profile.BitDepth = 16
|
||||
profile.SamplingRate = "44.1"
|
||||
case "MP3_128":
|
||||
profile.Container = "MP3"
|
||||
profile.Codec = "MP3"
|
||||
profile.Quality = "LOW"
|
||||
profile.BitrateKbps = 128
|
||||
profile.BitDepth = 16
|
||||
profile.SamplingRate = "44.1"
|
||||
case "MP3_64", "MP3_MISC":
|
||||
profile.Container = "MP3"
|
||||
profile.Codec = "MP3"
|
||||
profile.Quality = "LOW"
|
||||
profile.BitrateKbps = 64
|
||||
profile.BitDepth = 16
|
||||
profile.SamplingRate = "44.1"
|
||||
default:
|
||||
if ext := extensionForFormat(format); ext == "flac" {
|
||||
profile.Container = "FLAC"
|
||||
profile.Codec = "FLAC"
|
||||
profile.Quality = "LOSSLESS"
|
||||
profile.BitDepth = 16
|
||||
profile.SamplingRate = "44.1"
|
||||
} else {
|
||||
profile.Container = "MP3"
|
||||
profile.Codec = "MP3"
|
||||
profile.Quality = "LOW"
|
||||
profile.BitrateKbps = 128
|
||||
profile.BitDepth = 16
|
||||
profile.SamplingRate = "44.1"
|
||||
}
|
||||
}
|
||||
return profile
|
||||
}
|
||||
|
||||
func findStringByKey(v any, wantedKey string) string {
|
||||
w := strings.ToLower(strings.TrimSpace(wantedKey))
|
||||
switch x := v.(type) {
|
||||
|
||||
@@ -139,6 +139,9 @@ func TestGetDownloadableNativeCipher(t *testing.T) {
|
||||
if d.Cipher != "BF_CBC_STRIPE" || d.Extension != "flac" || d.TrackID != "42" {
|
||||
t.Fatalf("unexpected downloadable: %+v", d)
|
||||
}
|
||||
if d.Audio.Container != "FLAC" || d.Audio.Quality != "LOSSLESS" {
|
||||
t.Fatalf("unexpected audio profile: %+v", d.Audio)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetDownloadableRequiresARL(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user