updated nuget

This commit is contained in:
Luke Pulverenti 2013-10-20 23:01:22 -04:00
parent 14d8f48f31
commit 9456886848
12 changed files with 142 additions and 126 deletions

View File

@ -82,13 +82,16 @@ namespace MediaBrowser.Api.DefaultTheme
{
var user = _userManager.GetUserById(request.UserId);
var allItems = user.RootFolder.GetRecursiveChildren(user, i => _userDataManager.GetUserData(user.Id, i.GetUserDataKey()).IsFavorite)
var allItems = user.RootFolder.GetRecursiveChildren(user)
.ToList();
var itemsWithImages = allItems.Where(i => !string.IsNullOrEmpty(i.PrimaryImagePath))
var allFavoriteItems = allItems.Where(i => _userDataManager.GetUserData(user.Id, i.GetUserDataKey()).IsFavorite)
.ToList();
var itemsWithBackdrops = allItems.Where(i => i.BackdropImagePaths.Count > 0)
var itemsWithImages = allFavoriteItems.Where(i => !string.IsNullOrEmpty(i.PrimaryImagePath))
.ToList();
var itemsWithBackdrops = allFavoriteItems.Where(i => i.BackdropImagePaths.Count > 0)
.ToList();
var view = new FavoritesView();
@ -157,13 +160,6 @@ namespace MediaBrowser.Api.DefaultTheme
.Select(i => _dtoService.GetBaseItemDto(i, fields, user))
.ToList();
view.Artists = itemsWithImages
.OfType<MusicArtist>()
.OrderBy(i => Guid.NewGuid())
.Take(4)
.Select(i => _dtoService.GetBaseItemDto(i, fields, user))
.ToList();
view.MiniSpotlights = itemsWithBackdrops
.Except(spotlightItems)
.OrderBy(i => Guid.NewGuid())
@ -171,6 +167,40 @@ namespace MediaBrowser.Api.DefaultTheme
.Select(i => _dtoService.GetBaseItemDto(i, fields, user))
.ToList();
var artists = allItems.OfType<Audio>()
.SelectMany(i =>
{
var list = new List<string>();
if (!string.IsNullOrEmpty(i.AlbumArtist))
{
list.Add(i.AlbumArtist);
}
list.AddRange(i.Artists);
return list;
})
.Distinct(StringComparer.OrdinalIgnoreCase)
.OrderBy(i => Guid.NewGuid())
.Select(i =>
{
try
{
return _libraryManager.GetArtist(i);
}
catch
{
return null;
}
})
.Where(i => i != null && _userDataManager.GetUserData(user.Id, i.GetUserDataKey()).IsFavorite)
.Take(4)
.ToList();
view.Artists = artists
.Select(i => _dtoService.GetBaseItemDto(i, fields, user))
.ToList();
return ToOptimizedResult(view);
}

View File

@ -156,6 +156,9 @@ namespace MediaBrowser.Api
{
[ApiMember(Name = "UserId", Description = "Optional. Get counts from a specific user's library.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
public Guid? UserId { get; set; }
[ApiMember(Name = "IsFavorite", Description = "Optional. Get counts of favorite items", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]
public bool? IsFavorite { get; set; }
}
[Route("/Items/{Id}/Ancestors", "GET")]
@ -334,27 +337,29 @@ namespace MediaBrowser.Api
{
var items = GetAllLibraryItems(request.UserId, _userManager, _libraryManager).ToList();
var albums = items.OfType<MusicAlbum>().ToList();
var episodes = items.OfType<Episode>().ToList();
var games = items.OfType<Game>().ToList();
var movies = items.OfType<Movie>().ToList();
var musicVideos = items.OfType<MusicVideo>().ToList();
var adultVideos = items.OfType<AdultVideo>().ToList();
var boxsets = items.OfType<BoxSet>().ToList();
var books = items.OfType<Book>().ToList();
var songs = items.OfType<Audio>().ToList();
var series = items.OfType<Series>().ToList();
var filteredItems = request.UserId.HasValue ? FilterItems(items, request, request.UserId.Value).ToList() : items;
var albums = filteredItems.OfType<MusicAlbum>().ToList();
var episodes = filteredItems.OfType<Episode>().ToList();
var games = filteredItems.OfType<Game>().ToList();
var movies = filteredItems.OfType<Movie>().ToList();
var musicVideos = filteredItems.OfType<MusicVideo>().ToList();
var adultVideos = filteredItems.OfType<AdultVideo>().ToList();
var boxsets = filteredItems.OfType<BoxSet>().ToList();
var books = filteredItems.OfType<Book>().ToList();
var songs = filteredItems.OfType<Audio>().ToList();
var series = filteredItems.OfType<Series>().ToList();
var counts = new ItemCounts
{
AlbumCount = albums.Count,
EpisodeCount = episodes.Count,
GameCount = games.Count,
GameSystemCount = items.OfType<GameSystem>().Count(),
GameSystemCount = filteredItems.OfType<GameSystem>().Count(),
MovieCount = movies.Count,
SeriesCount = series.Count,
SongCount = songs.Count,
TrailerCount = items.OfType<Trailer>().Count(),
TrailerCount = filteredItems.OfType<Trailer>().Count(),
MusicVideoCount = musicVideos.Count,
AdultVideoCount = adultVideos.Count,
BoxSetCount = boxsets.Count,
@ -363,50 +368,38 @@ namespace MediaBrowser.Api
UniqueTypes = items.Select(i => i.GetType().Name).Distinct().ToList()
};
if (request.UserId.HasValue)
var people = items.SelectMany(i => i.People)
.Select(i => i.Name)
.Distinct(StringComparer.OrdinalIgnoreCase)
.Select(i =>
{
try
{
return _libraryManager.GetPerson(i);
}
catch
{
return null;
}
})
.Where(i => i != null)
.ToList();
people = request.UserId.HasValue ? FilterItems(people, request, request.UserId.Value).ToList() : people;
counts.PersonCount = people.Count;
var artists = items.OfType<Audio>().SelectMany(i =>
{
counts.FavoriteAlbumCount = FavoriteCount(albums, request.UserId.Value);
counts.FavoriteEpisodeCount = FavoriteCount(episodes, request.UserId.Value);
counts.FavoriteGameCount = FavoriteCount(games, request.UserId.Value);
counts.FavoriteMovieCount = FavoriteCount(movies, request.UserId.Value);
counts.FavoriteMusicVideoCount = FavoriteCount(musicVideos, request.UserId.Value);
counts.FavoriteAdultVideoCount = FavoriteCount(adultVideos, request.UserId.Value);
counts.FavoriteBoxSetCount = FavoriteCount(boxsets, request.UserId.Value);
counts.FavoriteBookCount = FavoriteCount(books, request.UserId.Value);
counts.FavoriteSongCount = FavoriteCount(songs, request.UserId.Value);
counts.FavoriteSeriesCount = FavoriteCount(series, request.UserId.Value);
var list = new List<string>();
var people = items.SelectMany(i => i.People)
.Select(i => i.Name)
.Distinct(StringComparer.OrdinalIgnoreCase)
.Select(i =>
{
try
{
return _libraryManager.GetPerson(i);
}
catch
{
return null;
}
})
.Where(i => i != null)
.ToList();
counts.FavoritePersonCount = FavoriteCount(people, request.UserId.Value);
var artists = songs.SelectMany(i =>
if (!string.IsNullOrEmpty(i.AlbumArtist))
{
var list = new List<string>();
list.Add(i.AlbumArtist);
}
list.AddRange(i.Artists);
if (!string.IsNullOrEmpty(i.AlbumArtist))
{
list.Add(i.AlbumArtist);
}
list.AddRange(i.Artists);
return list;
})
return list;
})
.Distinct(StringComparer.OrdinalIgnoreCase)
.Select(i =>
{
@ -419,18 +412,31 @@ namespace MediaBrowser.Api
return null;
}
})
.Where(i => i != null)
.ToList();
.Where(i => i != null)
.ToList();
counts.FavoriteArtistCount = FavoriteCount(artists, request.UserId.Value);
}
artists = request.UserId.HasValue ? FilterItems(artists, request, request.UserId.Value).ToList() : artists;
counts.ArtistCount = artists.Count;
return ToOptimizedResult(counts);
}
private IEnumerable<T> FilterItems<T>(IEnumerable<T> items, GetItemCounts request, Guid userId)
where T : BaseItem
{
if (request.IsFavorite.HasValue)
{
var val = request.IsFavorite.Value;
items = items.Where(i => _userDataManager.GetUserData(userId, i.GetUserDataKey()).IsFavorite == val);
}
return items;
}
private int FavoriteCount(IEnumerable<BaseItem> items, Guid userId)
{
return items.Count(i => _userDataManager.GetUserData(userId, i.GetUserDataKey()).IsFavorite);
return items.AsParallel().Count(i => _userDataManager.GetUserData(userId, i.GetUserDataKey()).IsFavorite);
}
/// <summary>

View File

@ -200,7 +200,7 @@ namespace MediaBrowser.Api.UserLibrary
{
var userdata = UserDataRepository.GetUserData(user.Id, i.GetUserDataKey());
return userdata != null && userdata.Likes.HasValue && userdata.IsFavorite;
return userdata != null && userdata.IsFavorite;
});
}

View File

@ -290,6 +290,9 @@
<Compile Include="..\MediaBrowser.Model\Querying\ArtistsQuery.cs">
<Link>Querying\ArtistsQuery.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\Querying\ItemCountsQuery.cs">
<Link>Querying\ItemCountsQuery.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\Querying\ItemFields.cs">
<Link>Querying\ItemFields.cs</Link>
</Compile>

View File

@ -277,6 +277,9 @@
<Compile Include="..\MediaBrowser.Model\Querying\ArtistsQuery.cs">
<Link>Querying\ArtistsQuery.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\Querying\ItemCountsQuery.cs">
<Link>Querying\ItemCountsQuery.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\Querying\ItemFields.cs">
<Link>Querying\ItemFields.cs</Link>
</Compile>

View File

@ -221,9 +221,9 @@ namespace MediaBrowser.Model.ApiClient
/// <summary>
/// Gets the item counts async.
/// </summary>
/// <param name="userId">The user id.</param>
/// <param name="query">The query.</param>
/// <returns>Task{ItemCounts}.</returns>
Task<ItemCounts> GetItemCountsAsync(string userId);
Task<ItemCounts> GetItemCountsAsync(ItemCountsQuery query);
/// <summary>
/// Queries for items

View File

@ -1,5 +1,4 @@

using System.Collections.Generic;
using System.Collections.Generic;
namespace MediaBrowser.Model.Dto
{
@ -70,55 +69,8 @@ namespace MediaBrowser.Model.Dto
/// <value>The unique types.</value>
public List<string> UniqueTypes { get; set; }
public int FavoriteAdultVideoCount { get; set; }
/// <summary>
/// Gets or sets the movie count.
/// </summary>
/// <value>The movie count.</value>
public int FavoriteMovieCount { get; set; }
/// <summary>
/// Gets or sets the series count.
/// </summary>
/// <value>The series count.</value>
public int FavoriteSeriesCount { get; set; }
/// <summary>
/// Gets or sets the episode count.
/// </summary>
/// <value>The episode count.</value>
public int FavoriteEpisodeCount { get; set; }
/// <summary>
/// Gets or sets the game count.
/// </summary>
/// <value>The game count.</value>
public int FavoriteGameCount { get; set; }
/// <summary>
/// Gets or sets the song count.
/// </summary>
/// <value>The song count.</value>
public int FavoriteSongCount { get; set; }
/// <summary>
/// Gets or sets the album count.
/// </summary>
/// <value>The album count.</value>
public int FavoriteAlbumCount { get; set; }
/// <summary>
/// Gets or sets the music video count.
/// </summary>
/// <value>The music video count.</value>
public int FavoriteMusicVideoCount { get; set; }
/// <summary>
/// Gets or sets the box set count.
/// </summary>
/// <value>The box set count.</value>
public int FavoriteBoxSetCount { get; set; }
/// <summary>
/// Gets or sets the book count.
/// </summary>
/// <value>The book count.</value>
public int FavoriteBookCount { get; set; }
public int FavoritePersonCount { get; set; }
public int FavoriteArtistCount { get; set; }
public int PersonCount { get; set; }
public int ArtistCount { get; set; }
public ItemCounts()
{

View File

@ -82,6 +82,7 @@
<Compile Include="Notifications\NotificationResult.cs" />
<Compile Include="Notifications\NotificationsSummary.cs" />
<Compile Include="Querying\ArtistsQuery.cs" />
<Compile Include="Querying\ItemCountsQuery.cs" />
<Compile Include="Querying\ItemReviewsResult.cs" />
<Compile Include="Querying\ItemsByNameQuery.cs" />
<Compile Include="Entities\BaseItemInfo.cs" />

View File

@ -0,0 +1,21 @@

namespace MediaBrowser.Model.Querying
{
/// <summary>
/// Class ItemCountsQuery
/// </summary>
public class ItemCountsQuery
{
/// <summary>
/// Gets or sets the user id.
/// </summary>
/// <value>The user id.</value>
public string UserId { get; set; }
/// <summary>
/// Gets or sets a value indicating whether this instance is favorite.
/// </summary>
/// <value><c>null</c> if [is favorite] contains no value, <c>true</c> if [is favorite]; otherwise, <c>false</c>.</value>
public bool? IsFavorite { get; set; }
}
}

View File

@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>MediaBrowser.Common.Internal</id>
<version>3.0.229</version>
<version>3.0.230</version>
<title>MediaBrowser.Common.Internal</title>
<authors>Luke</authors>
<owners>ebr,Luke,scottisafool</owners>
@ -12,7 +12,7 @@
<description>Contains common components shared by Media Browser Theater and Media Browser Server. Not intended for plugin developer consumption.</description>
<copyright>Copyright © Media Browser 2013</copyright>
<dependencies>
<dependency id="MediaBrowser.Common" version="3.0.229" />
<dependency id="MediaBrowser.Common" version="3.0.230" />
<dependency id="NLog" version="2.1.0" />
<dependency id="ServiceStack.Text" version="3.9.58" />
<dependency id="SimpleInjector" version="2.3.2" />

View File

@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>MediaBrowser.Common</id>
<version>3.0.229</version>
<version>3.0.230</version>
<title>MediaBrowser.Common</title>
<authors>Media Browser Team</authors>
<owners>ebr,Luke,scottisafool</owners>

View File

@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>MediaBrowser.Server.Core</id>
<version>3.0.229</version>
<version>3.0.230</version>
<title>Media Browser.Server.Core</title>
<authors>Media Browser Team</authors>
<owners>ebr,Luke,scottisafool</owners>
@ -12,7 +12,7 @@
<description>Contains core components required to build plugins for Media Browser Server.</description>
<copyright>Copyright © Media Browser 2013</copyright>
<dependencies>
<dependency id="MediaBrowser.Common" version="3.0.229" />
<dependency id="MediaBrowser.Common" version="3.0.230" />
</dependencies>
</metadata>
<files>