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 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(); .ToList();
var itemsWithImages = allItems.Where(i => !string.IsNullOrEmpty(i.PrimaryImagePath)) var allFavoriteItems = allItems.Where(i => _userDataManager.GetUserData(user.Id, i.GetUserDataKey()).IsFavorite)
.ToList(); .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(); .ToList();
var view = new FavoritesView(); var view = new FavoritesView();
@ -157,13 +160,6 @@ namespace MediaBrowser.Api.DefaultTheme
.Select(i => _dtoService.GetBaseItemDto(i, fields, user)) .Select(i => _dtoService.GetBaseItemDto(i, fields, user))
.ToList(); .ToList();
view.Artists = itemsWithImages
.OfType<MusicArtist>()
.OrderBy(i => Guid.NewGuid())
.Take(4)
.Select(i => _dtoService.GetBaseItemDto(i, fields, user))
.ToList();
view.MiniSpotlights = itemsWithBackdrops view.MiniSpotlights = itemsWithBackdrops
.Except(spotlightItems) .Except(spotlightItems)
.OrderBy(i => Guid.NewGuid()) .OrderBy(i => Guid.NewGuid())
@ -171,6 +167,40 @@ namespace MediaBrowser.Api.DefaultTheme
.Select(i => _dtoService.GetBaseItemDto(i, fields, user)) .Select(i => _dtoService.GetBaseItemDto(i, fields, user))
.ToList(); .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); 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")] [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; } 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")] [Route("/Items/{Id}/Ancestors", "GET")]
@ -334,27 +337,29 @@ namespace MediaBrowser.Api
{ {
var items = GetAllLibraryItems(request.UserId, _userManager, _libraryManager).ToList(); var items = GetAllLibraryItems(request.UserId, _userManager, _libraryManager).ToList();
var albums = items.OfType<MusicAlbum>().ToList(); var filteredItems = request.UserId.HasValue ? FilterItems(items, request, request.UserId.Value).ToList() : items;
var episodes = items.OfType<Episode>().ToList();
var games = items.OfType<Game>().ToList(); var albums = filteredItems.OfType<MusicAlbum>().ToList();
var movies = items.OfType<Movie>().ToList(); var episodes = filteredItems.OfType<Episode>().ToList();
var musicVideos = items.OfType<MusicVideo>().ToList(); var games = filteredItems.OfType<Game>().ToList();
var adultVideos = items.OfType<AdultVideo>().ToList(); var movies = filteredItems.OfType<Movie>().ToList();
var boxsets = items.OfType<BoxSet>().ToList(); var musicVideos = filteredItems.OfType<MusicVideo>().ToList();
var books = items.OfType<Book>().ToList(); var adultVideos = filteredItems.OfType<AdultVideo>().ToList();
var songs = items.OfType<Audio>().ToList(); var boxsets = filteredItems.OfType<BoxSet>().ToList();
var series = items.OfType<Series>().ToList(); var books = filteredItems.OfType<Book>().ToList();
var songs = filteredItems.OfType<Audio>().ToList();
var series = filteredItems.OfType<Series>().ToList();
var counts = new ItemCounts var counts = new ItemCounts
{ {
AlbumCount = albums.Count, AlbumCount = albums.Count,
EpisodeCount = episodes.Count, EpisodeCount = episodes.Count,
GameCount = games.Count, GameCount = games.Count,
GameSystemCount = items.OfType<GameSystem>().Count(), GameSystemCount = filteredItems.OfType<GameSystem>().Count(),
MovieCount = movies.Count, MovieCount = movies.Count,
SeriesCount = series.Count, SeriesCount = series.Count,
SongCount = songs.Count, SongCount = songs.Count,
TrailerCount = items.OfType<Trailer>().Count(), TrailerCount = filteredItems.OfType<Trailer>().Count(),
MusicVideoCount = musicVideos.Count, MusicVideoCount = musicVideos.Count,
AdultVideoCount = adultVideos.Count, AdultVideoCount = adultVideos.Count,
BoxSetCount = boxsets.Count, BoxSetCount = boxsets.Count,
@ -363,19 +368,6 @@ namespace MediaBrowser.Api
UniqueTypes = items.Select(i => i.GetType().Name).Distinct().ToList() UniqueTypes = items.Select(i => i.GetType().Name).Distinct().ToList()
}; };
if (request.UserId.HasValue)
{
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 people = items.SelectMany(i => i.People) var people = items.SelectMany(i => i.People)
.Select(i => i.Name) .Select(i => i.Name)
.Distinct(StringComparer.OrdinalIgnoreCase) .Distinct(StringComparer.OrdinalIgnoreCase)
@ -393,9 +385,10 @@ namespace MediaBrowser.Api
.Where(i => i != null) .Where(i => i != null)
.ToList(); .ToList();
counts.FavoritePersonCount = FavoriteCount(people, request.UserId.Value); people = request.UserId.HasValue ? FilterItems(people, request, request.UserId.Value).ToList() : people;
counts.PersonCount = people.Count;
var artists = songs.SelectMany(i => var artists = items.OfType<Audio>().SelectMany(i =>
{ {
var list = new List<string>(); var list = new List<string>();
@ -422,15 +415,28 @@ namespace MediaBrowser.Api
.Where(i => i != null) .Where(i => i != null)
.ToList(); .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); 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) 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> /// <summary>

View File

@ -200,7 +200,7 @@ namespace MediaBrowser.Api.UserLibrary
{ {
var userdata = UserDataRepository.GetUserData(user.Id, i.GetUserDataKey()); 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"> <Compile Include="..\MediaBrowser.Model\Querying\ArtistsQuery.cs">
<Link>Querying\ArtistsQuery.cs</Link> <Link>Querying\ArtistsQuery.cs</Link>
</Compile> </Compile>
<Compile Include="..\MediaBrowser.Model\Querying\ItemCountsQuery.cs">
<Link>Querying\ItemCountsQuery.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\Querying\ItemFields.cs"> <Compile Include="..\MediaBrowser.Model\Querying\ItemFields.cs">
<Link>Querying\ItemFields.cs</Link> <Link>Querying\ItemFields.cs</Link>
</Compile> </Compile>

View File

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

View File

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

View File

@ -1,5 +1,4 @@
 using System.Collections.Generic;
using System.Collections.Generic;
namespace MediaBrowser.Model.Dto namespace MediaBrowser.Model.Dto
{ {
@ -70,55 +69,8 @@ namespace MediaBrowser.Model.Dto
/// <value>The unique types.</value> /// <value>The unique types.</value>
public List<string> UniqueTypes { get; set; } public List<string> UniqueTypes { get; set; }
public int FavoriteAdultVideoCount { get; set; } public int PersonCount { get; set; }
/// <summary> public int ArtistCount { get; set; }
/// 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 ItemCounts() public ItemCounts()
{ {

View File

@ -82,6 +82,7 @@
<Compile Include="Notifications\NotificationResult.cs" /> <Compile Include="Notifications\NotificationResult.cs" />
<Compile Include="Notifications\NotificationsSummary.cs" /> <Compile Include="Notifications\NotificationsSummary.cs" />
<Compile Include="Querying\ArtistsQuery.cs" /> <Compile Include="Querying\ArtistsQuery.cs" />
<Compile Include="Querying\ItemCountsQuery.cs" />
<Compile Include="Querying\ItemReviewsResult.cs" /> <Compile Include="Querying\ItemReviewsResult.cs" />
<Compile Include="Querying\ItemsByNameQuery.cs" /> <Compile Include="Querying\ItemsByNameQuery.cs" />
<Compile Include="Entities\BaseItemInfo.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"> <package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata> <metadata>
<id>MediaBrowser.Common.Internal</id> <id>MediaBrowser.Common.Internal</id>
<version>3.0.229</version> <version>3.0.230</version>
<title>MediaBrowser.Common.Internal</title> <title>MediaBrowser.Common.Internal</title>
<authors>Luke</authors> <authors>Luke</authors>
<owners>ebr,Luke,scottisafool</owners> <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> <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> <copyright>Copyright © Media Browser 2013</copyright>
<dependencies> <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="NLog" version="2.1.0" />
<dependency id="ServiceStack.Text" version="3.9.58" /> <dependency id="ServiceStack.Text" version="3.9.58" />
<dependency id="SimpleInjector" version="2.3.2" /> <dependency id="SimpleInjector" version="2.3.2" />

View File

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

View File

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