From 5af6d7fac6594043259de59ed07eb2fc5ea10fb8 Mon Sep 17 00:00:00 2001 From: Bryan Van Deusen Date: Tue, 21 Apr 2026 22:35:29 -0400 Subject: [PATCH] docs(api): document intentional audioContentType divergence from subsonic --- internal/api/library_fixtures_test.go | 1 + internal/api/media.go | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/internal/api/library_fixtures_test.go b/internal/api/library_fixtures_test.go index 3cf13b61..6dafbf4c 100644 --- a/internal/api/library_fixtures_test.go +++ b/internal/api/library_fixtures_test.go @@ -107,6 +107,7 @@ func seedTrackWithFile(t *testing.T, pool *pgxpool.Pool, albumID, artistID pgtyp ArtistID: artistID, TrackNumber: &one, DiscNumber: nil, + // DurationMs: arbitrary non-zero; tests don't assert on it. DurationMs: int32(len(fileBody)), FilePath: path, FileSize: int64(len(fileBody)), diff --git a/internal/api/media.go b/internal/api/media.go index 5f65f107..d27d46f5 100644 --- a/internal/api/media.go +++ b/internal/api/media.go @@ -57,6 +57,12 @@ func resolveAlbumCoverPath(ctx context.Context, q *dbq.Queries, album dbq.Album) // ogg, opus, m4a, aac, wav) to a MIME type for the Content-Type header. // Unknown formats fall back to octet-stream so the browser downloads them // rather than attempting to decode. +// +// Divergences from internal/subsonic/types.go's contentTypeForFormat are +// intentional: opus→audio/ogg (library .opus files are Ogg-encapsulated, so +// this matches real library contents), aac→audio/aac (raw AAC is ADTS, not +// MP4, so audio/mp4 would mislead codec sniffers), and there is no "oga" case +// (we don't record that format). Don't "fix" these to match subsonic. func audioContentType(format string) string { switch strings.ToLower(format) { case "mp3":