From 96f6f7f8d4f0048fb6e5f86450764448fe0427df Mon Sep 17 00:00:00 2001 From: V1ck3s Date: Thu, 11 Dec 2025 22:16:43 +0100 Subject: [PATCH] fix: remote track number is now working, default bitrate for remote songs, remote quality for remote songs --- octo-fiesta/Controllers/SubSonicController.cs | 3 ++- octo-fiesta/Services/DeezerMetadataService.cs | 16 +++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/octo-fiesta/Controllers/SubSonicController.cs b/octo-fiesta/Controllers/SubSonicController.cs index a6e6df0..af51297 100644 --- a/octo-fiesta/Controllers/SubSonicController.cs +++ b/octo-fiesta/Controllers/SubSonicController.cs @@ -832,7 +832,8 @@ public class SubsonicController : ControllerBase track = song.Track ?? 0, year = song.Year ?? 0, coverArt = song.Id, // Utilisé pour getCoverArt - suffix = "mp3", + suffix = song.IsLocal ? "mp3" : "Remote", + bitRate = song.IsLocal ? (int?)null : 0, // 0 for remote tracks contentType = "audio/mpeg", type = "music", isVideo = false, diff --git a/octo-fiesta/Services/DeezerMetadataService.cs b/octo-fiesta/Services/DeezerMetadataService.cs index ece92b4..45664c4 100644 --- a/octo-fiesta/Services/DeezerMetadataService.cs +++ b/octo-fiesta/Services/DeezerMetadataService.cs @@ -157,9 +157,12 @@ public class DeezerMetadataService : IMusicMetadataService if (albumElement.TryGetProperty("tracks", out var tracks) && tracks.TryGetProperty("data", out var tracksData)) { + int trackIndex = 1; foreach (var track in tracksData.EnumerateArray()) { - album.Songs.Add(ParseDeezerTrack(track)); + // Pass the index as fallback for track_position (Deezer doesn't include it in album tracks) + album.Songs.Add(ParseDeezerTrack(track, trackIndex)); + trackIndex++; } } @@ -207,10 +210,15 @@ public class DeezerMetadataService : IMusicMetadataService return albums; } - private Song ParseDeezerTrack(JsonElement track) + private Song ParseDeezerTrack(JsonElement track, int? fallbackTrackNumber = null) { var externalId = track.GetProperty("id").GetInt64().ToString(); + // Try to get track_position from API, fallback to provided index + int? trackNumber = track.TryGetProperty("track_position", out var trackPos) + ? trackPos.GetInt32() + : fallbackTrackNumber; + return new Song { Id = $"ext-deezer-{externalId}", @@ -230,9 +238,7 @@ public class DeezerMetadataService : IMusicMetadataService Duration = track.TryGetProperty("duration", out var duration) ? duration.GetInt32() : null, - Track = track.TryGetProperty("track_position", out var trackPos) - ? trackPos.GetInt32() - : null, + Track = trackNumber, CoverArtUrl = track.TryGetProperty("album", out var albumForCover) && albumForCover.TryGetProperty("cover_medium", out var cover) ? cover.GetString()