Доработано получение плейлистов

This commit is contained in:
FrigaT
2026-04-16 19:10:47 +03:00
parent dec6bc4dd1
commit bb50bcbf22
3 changed files with 35 additions and 17 deletions

View File

@@ -230,23 +230,21 @@ public class YandexMusicService
else if (searchType == TrackSearchType.Album)
{
var album = await client.GetAlbumAsync(id);
if (album != null)
result.Tracks = album?.Volumes.SelectMany(v => v).Select(t => new YandexTrack
{
result.Tracks = album.Volumes.SelectMany(v => v).Select(t => new YandexTrack
TrackId = t.Id,
Title = t.Title,
Artists = t.Artists.Select(t => new YandexArtist()
{
TrackId = t.Id,
Title = t.Title,
Artists = t.Artists.Select(t => new YandexArtist()
{
Id = t.Id,
Name = t.Name,
CoverUrl = t.Cover.GetUrl(),
Description = t.Description?.Text ?? string.Empty,
}).ToList(),
CoverUri = t.CoverUri ?? string.Empty,
DurationMs = t.DurationMs,
}).ToList();
}
Id = t.Id,
Name = t.Name,
CoverUrl = t.Cover.GetUrl(),
Description = t.Description?.Text ?? string.Empty,
}).ToList(),
CoverUri = t.CoverUri ?? string.Empty,
DurationMs = t.DurationMs,
}).ToList();
}
else if (searchType == TrackSearchType.Artist)
@@ -298,6 +296,26 @@ public class YandexMusicService
}
}
else if (searchType == TrackSearchType.Playlist)
{
var playlist = await client.GetPlaylistAsync(id);
result.Tracks = playlist?.Tracks.Select(p => new YandexTrack
{
TrackId = p.Track.Id,
CoverUri = p.Track.CoverUri,
Artists = p.Track.Artists.Select(a => new YandexArtist
{
Id = a.Id,
Name = a.Name,
CoverUrl = a.Cover.GetUrl(),
Description = a.Description?.Text ?? string.Empty,
}).ToList(),
Title = p.Track.Title,
DurationMs = p.Track.DurationMs,
}).ToList();
}
return result;
}
}