namespace Music; public class SoundCloudDiscoveryProvider : IMusicDiscoveryProvider { public string Id => SoundCloudSupport.DiscoveryProviderId; public string Name => "SoundCloud Charts"; public bool Enabled => SoundCloudSupport.IsDiscoveryEnabled; public Task> GetHomeSectionsAsync(int limit, CancellationToken cancellationToken = default) { return GetHomeSectionsInternalAsync(limit, cancellationToken); } public Task GetSectionAsync(string sectionId, int limit, CancellationToken cancellationToken = default) { return GetSectionInternalAsync(sectionId, limit, cancellationToken); } public Task GetAlbumAsync(string id, CancellationToken cancellationToken = default) { return SoundCloudSupport.GetChartAlbumAsync(id, cancellationToken); } async Task> GetHomeSectionsInternalAsync(int limit, CancellationToken cancellationToken) { var albums = await SoundCloudSupport.GetChartAlbumsAsync(cancellationToken); if (albums.Count == 0) return new List(); return new List { new() { id = SoundCloudSupport.ChartsSectionId, title = "SoundCloud", type = "album", source_provider = Id, has_more = albums.Count > limit, albums = albums.Take(Math.Max(limit, 1)).ToList() } }; } async Task GetSectionInternalAsync(string sectionId, int limit, CancellationToken cancellationToken) { if (!string.Equals(sectionId, SoundCloudSupport.ChartsSectionId, StringComparison.OrdinalIgnoreCase)) return null; var albums = await SoundCloudSupport.GetChartAlbumsAsync(cancellationToken); if (albums.Count == 0) return null; return new MusicBrowseSection { id = SoundCloudSupport.ChartsSectionId, title = "SoundCloud", type = "album", source_provider = Id, has_more = false, albums = albums.ToList() }; } }