fix: remote track number is now working, default bitrate for remote songs, remote quality for remote songs

This commit is contained in:
V1ck3s
2025-12-11 22:16:43 +01:00
committed by Vickes
parent 288613d62b
commit 96f6f7f8d4
2 changed files with 13 additions and 6 deletions

View File

@@ -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,

View File

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