added GameSystem entity
This commit is contained in:
parent
0a7df60207
commit
4064b8bada
|
@ -9,7 +9,6 @@ using ServiceStack.ServiceHost;
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MediaBrowser.Api
|
||||
{
|
||||
|
@ -125,6 +124,18 @@ namespace MediaBrowser.Api
|
|||
return libraryManager.GetPerson(DeSlugPersonName(name, libraryManager));
|
||||
}
|
||||
|
||||
protected IEnumerable<BaseItem> GetAllLibraryItems(Guid? userId, IUserManager userManager, ILibraryManager libraryManager)
|
||||
{
|
||||
if (userId.HasValue)
|
||||
{
|
||||
var user = userManager.GetUserById(userId.Value);
|
||||
|
||||
return userManager.GetUserById(userId.Value).RootFolder.GetRecursiveChildren(user);
|
||||
}
|
||||
|
||||
return libraryManager.RootFolder.RecursiveChildren;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deslugs an artist name by finding the correct entry in the library
|
||||
/// </summary>
|
||||
|
|
|
@ -124,7 +124,7 @@ namespace MediaBrowser.Api.DefaultTheme
|
|||
var user = _userManager.GetUserById(request.UserId);
|
||||
|
||||
var items = user.RootFolder.GetRecursiveChildren(user)
|
||||
.Where(i => i is Game || string.Equals(i.GetType().Name, "GamePlatform", StringComparison.OrdinalIgnoreCase))
|
||||
.Where(i => i is Game || i is GameSystem)
|
||||
.ToList();
|
||||
|
||||
var itemsWithBackdrops = FilterItemsForBackdropDisplay(items.Where(i => i.BackdropImagePaths.Count > 0)).ToList();
|
||||
|
|
|
@ -2,7 +2,12 @@
|
|||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.Persistence;
|
||||
using MediaBrowser.Model.Dto;
|
||||
using ServiceStack.ServiceHost;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace MediaBrowser.Api
|
||||
{
|
||||
|
@ -15,6 +20,21 @@ namespace MediaBrowser.Api
|
|||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Class GetGameSystemSummaries
|
||||
/// </summary>
|
||||
[Route("/Games/SystemSummaries", "GET")]
|
||||
[Api(Description = "Finds games similar to a given game.")]
|
||||
public class GetGameSystemSummaries : IReturn<List<GameSystemSummary>>
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the user id.
|
||||
/// </summary>
|
||||
/// <value>The user id.</value>
|
||||
[ApiMember(Name = "UserId", Description = "Optional. Filter by user id", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
|
||||
public Guid? UserId { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Class GamesService
|
||||
/// </summary>
|
||||
|
@ -34,7 +54,13 @@ namespace MediaBrowser.Api
|
|||
/// </summary>
|
||||
private readonly ILibraryManager _libraryManager;
|
||||
|
||||
/// <summary>
|
||||
/// The _item repo
|
||||
/// </summary>
|
||||
private readonly IItemRepository _itemRepo;
|
||||
/// <summary>
|
||||
/// The _dto service
|
||||
/// </summary>
|
||||
private readonly IDtoService _dtoService;
|
||||
|
||||
/// <summary>
|
||||
|
@ -44,6 +70,7 @@ namespace MediaBrowser.Api
|
|||
/// <param name="userDataRepository">The user data repository.</param>
|
||||
/// <param name="libraryManager">The library manager.</param>
|
||||
/// <param name="itemRepo">The item repo.</param>
|
||||
/// <param name="dtoService">The dto service.</param>
|
||||
public GamesService(IUserManager userManager, IUserDataRepository userDataRepository, ILibraryManager libraryManager, IItemRepository itemRepo, IDtoService dtoService)
|
||||
{
|
||||
_userManager = userManager;
|
||||
|
@ -53,6 +80,52 @@ namespace MediaBrowser.Api
|
|||
_dtoService = dtoService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the specified request.
|
||||
/// </summary>
|
||||
/// <param name="request">The request.</param>
|
||||
/// <returns>System.Object.</returns>
|
||||
public object Get(GetGameSystemSummaries request)
|
||||
{
|
||||
var gameSystems = GetAllLibraryItems(request.UserId, _userManager, _libraryManager)
|
||||
.OfType<GameSystem>()
|
||||
.ToList();
|
||||
|
||||
var user = request.UserId == null ? null : _userManager.GetUserById(request.UserId.Value);
|
||||
|
||||
var result = gameSystems
|
||||
.Select(i => GetSummary(i, user))
|
||||
.ToList();
|
||||
|
||||
return ToOptimizedResult(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the summary.
|
||||
/// </summary>
|
||||
/// <param name="system">The system.</param>
|
||||
/// <param name="user">The user.</param>
|
||||
/// <returns>GameSystemSummary.</returns>
|
||||
private GameSystemSummary GetSummary(GameSystem system, User user)
|
||||
{
|
||||
var summary = new GameSystemSummary
|
||||
{
|
||||
Name = system.Name
|
||||
};
|
||||
|
||||
var items = user == null ? system.RecursiveChildren : system.GetRecursiveChildren(user);
|
||||
|
||||
var games = items.OfType<Game>().ToList();
|
||||
|
||||
summary.GameCount = games.Count;
|
||||
|
||||
summary.GameFileExtensions = games.Select(i => Path.GetExtension(i.Path))
|
||||
.Distinct(StringComparer.OrdinalIgnoreCase)
|
||||
.ToList();
|
||||
|
||||
return summary;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the specified request.
|
||||
/// </summary>
|
||||
|
|
|
@ -313,7 +313,7 @@ namespace MediaBrowser.Api
|
|||
/// <returns>System.Object.</returns>
|
||||
public object Get(GetItemCounts request)
|
||||
{
|
||||
var items = GetItems(request.UserId).ToList();
|
||||
var items = GetAllLibraryItems(request.UserId, _userManager, _libraryManager).ToList();
|
||||
|
||||
var counts = new ItemCounts
|
||||
{
|
||||
|
@ -332,18 +332,6 @@ namespace MediaBrowser.Api
|
|||
return ToOptimizedResult(counts);
|
||||
}
|
||||
|
||||
protected IEnumerable<BaseItem> GetItems(Guid? userId)
|
||||
{
|
||||
if (userId.HasValue)
|
||||
{
|
||||
var user = _userManager.GetUserById(userId.Value);
|
||||
|
||||
return _userManager.GetUserById(userId.Value).RootFolder.GetRecursiveChildren(user);
|
||||
}
|
||||
|
||||
return _libraryManager.RootFolder.RecursiveChildren;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Posts the specified request.
|
||||
/// </summary>
|
||||
|
|
23
MediaBrowser.Controller/Entities/GameSystem.cs
Normal file
23
MediaBrowser.Controller/Entities/GameSystem.cs
Normal file
|
@ -0,0 +1,23 @@
|
|||
using System;
|
||||
|
||||
namespace MediaBrowser.Controller.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// Class GameSystem
|
||||
/// </summary>
|
||||
public class GameSystem : Folder
|
||||
{
|
||||
/// <summary>
|
||||
/// Return the id that should be used to key display prefs for this item.
|
||||
/// Default is based on the type for everything except actual generic folders.
|
||||
/// </summary>
|
||||
/// <value>The display prefs id.</value>
|
||||
public override Guid DisplayPreferencesId
|
||||
{
|
||||
get
|
||||
{
|
||||
return Id;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -83,6 +83,7 @@
|
|||
<Compile Include="Entities\Extensions.cs" />
|
||||
<Compile Include="Entities\Game.cs" />
|
||||
<Compile Include="Entities\GameGenre.cs" />
|
||||
<Compile Include="Entities\GameSystem.cs" />
|
||||
<Compile Include="Entities\IByReferenceItem.cs" />
|
||||
<Compile Include="Entities\IItemByName.cs" />
|
||||
<Compile Include="Entities\LinkedChild.cs" />
|
||||
|
|
|
@ -98,6 +98,9 @@
|
|||
<Compile Include="..\MediaBrowser.Model\Dto\ChapterInfoDto.cs">
|
||||
<Link>Dto\ChapterInfoDto.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\MediaBrowser.Model\Dto\GameSystemSummary.cs">
|
||||
<Link>Dto\GameSystemSummary.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\MediaBrowser.Model\Dto\IItemDto.cs">
|
||||
<Link>Dto\IItemDto.cs</Link>
|
||||
</Compile>
|
||||
|
|
|
@ -82,6 +82,9 @@
|
|||
<Compile Include="..\MediaBrowser.Model\Dto\ChapterInfoDto.cs">
|
||||
<Link>Dto\ChapterInfoDto.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\MediaBrowser.Model\Dto\GameSystemSummary.cs">
|
||||
<Link>Dto\GameSystemSummary.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\MediaBrowser.Model\Dto\IItemDto.cs">
|
||||
<Link>Dto\IItemDto.cs</Link>
|
||||
</Compile>
|
||||
|
|
|
@ -34,8 +34,20 @@ namespace MediaBrowser.Model.ApiClient
|
|||
/// </summary>
|
||||
event EventHandler<HttpResponseEventArgs> HttpResponseReceived;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the API URL.
|
||||
/// </summary>
|
||||
/// <param name="handler">The handler.</param>
|
||||
/// <returns>System.String.</returns>
|
||||
string GetApiUrl(string handler);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the game system summaries async.
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task{List{GameSystemSummary}}.</returns>
|
||||
Task<List<GameSystemSummary>> GetGameSystemSummariesAsync(CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the async.
|
||||
/// </summary>
|
||||
|
@ -186,6 +198,7 @@ namespace MediaBrowser.Model.ApiClient
|
|||
/// <summary>
|
||||
/// Gets active client sessions.
|
||||
/// </summary>
|
||||
/// <param name="query">The query.</param>
|
||||
/// <returns>Task{SessionInfoDto[]}.</returns>
|
||||
Task<SessionInfoDto[]> GetClientSessionsAsync(SessionQuery query);
|
||||
|
||||
|
@ -468,7 +481,7 @@ namespace MediaBrowser.Model.ApiClient
|
|||
/// <param name="userId">The user id.</param>
|
||||
/// <returns>Task{UserItemDataDto}.</returns>
|
||||
Task<UserItemDataDto> MarkUnplayedAsync(string itemId, string userId);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Updates the favorite status async.
|
||||
/// </summary>
|
||||
|
|
36
MediaBrowser.Model/Dto/GameSystemSummary.cs
Normal file
36
MediaBrowser.Model/Dto/GameSystemSummary.cs
Normal file
|
@ -0,0 +1,36 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace MediaBrowser.Model.Dto
|
||||
{
|
||||
/// <summary>
|
||||
/// Class GameSystemSummary
|
||||
/// </summary>
|
||||
public class GameSystemSummary
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the name.
|
||||
/// </summary>
|
||||
/// <value>The name.</value>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the game count.
|
||||
/// </summary>
|
||||
/// <value>The game count.</value>
|
||||
public int GameCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the game extensions.
|
||||
/// </summary>
|
||||
/// <value>The game extensions.</value>
|
||||
public List<string> GameFileExtensions { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GameSystemSummary"/> class.
|
||||
/// </summary>
|
||||
public GameSystemSummary()
|
||||
{
|
||||
GameFileExtensions = new List<string>();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -50,6 +50,7 @@
|
|||
<Compile Include="Drawing\ImageOutputFormat.cs" />
|
||||
<Compile Include="Dto\BaseItemPerson.cs" />
|
||||
<Compile Include="Dto\ChapterInfoDto.cs" />
|
||||
<Compile Include="Dto\GameSystemSummary.cs" />
|
||||
<Compile Include="Dto\IItemDto.cs" />
|
||||
<Compile Include="Dto\ImageInfo.cs" />
|
||||
<Compile Include="Dto\ItemByNameCounts.cs" />
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
|
||||
<metadata>
|
||||
<id>MediaBrowser.Common.Internal</id>
|
||||
<version>3.0.204</version>
|
||||
<version>3.0.205</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.204" />
|
||||
<dependency id="MediaBrowser.Common" version="3.0.205" />
|
||||
<dependency id="NLog" version="2.0.1.2" />
|
||||
<dependency id="ServiceStack.Text" version="3.9.58" />
|
||||
<dependency id="SimpleInjector" version="2.3.2" />
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
|
||||
<metadata>
|
||||
<id>MediaBrowser.Common</id>
|
||||
<version>3.0.204</version>
|
||||
<version>3.0.205</version>
|
||||
<title>MediaBrowser.Common</title>
|
||||
<authors>Media Browser Team</authors>
|
||||
<owners>ebr,Luke,scottisafool</owners>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
|
||||
<metadata>
|
||||
<id>MediaBrowser.Server.Core</id>
|
||||
<version>3.0.204</version>
|
||||
<version>3.0.205</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.204" />
|
||||
<dependency id="MediaBrowser.Common" version="3.0.205" />
|
||||
</dependencies>
|
||||
</metadata>
|
||||
<files>
|
||||
|
|
Loading…
Reference in New Issue
Block a user