unify folder naming with resolved audio profiles across providers

This commit is contained in:
2026-04-24 00:35:38 +02:00
parent d5b336ca4e
commit 232901f3eb
11 changed files with 550 additions and 33 deletions

View File

@@ -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) {