public static void ProcessArtistData(MusicArtist artist, LastfmArtist data) { var yearFormed = 0; if (data.bio != null) { Int32.TryParse(data.bio.yearformed, out yearFormed); if (!artist.LockedFields.Contains(MetadataFields.Overview)) { artist.Overview = data.bio.content; } if (!string.IsNullOrEmpty(data.bio.placeformed) && !artist.LockedFields.Contains(MetadataFields.ProductionLocations)) { artist.AddProductionLocation(data.bio.placeformed); } } if (yearFormed > 0) { artist.PremiereDate = new DateTime(yearFormed, 1, 1, 0, 0, 0, DateTimeKind.Utc); artist.ProductionYear = yearFormed; } if (data.tags != null && !artist.LockedFields.Contains(MetadataFields.Tags)) { AddTags(artist, data.tags); } string imageSize; artist.LastFmImageUrl = GetImageUrl(data, out imageSize); artist.LastFmImageSize = imageSize; }
private async Task RefreshArtist(RefreshItem request, MusicArtist item) { var cancellationToken = CancellationToken.None; var albums = _libraryManager.RootFolder .RecursiveChildren .OfType<MusicAlbum>() .Where(i => i.HasArtist(item.Name)) .ToList(); var musicArtists = albums .Select(i => i.Parent) .OfType<MusicArtist>() .ToList(); var options = GetRefreshOptions(request); var musicArtistRefreshTasks = musicArtists.Select(i => i.ValidateChildren(new Progress<double>(), cancellationToken, options, true)); await Task.WhenAll(musicArtistRefreshTasks).ConfigureAwait(false); try { await item.RefreshMetadata(options, CancellationToken.None).ConfigureAwait(false); } catch (Exception ex) { Logger.ErrorException("Error refreshing library", ex); } }
public static void ProcessArtistData(MusicArtist source, Artist target) { target.PremiereDate = source.PremiereDate; target.ProductionYear = source.ProductionYear; target.Tags = source.Tags.ToList(); target.Overview = source.Overview; target.ProductionLocations = source.ProductionLocations.ToList(); }
/// <summary> /// Gets the user data key. /// </summary> /// <param name="item">The item.</param> /// <returns>System.String.</returns> private static string GetUserDataKey(MusicArtist item) { var id = item.GetProviderId(MetadataProviders.MusicBrainzArtist); if (!string.IsNullOrEmpty(id)) { return("Artist-Musicbrainz-" + id); } return("Artist-" + item.Name); }
public IEnumerable<Audio> GetInstantMixFromArtist(MusicArtist artist, User user) { var genres = user.RootFolder .GetRecursiveChildren(user, i => i is Audio) .Cast<Audio>() .Where(i => i.HasAnyArtist(artist.Name)) .SelectMany(i => i.Genres) .Concat(artist.Genres) .Distinct(StringComparer.OrdinalIgnoreCase); return GetInstantMixFromGenres(genres, user); }
/// <summary> /// Gets the user data key. /// </summary> /// <param name="item">The item.</param> /// <returns>System.String.</returns> private static List <string> GetUserDataKeys(MusicArtist item) { var list = new List <string>(); var id = item.GetProviderId(MetadataProviders.MusicBrainzArtist); if (!string.IsNullOrEmpty(id)) { list.Add("Artist-Musicbrainz-" + id); } list.Add("Artist-" + (item.Name ?? string.Empty).RemoveDiacritics()); return(list); }
public IEnumerable<Audio> GetInstantMixFromArtist(MusicArtist artist, User user) { var genres = user.RootFolder .GetRecursiveChildren(user, new InternalItemsQuery(user) { IncludeItemTypes = new[] { typeof(Audio).Name } }) .Cast<Audio>() .Where(i => i.HasAnyArtist(artist.Name)) .SelectMany(i => i.Genres) .Concat(artist.Genres) .Distinct(StringComparer.OrdinalIgnoreCase); return GetInstantMixFromGenres(genres, user); }
//The nuget doesn't seem to have GetProviderId for artists public static string GetMusicBrainzArtistId(MusicArtist artist) { string mbArtistId; if (artist.ProviderIds == null) { Plugin.Logger.Debug("No provider id: {0}", artist.Name); return null; } if (artist.ProviderIds.TryGetValue("MusicBrainzArtist", out mbArtistId)) return mbArtistId; Plugin.Logger.Debug("No MBID: {0}", artist.Name); return null; }
/// <summary> /// Sets the item counts. /// </summary> /// <param name="artist">The artist.</param> /// <param name="userId">The user id.</param> /// <param name="allItems">All items.</param> private void SetItemCounts(MusicArtist artist, Guid? userId, IEnumerable<IHasArtist> allItems) { var name = artist.Name; var items = allItems .Where(i => i.HasArtist(name)) .ToList(); var counts = new ItemByNameCounts { TotalCount = items.Count, SongCount = items.OfType<Audio>().Count(), AlbumCount = items.OfType<MusicAlbum>().Count(), MusicVideoCount = items.OfType<MusicVideo>().Count() }; if (userId.HasValue) { artist.UserItemCounts[userId.Value] = counts; } }
/// <summary> /// Gets the data. /// </summary> /// <param name="artist">The artist.</param> /// <returns>Guid.</returns> private Guid GetComparisonData(MusicArtist artist) { var songs = artist.RecursiveChildren.OfType<Audio>().ToList(); return GetComparisonData(songs); }
/// <summary> /// Gets the user data key. /// </summary> /// <param name="item">The item.</param> /// <returns>System.String.</returns> private static string GetUserDataKey(MusicArtist item) { var id = item.GetProviderId(MetadataProviders.Musicbrainz); if (!string.IsNullOrEmpty(id)) { return "Artist-Musicbrainz-" + id; } return "Artist-" + item.Name; }
public async Task<GetTracksResponse> GetTracks(LastfmUser user, MusicArtist artist, CancellationToken cancellationToken) { var request = new GetTracksRequest { User = user.Username, Artist = artist.Name, ApiKey = Strings.Keys.LastfmApiKey, Method = Strings.Methods.GetTracks, Limit = 1000 }; return await Get<GetTracksRequest, GetTracksResponse>(request, cancellationToken); }