mirror of
https://github.com/SoPat712/allstarr.git
synced 2026-02-10 07:58:39 -05:00
fix: remote track number is now working, default bitrate for remote songs, remote quality for remote songs
This commit is contained in:
@@ -832,7 +832,8 @@ public class SubsonicController : ControllerBase
|
|||||||
track = song.Track ?? 0,
|
track = song.Track ?? 0,
|
||||||
year = song.Year ?? 0,
|
year = song.Year ?? 0,
|
||||||
coverArt = song.Id, // Utilisé pour getCoverArt
|
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",
|
contentType = "audio/mpeg",
|
||||||
type = "music",
|
type = "music",
|
||||||
isVideo = false,
|
isVideo = false,
|
||||||
|
|||||||
@@ -157,9 +157,12 @@ public class DeezerMetadataService : IMusicMetadataService
|
|||||||
if (albumElement.TryGetProperty("tracks", out var tracks) &&
|
if (albumElement.TryGetProperty("tracks", out var tracks) &&
|
||||||
tracks.TryGetProperty("data", out var tracksData))
|
tracks.TryGetProperty("data", out var tracksData))
|
||||||
{
|
{
|
||||||
|
int trackIndex = 1;
|
||||||
foreach (var track in tracksData.EnumerateArray())
|
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;
|
return albums;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Song ParseDeezerTrack(JsonElement track)
|
private Song ParseDeezerTrack(JsonElement track, int? fallbackTrackNumber = null)
|
||||||
{
|
{
|
||||||
var externalId = track.GetProperty("id").GetInt64().ToString();
|
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
|
return new Song
|
||||||
{
|
{
|
||||||
Id = $"ext-deezer-{externalId}",
|
Id = $"ext-deezer-{externalId}",
|
||||||
@@ -230,9 +238,7 @@ public class DeezerMetadataService : IMusicMetadataService
|
|||||||
Duration = track.TryGetProperty("duration", out var duration)
|
Duration = track.TryGetProperty("duration", out var duration)
|
||||||
? duration.GetInt32()
|
? duration.GetInt32()
|
||||||
: null,
|
: null,
|
||||||
Track = track.TryGetProperty("track_position", out var trackPos)
|
Track = trackNumber,
|
||||||
? trackPos.GetInt32()
|
|
||||||
: null,
|
|
||||||
CoverArtUrl = track.TryGetProperty("album", out var albumForCover) &&
|
CoverArtUrl = track.TryGetProperty("album", out var albumForCover) &&
|
||||||
albumForCover.TryGetProperty("cover_medium", out var cover)
|
albumForCover.TryGetProperty("cover_medium", out var cover)
|
||||||
? cover.GetString()
|
? cover.GetString()
|
||||||
|
|||||||
Reference in New Issue
Block a user