コード例 #1
0
        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;
        }
コード例 #2
0
        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);
            }
        }
コード例 #3
0
 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();
 }
コード例 #4
0
        /// <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);
        }
コード例 #5
0
ファイル: MusicManager.cs プロジェクト: paul-777/Emby
        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);
        }
コード例 #6
0
        /// <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);
        }
コード例 #7
0
ファイル: MusicManager.cs プロジェクト: ChubbyArse/Emby
        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);
        }
コード例 #8
0
ファイル: Helpers.cs プロジェクト: jvanhie/Lastfm-Scrobbler
        //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;
        }
コード例 #9
0
        /// <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;
            }
        }
コード例 #10
0
        /// <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);
        }
コード例 #11
0
        /// <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;
        }
コード例 #12
0
        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);
        }