From 64ac09becfb21aefa1aecccc56e5d032379a2ebc Mon Sep 17 00:00:00 2001 From: Josh Patra Date: Tue, 3 Feb 2026 19:35:39 -0500 Subject: [PATCH] Preserve MediaSources metadata for local tracks in playlists to show bitrate --- allstarr/Models/Domain/Song.cs | 6 ++++++ allstarr/Services/Jellyfin/JellyfinModelMapper.cs | 8 ++++++++ allstarr/Services/Jellyfin/JellyfinResponseBuilder.cs | 5 +++++ 3 files changed, 19 insertions(+) diff --git a/allstarr/Models/Domain/Song.cs b/allstarr/Models/Domain/Song.cs index f9abe4b..55397cb 100644 --- a/allstarr/Models/Domain/Song.cs +++ b/allstarr/Models/Domain/Song.cs @@ -99,4 +99,10 @@ public class Song /// 0 = Naturally clean, 1 = Explicit, 2 = Not applicable, 3 = Clean/edited version, 6/7 = Unknown /// public int? ExplicitContentLyrics { get; set; } + + /// + /// Raw Jellyfin metadata (MediaSources, etc.) for local tracks + /// Preserved to maintain bitrate and other technical details + /// + public Dictionary? JellyfinMetadata { get; set; } } diff --git a/allstarr/Services/Jellyfin/JellyfinModelMapper.cs b/allstarr/Services/Jellyfin/JellyfinModelMapper.cs index 6ea1502..3f15836 100644 --- a/allstarr/Services/Jellyfin/JellyfinModelMapper.cs +++ b/allstarr/Services/Jellyfin/JellyfinModelMapper.cs @@ -186,6 +186,14 @@ public class JellyfinModelMapper // Cover art URL construction song.CoverArtUrl = $"/Items/{id}/Images/Primary"; + + // Preserve Jellyfin metadata (MediaSources, etc.) for local tracks + // This ensures bitrate and other technical details are maintained + song.JellyfinMetadata = new Dictionary(); + if (item.TryGetProperty("MediaSources", out var mediaSources)) + { + song.JellyfinMetadata["MediaSources"] = JsonSerializer.Deserialize(mediaSources.GetRawText()); + } return song; } diff --git a/allstarr/Services/Jellyfin/JellyfinResponseBuilder.cs b/allstarr/Services/Jellyfin/JellyfinResponseBuilder.cs index 277c1d9..24e2725 100644 --- a/allstarr/Services/Jellyfin/JellyfinResponseBuilder.cs +++ b/allstarr/Services/Jellyfin/JellyfinResponseBuilder.cs @@ -323,6 +323,11 @@ public class JellyfinResponseBuilder } }; } + else if (song.IsLocal && song.JellyfinMetadata != null && song.JellyfinMetadata.ContainsKey("MediaSources")) + { + // Use preserved Jellyfin metadata for local tracks to maintain bitrate info + item["MediaSources"] = song.JellyfinMetadata["MediaSources"]; + } if (!string.IsNullOrEmpty(song.Genre)) {