mirror of
https://github.com/SoPat712/allstarr.git
synced 2026-02-09 23:55:10 -05:00
multiple artists big fix!
This commit is contained in:
@@ -14,6 +14,11 @@ public class Song
|
|||||||
public string Title { get; set; } = string.Empty;
|
public string Title { get; set; } = string.Empty;
|
||||||
public string Artist { get; set; } = string.Empty;
|
public string Artist { get; set; } = string.Empty;
|
||||||
public string? ArtistId { get; set; }
|
public string? ArtistId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// All artists for this track (main + featured). For display in Jellyfin clients.
|
||||||
|
/// </summary>
|
||||||
|
public List<string> Artists { get; set; } = new();
|
||||||
public string Album { get; set; } = string.Empty;
|
public string Album { get; set; } = string.Empty;
|
||||||
public string? AlbumId { get; set; }
|
public string? AlbumId { get; set; }
|
||||||
public int? Duration { get; set; } // In seconds
|
public int? Duration { get; set; } // In seconds
|
||||||
|
|||||||
@@ -186,7 +186,7 @@ public class JellyfinResponseBuilder
|
|||||||
["Type"] = "Audio",
|
["Type"] = "Audio",
|
||||||
["Album"] = song.Album,
|
["Album"] = song.Album,
|
||||||
["AlbumArtist"] = song.Artist,
|
["AlbumArtist"] = song.Artist,
|
||||||
["Artists"] = new[] { song.Artist },
|
["Artists"] = song.Artists.Count > 0 ? song.Artists.ToArray() : new[] { song.Artist },
|
||||||
["RunTimeTicks"] = (song.Duration ?? 0) * TimeSpan.TicksPerSecond,
|
["RunTimeTicks"] = (song.Duration ?? 0) * TimeSpan.TicksPerSecond,
|
||||||
["ImageTags"] = new Dictionary<string, string>
|
["ImageTags"] = new Dictionary<string, string>
|
||||||
{
|
{
|
||||||
@@ -242,7 +242,7 @@ public class JellyfinResponseBuilder
|
|||||||
["Album"] = song.Album,
|
["Album"] = song.Album,
|
||||||
["AlbumId"] = song.AlbumId ?? song.Id,
|
["AlbumId"] = song.AlbumId ?? song.Id,
|
||||||
["AlbumArtist"] = song.AlbumArtist ?? song.Artist,
|
["AlbumArtist"] = song.AlbumArtist ?? song.Artist,
|
||||||
["Artists"] = new[] { song.Artist },
|
["Artists"] = song.Artists.Count > 0 ? song.Artists.ToArray() : new[] { song.Artist },
|
||||||
["ArtistItems"] = new[]
|
["ArtistItems"] = new[]
|
||||||
{
|
{
|
||||||
new Dictionary<string, object?>
|
new Dictionary<string, object?>
|
||||||
|
|||||||
@@ -551,26 +551,36 @@ public class SquidWTFMetadataService : IMusicMetadataService
|
|||||||
? volNum.GetInt32()
|
? volNum.GetInt32()
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
// Get artist name - handle both single artist and artists array
|
// Get all artists - Tidal provides both "artist" (singular) and "artists" (plural array)
|
||||||
|
var allArtists = new List<string>();
|
||||||
string artistName = "";
|
string artistName = "";
|
||||||
if (track.TryGetProperty("artist", out var artist))
|
string? artistId = null;
|
||||||
|
|
||||||
|
// Prefer the "artists" array as it includes all collaborators
|
||||||
|
if (track.TryGetProperty("artists", out var artists) && artists.GetArrayLength() > 0)
|
||||||
|
{
|
||||||
|
foreach (var artistEl in artists.EnumerateArray())
|
||||||
|
{
|
||||||
|
var name = artistEl.GetProperty("name").GetString();
|
||||||
|
if (!string.IsNullOrEmpty(name))
|
||||||
|
{
|
||||||
|
allArtists.Add(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// First artist is the main artist
|
||||||
|
if (allArtists.Count > 0)
|
||||||
|
{
|
||||||
|
artistName = allArtists[0];
|
||||||
|
artistId = $"ext-squidwtf-artist-{artists[0].GetProperty("id").GetInt64()}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Fallback to singular "artist" field
|
||||||
|
else if (track.TryGetProperty("artist", out var artist))
|
||||||
{
|
{
|
||||||
artistName = artist.GetProperty("name").GetString() ?? "";
|
artistName = artist.GetProperty("name").GetString() ?? "";
|
||||||
}
|
artistId = $"ext-squidwtf-artist-{artist.GetProperty("id").GetInt64()}";
|
||||||
else if (track.TryGetProperty("artists", out var artists) && artists.GetArrayLength() > 0)
|
allArtists.Add(artistName);
|
||||||
{
|
|
||||||
artistName = artists[0].GetProperty("name").GetString() ?? "";
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get artist ID
|
|
||||||
string? artistId = null;
|
|
||||||
if (track.TryGetProperty("artist", out var artistForId))
|
|
||||||
{
|
|
||||||
artistId = $"ext-squidwtf-artist-{artistForId.GetProperty("id").GetInt64()}";
|
|
||||||
}
|
|
||||||
else if (track.TryGetProperty("artists", out var artistsForId) && artistsForId.GetArrayLength() > 0)
|
|
||||||
{
|
|
||||||
artistId = $"ext-squidwtf-artist-{artistsForId[0].GetProperty("id").GetInt64()}";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get album info
|
// Get album info
|
||||||
@@ -596,6 +606,7 @@ public class SquidWTFMetadataService : IMusicMetadataService
|
|||||||
Title = track.GetProperty("title").GetString() ?? "",
|
Title = track.GetProperty("title").GetString() ?? "",
|
||||||
Artist = artistName,
|
Artist = artistName,
|
||||||
ArtistId = artistId,
|
ArtistId = artistId,
|
||||||
|
Artists = allArtists,
|
||||||
Album = albumTitle,
|
Album = albumTitle,
|
||||||
AlbumId = albumId,
|
AlbumId = albumId,
|
||||||
Duration = track.TryGetProperty("duration", out var duration)
|
Duration = track.TryGetProperty("duration", out var duration)
|
||||||
@@ -649,9 +660,34 @@ public class SquidWTFMetadataService : IMusicMetadataService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get artist info
|
// Get all artists - prefer "artists" array for collaborations
|
||||||
string artistName = track.GetProperty("artist").GetProperty("name").GetString() ?? "";
|
var allArtists = new List<string>();
|
||||||
long artistIdNum = track.GetProperty("artist").GetProperty("id").GetInt64();
|
string artistName = "";
|
||||||
|
long artistIdNum = 0;
|
||||||
|
|
||||||
|
if (track.TryGetProperty("artists", out var artists) && artists.GetArrayLength() > 0)
|
||||||
|
{
|
||||||
|
foreach (var artistEl in artists.EnumerateArray())
|
||||||
|
{
|
||||||
|
var name = artistEl.GetProperty("name").GetString();
|
||||||
|
if (!string.IsNullOrEmpty(name))
|
||||||
|
{
|
||||||
|
allArtists.Add(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (allArtists.Count > 0)
|
||||||
|
{
|
||||||
|
artistName = allArtists[0];
|
||||||
|
artistIdNum = artists[0].GetProperty("id").GetInt64();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (track.TryGetProperty("artist", out var artist))
|
||||||
|
{
|
||||||
|
artistName = artist.GetProperty("name").GetString() ?? "";
|
||||||
|
artistIdNum = artist.GetProperty("id").GetInt64();
|
||||||
|
allArtists.Add(artistName);
|
||||||
|
}
|
||||||
|
|
||||||
// Album artist - same as main artist for Tidal tracks
|
// Album artist - same as main artist for Tidal tracks
|
||||||
string? albumArtist = artistName;
|
string? albumArtist = artistName;
|
||||||
@@ -685,6 +721,7 @@ public class SquidWTFMetadataService : IMusicMetadataService
|
|||||||
Title = track.GetProperty("title").GetString() ?? "",
|
Title = track.GetProperty("title").GetString() ?? "",
|
||||||
Artist = artistName,
|
Artist = artistName,
|
||||||
ArtistId = $"ext-squidwtf-artist-{artistIdNum}",
|
ArtistId = $"ext-squidwtf-artist-{artistIdNum}",
|
||||||
|
Artists = allArtists,
|
||||||
Album = albumTitle,
|
Album = albumTitle,
|
||||||
AlbumId = $"ext-squidwtf-album-{albumIdNum}",
|
AlbumId = $"ext-squidwtf-album-{albumIdNum}",
|
||||||
AlbumArtist = albumArtist,
|
AlbumArtist = albumArtist,
|
||||||
|
|||||||
Reference in New Issue
Block a user