diff --git a/MediaBrowser.Api/UserLibrary/ArtistsService.cs b/MediaBrowser.Api/UserLibrary/ArtistsService.cs index 2393d0533..f027fe9df 100644 --- a/MediaBrowser.Api/UserLibrary/ArtistsService.cs +++ b/MediaBrowser.Api/UserLibrary/ArtistsService.cs @@ -6,7 +6,6 @@ using MediaBrowser.Controller.Net; using MediaBrowser.Controller.Persistence; using MediaBrowser.Model.Dto; using ServiceStack; -using System; using System.Collections.Generic; using System.Linq; @@ -128,44 +127,14 @@ namespace MediaBrowser.Api.UserLibrary { if (request is GetAlbumArtists) { - return items - .Where(i => !i.IsFolder) - .OfType() - .SelectMany(i => i.AlbumArtists) - .DistinctNames() - .Select(name => - { - try - { - return LibraryManager.GetArtist(name); - } - catch (Exception ex) - { - Logger.ErrorException("Error getting artist {0}", ex, name); - return null; - } - - }).Where(i => i != null); + return LibraryManager.GetAlbumArtists(items + .Where(i => !i.IsFolder) + .OfType()); } - return items + return LibraryManager.GetArtists(items .Where(i => !i.IsFolder) - .OfType() - .SelectMany(i => i.AllArtists) - .DistinctNames() - .Select(name => - { - try - { - return LibraryManager.GetArtist(name); - } - catch (Exception ex) - { - Logger.ErrorException("Error getting artist {0}", ex, name); - return null; - } - - }).Where(i => i != null); + .OfType()); } } } diff --git a/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs b/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs index 8a77d7616..807beee52 100644 --- a/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs +++ b/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs @@ -54,6 +54,12 @@ namespace MediaBrowser.Controller.Entities.Audio get { return AlbumArtists.FirstOrDefault(); } } + [IgnoreDataMember] + public override bool SupportsPeople + { + get { return false; } + } + public List AlbumArtists { get; set; } /// diff --git a/MediaBrowser.Controller/Entities/UserViewBuilder.cs b/MediaBrowser.Controller/Entities/UserViewBuilder.cs index 462f66e20..ba2820bc1 100644 --- a/MediaBrowser.Controller/Entities/UserViewBuilder.cs +++ b/MediaBrowser.Controller/Entities/UserViewBuilder.cs @@ -341,95 +341,43 @@ namespace MediaBrowser.Controller.Entities var items = GetRecursiveChildren(queryParent, user, new[] { CollectionType.Music, CollectionType.MusicVideos }) .Where(i => !i.IsFolder) .Where(i => i.Genres.Contains(displayParent.Name, StringComparer.OrdinalIgnoreCase)) - .OfType() - .SelectMany(i => i.AlbumArtists) - .DistinctNames() - .Select(i => - { - try - { - return _libraryManager.GetArtist(i); - } - catch - { - // Already logged at lower levels - return null; - } - }) - .Where(i => i != null); + .OfType(); - return GetResult(items, queryParent, query); + var artists = _libraryManager.GetAlbumArtists(items); + + return GetResult(artists, queryParent, query); } private QueryResult GetMusicAlbumArtists(Folder parent, User user, InternalItemsQuery query) { - var artists = GetRecursiveChildren(parent, user, new[] { CollectionType.Music, CollectionType.MusicVideos }) + var items = GetRecursiveChildren(parent, user, new[] { CollectionType.Music, CollectionType.MusicVideos }) .Where(i => !i.IsFolder) - .OfType() - .SelectMany(i => i.AlbumArtists) - .DistinctNames() - .Select(i => - { - try - { - return _libraryManager.GetArtist(i); - } - catch - { - // Already logged at lower levels - return null; - } - }) - .Where(i => i != null); + .OfType(); + + var artists = _libraryManager.GetAlbumArtists(items); return GetResult(artists, parent, query); } private QueryResult GetMusicArtists(Folder parent, User user, InternalItemsQuery query) { - var artists = GetRecursiveChildren(parent, user, new[] { CollectionType.Music, CollectionType.MusicVideos }) + var items = GetRecursiveChildren(parent, user, new[] { CollectionType.Music, CollectionType.MusicVideos }) .Where(i => !i.IsFolder) - .OfType() - .SelectMany(i => i.Artists) - .DistinctNames() - .Select(i => - { - try - { - return _libraryManager.GetArtist(i); - } - catch - { - // Already logged at lower levels - return null; - } - }) - .Where(i => i != null); + .OfType(); + var artists = _libraryManager.GetArtists(items); + return GetResult(artists, parent, query); } private QueryResult GetFavoriteArtists(Folder parent, User user, InternalItemsQuery query) { - var artists = GetRecursiveChildren(parent, user, new[] { CollectionType.Music, CollectionType.MusicVideos }) + var items = GetRecursiveChildren(parent, user, new[] { CollectionType.Music, CollectionType.MusicVideos }) .Where(i => !i.IsFolder) - .OfType() - .SelectMany(i => i.AlbumArtists) - .DistinctNames() - .Select(i => - { - try - { - return _libraryManager.GetArtist(i); - } - catch - { - // Already logged at lower levels - return null; - } - }) - .Where(i => i != null && _userDataManager.GetUserData(user.Id, i.GetUserDataKey()).IsFavorite); + .OfType(); + var artists = _libraryManager.GetAlbumArtists(items).Where(i => _userDataManager.GetUserData(user.Id, i.GetUserDataKey()).IsFavorite); + return GetResult(artists, parent, query); } diff --git a/MediaBrowser.Controller/Library/ILibraryManager.cs b/MediaBrowser.Controller/Library/ILibraryManager.cs index 77c07dfd4..9c52fd2dc 100644 --- a/MediaBrowser.Controller/Library/ILibraryManager.cs +++ b/MediaBrowser.Controller/Library/ILibraryManager.cs @@ -61,7 +61,18 @@ namespace MediaBrowser.Controller.Library /// The name. /// Task{Artist}. MusicArtist GetArtist(string name); - + /// + /// Gets the album artists. + /// + /// The items. + /// IEnumerable<MusicArtist>. + IEnumerable GetAlbumArtists(IEnumerable items); + /// + /// Gets the artists. + /// + /// The items. + /// IEnumerable<MusicArtist>. + IEnumerable GetArtists(IEnumerable items); /// /// Gets a Studio /// diff --git a/MediaBrowser.Providers/Music/MusicBrainzAlbumProvider.cs b/MediaBrowser.Providers/Music/MusicBrainzAlbumProvider.cs index 664eff004..6748c2ba5 100644 --- a/MediaBrowser.Providers/Music/MusicBrainzAlbumProvider.cs +++ b/MediaBrowser.Providers/Music/MusicBrainzAlbumProvider.cs @@ -280,7 +280,7 @@ namespace MediaBrowser.Providers.Music { // MusicBrainz is extremely adamant about limiting to one request per second - await Task.Delay(800, cancellationToken).ConfigureAwait(false); + await Task.Delay(1000, cancellationToken).ConfigureAwait(false); var doc = new XmlDocument(); diff --git a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs index e89c83397..c9a5cb731 100644 --- a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs +++ b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs @@ -939,26 +939,7 @@ namespace MediaBrowser.Server.Implementations.Library } } - var fileInfo = new DirectoryInfo(path); - - var isNew = false; - - if (!fileInfo.Exists) - { - try - { - fileInfo = Directory.CreateDirectory(path); - } - catch (UnauthorizedAccessException ex) - { - _logger.Error("Error creating directory {0}", ex, path); - throw new Exception(string.Format("Error creating directory {0}", path), ex); - } - - isNew = true; - } - - var item = isNew ? null : GetItemById(id) as T; + var item = GetItemById(id) as T; if (item == null) { @@ -966,8 +947,8 @@ namespace MediaBrowser.Server.Implementations.Library { Name = name, Id = id, - DateCreated = _fileSystem.GetCreationTimeUtc(fileInfo), - DateModified = _fileSystem.GetLastWriteTimeUtc(fileInfo), + DateCreated = DateTime.UtcNow, + DateModified = DateTime.UtcNow, Path = path }; } @@ -980,6 +961,59 @@ namespace MediaBrowser.Server.Implementations.Library return item; } + public IEnumerable GetAlbumArtists(IEnumerable items) + { + var names = items + .SelectMany(i => i.AlbumArtists) + .DistinctNames() + .Select(i => + { + try + { + var artist = GetArtist(i); + + return artist; + } + catch + { + // Already logged at lower levels + return null; + } + }) + .Where(i => i != null); + + return names; + } + + public IEnumerable GetArtists(IEnumerable items) + { + var names = items + .SelectMany(i => i.AllArtists) + .DistinctNames() + .Select(i => + { + try + { + var artist = GetArtist(i); + + return artist; + } + catch + { + // Already logged at lower levels + return null; + } + }) + .Where(i => i != null); + + return names; + } + + private void SetPropertiesFromSongs(MusicArtist artist, IEnumerable items) + { + + } + /// /// Validate and refresh the People sub-set of the IBN. /// The items are stored in the db but not loaded into memory until actually requested by an operation. @@ -2118,6 +2152,11 @@ namespace MediaBrowser.Server.Implementations.Library public Task UpdatePeople(BaseItem item, List people) { + if (!item.SupportsPeople) + { + return Task.FromResult(true); + } + return ItemRepository.UpdatePeople(item.Id, people); } } diff --git a/MediaBrowser.Server.Implementations/Library/Validators/ArtistsValidator.cs b/MediaBrowser.Server.Implementations/Library/Validators/ArtistsValidator.cs index c9440bb27..68d351b44 100644 --- a/MediaBrowser.Server.Implementations/Library/Validators/ArtistsValidator.cs +++ b/MediaBrowser.Server.Implementations/Library/Validators/ArtistsValidator.cs @@ -48,26 +48,22 @@ namespace MediaBrowser.Server.Implementations.Library.Validators .Cast() .ToList(); - var allArtists = allSongs.SelectMany(i => i.AllArtists) - .DistinctNames() - .ToList(); + var allArtists = _libraryManager.GetArtists(allSongs).ToList(); var numComplete = 0; var numArtists = allArtists.Count; - foreach (var artist in allArtists) + foreach (var artistItem in allArtists) { cancellationToken.ThrowIfCancellationRequested(); try { - var artistItem = _libraryManager.GetArtist(artist); - await artistItem.RefreshMetadata(cancellationToken).ConfigureAwait(false); } catch (IOException ex) { - _logger.ErrorException("Error validating Artist {0}", ex, artist); + _logger.ErrorException("Error validating Artist {0}", ex, artistItem.Name); } // Update progress diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs index 6861901ac..aa883ce75 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs @@ -1398,14 +1398,40 @@ namespace MediaBrowser.Server.Implementations.LiveTv dto.EpisodeTitle = program.EpisodeTitle; dto.ChannelType = program.ChannelType; dto.Audio = program.Audio; - dto.IsHD = program.IsHD; - dto.IsMovie = program.IsMovie; - dto.IsSeries = program.IsSeries; - dto.IsSports = program.IsSports; - dto.IsLive = program.IsLive; - dto.IsNews = program.IsNews; - dto.IsKids = program.IsKids; - dto.IsPremiere = program.IsPremiere; + + if (program.IsHD.HasValue && program.IsHD.Value) + { + dto.IsHD = program.IsHD; + } + if (program.IsMovie) + { + dto.IsMovie = program.IsMovie; + } + if (program.IsSeries) + { + dto.IsSeries = program.IsSeries; + } + if (program.IsSports) + { + dto.IsSports = program.IsSports; + } + if (program.IsLive) + { + dto.IsLive = program.IsLive; + } + if (program.IsNews) + { + dto.IsNews = program.IsNews; + } + if (program.IsKids) + { + dto.IsKids = program.IsKids; + } + if (program.IsPremiere) + { + dto.IsPremiere = program.IsPremiere; + } + dto.OriginalAirDate = program.OriginalAirDate; if (channel != null) diff --git a/MediaBrowser.Server.Implementations/UserViews/DynamicImageProvider.cs b/MediaBrowser.Server.Implementations/UserViews/DynamicImageProvider.cs index 0162b8802..ca2568a0f 100644 --- a/MediaBrowser.Server.Implementations/UserViews/DynamicImageProvider.cs +++ b/MediaBrowser.Server.Implementations/UserViews/DynamicImageProvider.cs @@ -155,12 +155,6 @@ namespace MediaBrowser.Server.Implementations.UserViews SpecialFolder.MovieMovies, SpecialFolder.MovieResume, - SpecialFolder.GameFavorites, - SpecialFolder.GameGenres, - SpecialFolder.GameSystems, - SpecialFolder.LatestGames, - SpecialFolder.RecentlyPlayedGames, - SpecialFolder.MusicArtists, SpecialFolder.MusicAlbumArtists, SpecialFolder.MusicAlbums,