update globalize

This commit is contained in:
Luke Pulverenti 2015-08-05 21:21:18 -04:00
parent 7caedd1aee
commit 96346fc88c
9 changed files with 138 additions and 149 deletions

View File

@ -6,7 +6,6 @@ using MediaBrowser.Controller.Net;
using MediaBrowser.Controller.Persistence; using MediaBrowser.Controller.Persistence;
using MediaBrowser.Model.Dto; using MediaBrowser.Model.Dto;
using ServiceStack; using ServiceStack;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -128,44 +127,14 @@ namespace MediaBrowser.Api.UserLibrary
{ {
if (request is GetAlbumArtists) if (request is GetAlbumArtists)
{ {
return items return LibraryManager.GetAlbumArtists(items
.Where(i => !i.IsFolder) .Where(i => !i.IsFolder)
.OfType<IHasAlbumArtist>() .OfType<IHasAlbumArtist>());
.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 items return LibraryManager.GetArtists(items
.Where(i => !i.IsFolder) .Where(i => !i.IsFolder)
.OfType<IHasArtist>() .OfType<IHasArtist>());
.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);
} }
} }
} }

View File

@ -54,6 +54,12 @@ namespace MediaBrowser.Controller.Entities.Audio
get { return AlbumArtists.FirstOrDefault(); } get { return AlbumArtists.FirstOrDefault(); }
} }
[IgnoreDataMember]
public override bool SupportsPeople
{
get { return false; }
}
public List<string> AlbumArtists { get; set; } public List<string> AlbumArtists { get; set; }
/// <summary> /// <summary>

View File

@ -341,95 +341,43 @@ namespace MediaBrowser.Controller.Entities
var items = GetRecursiveChildren(queryParent, user, new[] { CollectionType.Music, CollectionType.MusicVideos }) var items = GetRecursiveChildren(queryParent, user, new[] { CollectionType.Music, CollectionType.MusicVideos })
.Where(i => !i.IsFolder) .Where(i => !i.IsFolder)
.Where(i => i.Genres.Contains(displayParent.Name, StringComparer.OrdinalIgnoreCase)) .Where(i => i.Genres.Contains(displayParent.Name, StringComparer.OrdinalIgnoreCase))
.OfType<IHasAlbumArtist>() .OfType<IHasAlbumArtist>();
.SelectMany(i => i.AlbumArtists)
.DistinctNames()
.Select(i =>
{
try
{
return _libraryManager.GetArtist(i);
}
catch
{
// Already logged at lower levels
return null;
}
})
.Where(i => i != null);
return GetResult(items, queryParent, query); var artists = _libraryManager.GetAlbumArtists(items);
return GetResult(artists, queryParent, query);
} }
private QueryResult<BaseItem> GetMusicAlbumArtists(Folder parent, User user, InternalItemsQuery query) private QueryResult<BaseItem> 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) .Where(i => !i.IsFolder)
.OfType<IHasAlbumArtist>() .OfType<IHasAlbumArtist>();
.SelectMany(i => i.AlbumArtists)
.DistinctNames() var artists = _libraryManager.GetAlbumArtists(items);
.Select(i =>
{
try
{
return _libraryManager.GetArtist(i);
}
catch
{
// Already logged at lower levels
return null;
}
})
.Where(i => i != null);
return GetResult(artists, parent, query); return GetResult(artists, parent, query);
} }
private QueryResult<BaseItem> GetMusicArtists(Folder parent, User user, InternalItemsQuery query) private QueryResult<BaseItem> 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) .Where(i => !i.IsFolder)
.OfType<IHasArtist>() .OfType<IHasArtist>();
.SelectMany(i => i.Artists)
.DistinctNames()
.Select(i =>
{
try
{
return _libraryManager.GetArtist(i);
}
catch
{
// Already logged at lower levels
return null;
}
})
.Where(i => i != null);
var artists = _libraryManager.GetArtists(items);
return GetResult(artists, parent, query); return GetResult(artists, parent, query);
} }
private QueryResult<BaseItem> GetFavoriteArtists(Folder parent, User user, InternalItemsQuery query) private QueryResult<BaseItem> 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) .Where(i => !i.IsFolder)
.OfType<IHasAlbumArtist>() .OfType<IHasAlbumArtist>();
.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);
var artists = _libraryManager.GetAlbumArtists(items).Where(i => _userDataManager.GetUserData(user.Id, i.GetUserDataKey()).IsFavorite);
return GetResult(artists, parent, query); return GetResult(artists, parent, query);
} }

View File

@ -61,7 +61,18 @@ namespace MediaBrowser.Controller.Library
/// <param name="name">The name.</param> /// <param name="name">The name.</param>
/// <returns>Task{Artist}.</returns> /// <returns>Task{Artist}.</returns>
MusicArtist GetArtist(string name); MusicArtist GetArtist(string name);
/// <summary>
/// Gets the album artists.
/// </summary>
/// <param name="items">The items.</param>
/// <returns>IEnumerable&lt;MusicArtist&gt;.</returns>
IEnumerable<MusicArtist> GetAlbumArtists(IEnumerable<IHasAlbumArtist> items);
/// <summary>
/// Gets the artists.
/// </summary>
/// <param name="items">The items.</param>
/// <returns>IEnumerable&lt;MusicArtist&gt;.</returns>
IEnumerable<MusicArtist> GetArtists(IEnumerable<IHasArtist> items);
/// <summary> /// <summary>
/// Gets a Studio /// Gets a Studio
/// </summary> /// </summary>

View File

@ -280,7 +280,7 @@ namespace MediaBrowser.Providers.Music
{ {
// MusicBrainz is extremely adamant about limiting to one request per second // 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(); var doc = new XmlDocument();

View File

@ -939,26 +939,7 @@ namespace MediaBrowser.Server.Implementations.Library
} }
} }
var fileInfo = new DirectoryInfo(path); var item = GetItemById(id) as T;
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;
if (item == null) if (item == null)
{ {
@ -966,8 +947,8 @@ namespace MediaBrowser.Server.Implementations.Library
{ {
Name = name, Name = name,
Id = id, Id = id,
DateCreated = _fileSystem.GetCreationTimeUtc(fileInfo), DateCreated = DateTime.UtcNow,
DateModified = _fileSystem.GetLastWriteTimeUtc(fileInfo), DateModified = DateTime.UtcNow,
Path = path Path = path
}; };
} }
@ -980,6 +961,59 @@ namespace MediaBrowser.Server.Implementations.Library
return item; return item;
} }
public IEnumerable<MusicArtist> GetAlbumArtists(IEnumerable<IHasAlbumArtist> 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<MusicArtist> GetArtists(IEnumerable<IHasArtist> 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<IHasMetadata> items)
{
}
/// <summary> /// <summary>
/// Validate and refresh the People sub-set of the IBN. /// 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. /// 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<PersonInfo> people) public Task UpdatePeople(BaseItem item, List<PersonInfo> people)
{ {
if (!item.SupportsPeople)
{
return Task.FromResult(true);
}
return ItemRepository.UpdatePeople(item.Id, people); return ItemRepository.UpdatePeople(item.Id, people);
} }
} }

View File

@ -48,26 +48,22 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
.Cast<IHasArtist>() .Cast<IHasArtist>()
.ToList(); .ToList();
var allArtists = allSongs.SelectMany(i => i.AllArtists) var allArtists = _libraryManager.GetArtists(allSongs).ToList();
.DistinctNames()
.ToList();
var numComplete = 0; var numComplete = 0;
var numArtists = allArtists.Count; var numArtists = allArtists.Count;
foreach (var artist in allArtists) foreach (var artistItem in allArtists)
{ {
cancellationToken.ThrowIfCancellationRequested(); cancellationToken.ThrowIfCancellationRequested();
try try
{ {
var artistItem = _libraryManager.GetArtist(artist);
await artistItem.RefreshMetadata(cancellationToken).ConfigureAwait(false); await artistItem.RefreshMetadata(cancellationToken).ConfigureAwait(false);
} }
catch (IOException ex) catch (IOException ex)
{ {
_logger.ErrorException("Error validating Artist {0}", ex, artist); _logger.ErrorException("Error validating Artist {0}", ex, artistItem.Name);
} }
// Update progress // Update progress

View File

@ -1398,14 +1398,40 @@ namespace MediaBrowser.Server.Implementations.LiveTv
dto.EpisodeTitle = program.EpisodeTitle; dto.EpisodeTitle = program.EpisodeTitle;
dto.ChannelType = program.ChannelType; dto.ChannelType = program.ChannelType;
dto.Audio = program.Audio; dto.Audio = program.Audio;
dto.IsHD = program.IsHD;
dto.IsMovie = program.IsMovie; if (program.IsHD.HasValue && program.IsHD.Value)
dto.IsSeries = program.IsSeries; {
dto.IsSports = program.IsSports; dto.IsHD = program.IsHD;
dto.IsLive = program.IsLive; }
dto.IsNews = program.IsNews; if (program.IsMovie)
dto.IsKids = program.IsKids; {
dto.IsPremiere = program.IsPremiere; 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; dto.OriginalAirDate = program.OriginalAirDate;
if (channel != null) if (channel != null)

View File

@ -155,12 +155,6 @@ namespace MediaBrowser.Server.Implementations.UserViews
SpecialFolder.MovieMovies, SpecialFolder.MovieMovies,
SpecialFolder.MovieResume, SpecialFolder.MovieResume,
SpecialFolder.GameFavorites,
SpecialFolder.GameGenres,
SpecialFolder.GameSystems,
SpecialFolder.LatestGames,
SpecialFolder.RecentlyPlayedGames,
SpecialFolder.MusicArtists, SpecialFolder.MusicArtists,
SpecialFolder.MusicAlbumArtists, SpecialFolder.MusicAlbumArtists,
SpecialFolder.MusicAlbums, SpecialFolder.MusicAlbums,