From 5bcd339501b24aad8ebe1cbee5d74b39c1ec80a0 Mon Sep 17 00:00:00 2001 From: sentriz Date: Fri, 29 Dec 2023 22:06:12 +0000 Subject: [PATCH] add more logging to transcode rules related #445 --- server/ctrlsubsonic/handlers_raw.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/server/ctrlsubsonic/handlers_raw.go b/server/ctrlsubsonic/handlers_raw.go index 4389e19..c77584c 100644 --- a/server/ctrlsubsonic/handlers_raw.go +++ b/server/ctrlsubsonic/handlers_raw.go @@ -188,16 +188,24 @@ func (c *Controller) ServeStream(w http.ResponseWriter, r *http.Request) *spec.R format, _ := params.Get("format") timeOffset, _ := params.GetInt("timeOffset") - if format == "raw" || maxBitRate >= audioFile.AudioBitrate() { + if format == "raw" { http.ServeFile(w, r, file.AbsPath()) return nil } - pref, err := streamGetTransodePreference(c.dbc, user.ID, params.GetOr("c", "")) + client, _ := params.Get("c") + pref, err := streamGetTransodePreference(c.dbc, user.ID, client) if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) { return spec.NewError(0, "couldn't find transcode preference: %v", err) } if pref == nil { + log.Printf("serving raw file, no transcode preferences found for client %q", client) + http.ServeFile(w, r, file.AbsPath()) + return nil + } + + if maxBitRate >= audioFile.AudioBitrate() { + log.Printf("serving raw file, requested max bitrate %dk is greater or equal to %dk", maxBitRate, audioFile.AudioBitrate()) http.ServeFile(w, r, file.AbsPath()) return nil } @@ -213,7 +221,7 @@ func (c *Controller) ServeStream(w http.ResponseWriter, r *http.Request) *spec.R profile = transcode.WithSeek(profile, time.Second*time.Duration(timeOffset)) } - log.Printf("trancoding to %q with max bitrate %dk", profile.MIME(), profile.BitRate()) + log.Printf("trancoding to %q with at bitrate %dk", profile.MIME(), profile.BitRate()) w.Header().Set("Content-Type", profile.MIME()) if err := c.transcoder.Transcode(r.Context(), profile, file.AbsPath(), w); err != nil && !errors.Is(err, transcode.ErrFFmpegKilled) {