diff options
| -rw-r--r-- | MediaBrowser.Api/BaseApiService.cs | 5 | ||||
| -rw-r--r-- | MediaBrowser.Api/Images/ImageService.cs | 22 | ||||
| -rw-r--r-- | MediaBrowser.Api/ItemRefreshService.cs | 32 | ||||
| -rw-r--r-- | MediaBrowser.Api/ItemUpdateService.cs | 24 | ||||
| -rw-r--r-- | MediaBrowser.Api/MediaBrowser.Api.csproj | 1 | ||||
| -rw-r--r-- | MediaBrowser.Api/UserLibrary/GameGenresService.cs | 166 | ||||
| -rw-r--r-- | MediaBrowser.Api/UserLibrary/ItemByNameUserDataService.cs | 11 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Entities/GameGenre.cs | 15 | ||||
| -rw-r--r-- | MediaBrowser.Controller/IServerApplicationPaths.cs | 6 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Library/ILibraryManager.cs | 8 | ||||
| -rw-r--r-- | MediaBrowser.Controller/MediaBrowser.Controller.csproj | 1 | ||||
| -rw-r--r-- | MediaBrowser.Server.Implementations/Library/LibraryManager.cs | 11 | ||||
| -rw-r--r-- | MediaBrowser.Server.Implementations/ServerApplicationPaths.cs | 13 | ||||
| -rw-r--r-- | MediaBrowser.WebDashboard/ApiClient.js | 189 | ||||
| -rw-r--r-- | MediaBrowser.WebDashboard/packages.config | 2 |
15 files changed, 503 insertions, 3 deletions
diff --git a/MediaBrowser.Api/BaseApiService.cs b/MediaBrowser.Api/BaseApiService.cs index b2ab395db..5147e93db 100644 --- a/MediaBrowser.Api/BaseApiService.cs +++ b/MediaBrowser.Api/BaseApiService.cs @@ -115,6 +115,11 @@ namespace MediaBrowser.Api return libraryManager.GetMusicGenre(DeSlugGenreName(name, libraryManager)); } + protected Task<GameGenre> GetGameGenre(string name, ILibraryManager libraryManager) + { + return libraryManager.GetGameGenre(DeSlugGenreName(name, libraryManager)); + } + protected Task<Person> GetPerson(string name, ILibraryManager libraryManager) { return libraryManager.GetPerson(DeSlugPersonName(name, libraryManager)); diff --git a/MediaBrowser.Api/Images/ImageService.cs b/MediaBrowser.Api/Images/ImageService.cs index 70f87e470..e7b4a42c9 100644 --- a/MediaBrowser.Api/Images/ImageService.cs +++ b/MediaBrowser.Api/Images/ImageService.cs @@ -180,7 +180,20 @@ namespace MediaBrowser.Api.Images [ApiMember(Name = "Name", Description = "Genre name", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")] public string Name { get; set; } } - + + [Route("/GameGenres/{Name}/Images/{Type}", "GET")] + [Route("/GameGenres/{Name}/Images/{Type}/{Index}", "GET")] + [Api(Description = "Gets a genre image")] + public class GetGameGenreImage : ImageRequest + { + /// <summary> + /// Gets or sets the name. + /// </summary> + /// <value>The name.</value> + [ApiMember(Name = "Name", Description = "Genre name", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")] + public string Name { get; set; } + } + /// <summary> /// Class GetYearImage /// </summary> @@ -530,6 +543,13 @@ namespace MediaBrowser.Api.Images return GetImage(request, item); } + public object Get(GetGameGenreImage request) + { + var item = GetGameGenre(request.Name, _libraryManager).Result; + + return GetImage(request, item); + } + /// <summary> /// Posts the specified request. /// </summary> diff --git a/MediaBrowser.Api/ItemRefreshService.cs b/MediaBrowser.Api/ItemRefreshService.cs index 71f07fb35..f6e5a2cba 100644 --- a/MediaBrowser.Api/ItemRefreshService.cs +++ b/MediaBrowser.Api/ItemRefreshService.cs @@ -56,6 +56,17 @@ namespace MediaBrowser.Api public string Name { get; set; } } + [Route("/GameGenres/{Name}/Refresh", "POST")] + [Api(Description = "Refreshes metadata for a game genre")] + public class RefreshGameGenre : IReturnVoid + { + [ApiMember(Name = "Forced", Description = "Indicates if a normal or forced refresh should occur.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "POST")] + public bool Forced { get; set; } + + [ApiMember(Name = "Name", Description = "Name", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "POST")] + public string Name { get; set; } + } + [Route("/Persons/{Name}/Refresh", "POST")] [Api(Description = "Refreshes metadata for a person")] public class RefreshPerson : IReturnVoid @@ -152,6 +163,27 @@ namespace MediaBrowser.Api } } + public void Post(RefreshGameGenre request) + { + var task = RefreshGameGenre(request); + + Task.WaitAll(task); + } + + private async Task RefreshGameGenre(RefreshGameGenre request) + { + var item = await GetGameGenre(request.Name, _libraryManager).ConfigureAwait(false); + + try + { + await item.RefreshMetadata(CancellationToken.None, forceRefresh: request.Forced).ConfigureAwait(false); + } + catch (Exception ex) + { + Logger.ErrorException("Error refreshing library", ex); + } + } + public void Post(RefreshPerson request) { var task = RefreshPerson(request); diff --git a/MediaBrowser.Api/ItemUpdateService.cs b/MediaBrowser.Api/ItemUpdateService.cs index 42a2a3b5c..71f1e0ddc 100644 --- a/MediaBrowser.Api/ItemUpdateService.cs +++ b/MediaBrowser.Api/ItemUpdateService.cs @@ -53,6 +53,14 @@ namespace MediaBrowser.Api public string GenreName { get; set; } } + [Route("/GameGenres/{GenreName}", "POST")] + [Api(("Updates a game genre"))] + public class UpdateGameGenre : BaseItemDto, IReturnVoid + { + [ApiMember(Name = "GenreName", Description = "The name of the item", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "POST")] + public string GenreName { get; set; } + } + [Route("/Genres/{GenreName}", "POST")] [Api(("Updates a genre"))] public class UpdateGenre : BaseItemDto, IReturnVoid @@ -152,6 +160,22 @@ namespace MediaBrowser.Api await _libraryManager.UpdateItem(item, ItemUpdateType.MetadataEdit, CancellationToken.None).ConfigureAwait(false); } + public void Post(UpdateGameGenre request) + { + var task = UpdateItem(request); + + Task.WaitAll(task); + } + + private async Task UpdateItem(UpdateGameGenre request) + { + var item = await _libraryManager.GetGameGenre(request.GenreName).ConfigureAwait(false); + + UpdateItem(request, item); + + await _libraryManager.UpdateItem(item, ItemUpdateType.MetadataEdit, CancellationToken.None).ConfigureAwait(false); + } + public void Post(UpdateGenre request) { var task = UpdateItem(request); diff --git a/MediaBrowser.Api/MediaBrowser.Api.csproj b/MediaBrowser.Api/MediaBrowser.Api.csproj index 60583f446..d22fa5c8a 100644 --- a/MediaBrowser.Api/MediaBrowser.Api.csproj +++ b/MediaBrowser.Api/MediaBrowser.Api.csproj @@ -106,6 +106,7 @@ <Compile Include="UserLibrary\ArtistsService.cs" /> <Compile Include="UserLibrary\BaseItemsByNameService.cs" /> <Compile Include="UserLibrary\BaseItemsRequest.cs" /> + <Compile Include="UserLibrary\GameGenresService.cs" /> <Compile Include="UserLibrary\GenresService.cs" /> <Compile Include="UserLibrary\ItemByNameUserDataService.cs" /> <Compile Include="UserLibrary\ItemsService.cs" /> diff --git a/MediaBrowser.Api/UserLibrary/GameGenresService.cs b/MediaBrowser.Api/UserLibrary/GameGenresService.cs new file mode 100644 index 000000000..fc99ce6b8 --- /dev/null +++ b/MediaBrowser.Api/UserLibrary/GameGenresService.cs @@ -0,0 +1,166 @@ +using MediaBrowser.Controller.Dto; +using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller.Entities.Audio; +using MediaBrowser.Controller.Library; +using MediaBrowser.Controller.Persistence; +using MediaBrowser.Model.Dto; +using MediaBrowser.Model.Querying; +using ServiceStack.ServiceHost; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace MediaBrowser.Api.UserLibrary +{ + [Route("/GameGenres", "GET")] + [Api(Description = "Gets all Game genres from a given item, folder, or the entire library")] + public class GetGameGenres : GetItemsByName + { + public GetGameGenres() + { + IncludeItemTypes = typeof(Audio).Name; + } + } + + [Route("/GameGenres/{Name}/Counts", "GET")] + [Api(Description = "Gets item counts of library items that a genre appears in")] + public class GetGameGenreItemCounts : IReturn<ItemByNameCounts> + { + /// <summary> + /// Gets or sets the user id. + /// </summary> + /// <value>The user id.</value> + [ApiMember(Name = "UserId", Description = "User Id", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")] + public Guid? UserId { get; set; } + + /// <summary> + /// Gets or sets the name. + /// </summary> + /// <value>The name.</value> + [ApiMember(Name = "Name", Description = "The genre name", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")] + public string Name { get; set; } + } + + [Route("/GameGenres/{Name}", "GET")] + [Api(Description = "Gets a Game genre, by name")] + public class GetGameGenre : IReturn<BaseItemDto> + { + /// <summary> + /// Gets or sets the name. + /// </summary> + /// <value>The name.</value> + [ApiMember(Name = "Name", Description = "The genre name", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")] + public string Name { get; set; } + + /// <summary> + /// Gets or sets the user id. + /// </summary> + /// <value>The user id.</value> + [ApiMember(Name = "UserId", Description = "Optional. Filter by user id, and attach user data", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")] + public Guid? UserId { get; set; } + } + + public class GameGenresService : BaseItemsByNameService<GameGenre> + { + public GameGenresService(IUserManager userManager, ILibraryManager libraryManager, IUserDataRepository userDataRepository, IItemRepository itemRepo) + : base(userManager, libraryManager, userDataRepository, itemRepo) + { + } + + /// <summary> + /// Gets the specified request. + /// </summary> + /// <param name="request">The request.</param> + /// <returns>System.Object.</returns> + public object Get(GetGameGenre request) + { + var result = GetItem(request).Result; + + return ToOptimizedResult(result); + } + + /// <summary> + /// Gets the item. + /// </summary> + /// <param name="request">The request.</param> + /// <returns>Task{BaseItemDto}.</returns> + private async Task<BaseItemDto> GetItem(GetGameGenre request) + { + var item = await GetGameGenre(request.Name, LibraryManager).ConfigureAwait(false); + + // Get everything + var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true)); + + var builder = new DtoBuilder(Logger, LibraryManager, UserDataRepository, ItemRepository); + + if (request.UserId.HasValue) + { + var user = UserManager.GetUserById(request.UserId.Value); + + return await builder.GetBaseItemDto(item, fields.ToList(), user).ConfigureAwait(false); + } + + return await builder.GetBaseItemDto(item, fields.ToList()).ConfigureAwait(false); + } + + /// <summary> + /// Gets the specified request. + /// </summary> + /// <param name="request">The request.</param> + /// <returns>System.Object.</returns> + public object Get(GetGameGenres request) + { + var result = GetResult(request).Result; + + return ToOptimizedResult(result); + } + + /// <summary> + /// Gets all items. + /// </summary> + /// <param name="request">The request.</param> + /// <param name="items">The items.</param> + /// <returns>IEnumerable{Tuple{System.StringFunc{System.Int32}}}.</returns> + protected override IEnumerable<IbnStub<GameGenre>> GetAllItems(GetItemsByName request, IEnumerable<BaseItem> items) + { + var itemsList = items.Where(i => i.Genres != null).ToList(); + + return itemsList + .SelectMany(i => i.Genres) + .Distinct(StringComparer.OrdinalIgnoreCase) + .Select(name => new IbnStub<GameGenre>(name, () => itemsList.Where(i => i.Genres.Contains(name, StringComparer.OrdinalIgnoreCase)), GetEntity)); + } + + /// <summary> + /// Gets the entity. + /// </summary> + /// <param name="name">The name.</param> + /// <returns>Task{Genre}.</returns> + protected Task<GameGenre> GetEntity(string name) + { + return LibraryManager.GetGameGenre(name); + } + + /// <summary> + /// Gets the specified request. + /// </summary> + /// <param name="request">The request.</param> + /// <returns>System.Object.</returns> + public object Get(GetGameGenreItemCounts request) + { + var name = DeSlugGenreName(request.Name, LibraryManager); + + var items = GetItems(request.UserId).Where(i => i.Genres != null && i.Genres.Contains(name, StringComparer.OrdinalIgnoreCase)).ToList(); + + var counts = new ItemByNameCounts + { + TotalCount = items.Count, + + GameCount = items.OfType<Game>().Count() + }; + + return ToOptimizedResult(counts); + } + } +} diff --git a/MediaBrowser.Api/UserLibrary/ItemByNameUserDataService.cs b/MediaBrowser.Api/UserLibrary/ItemByNameUserDataService.cs index eaa65dc2d..07885346b 100644 --- a/MediaBrowser.Api/UserLibrary/ItemByNameUserDataService.cs +++ b/MediaBrowser.Api/UserLibrary/ItemByNameUserDataService.cs @@ -17,6 +17,7 @@ namespace MediaBrowser.Api.UserLibrary [Route("/Users/{UserId}/Favorites/Studios/{Name}", "POST")] [Route("/Users/{UserId}/Favorites/Genres/{Name}", "POST")] [Route("/Users/{UserId}/Favorites/MusicGenres/{Name}", "POST")] + [Route("/Users/{UserId}/Favorites/GameGenres/{Name}", "POST")] [Api(Description = "Marks something as a favorite")] public class MarkItemByNameFavorite : IReturnVoid { @@ -43,6 +44,7 @@ namespace MediaBrowser.Api.UserLibrary [Route("/Users/{UserId}/Favorites/Studios/{Name}", "DELETE")] [Route("/Users/{UserId}/Favorites/Genres/{Name}", "DELETE")] [Route("/Users/{UserId}/Favorites/MusicGenres/{Name}", "DELETE")] + [Route("/Users/{UserId}/Favorites/GameGenres/{Name}", "DELETE")] [Api(Description = "Unmarks something as a favorite")] public class UnmarkItemByNameFavorite : IReturnVoid { @@ -102,6 +104,7 @@ namespace MediaBrowser.Api.UserLibrary [Route("/Users/{UserId}/Ratings/Studios/{Name}", "DELETE")] [Route("/Users/{UserId}/Ratings/Genres/{Name}", "DELETE")] [Route("/Users/{UserId}/Ratings/MusicGenres/{Name}", "DELETE")] + [Route("/Users/{UserId}/Ratings/GameGenres/{Name}", "DELETE")] [Api(Description = "Deletes a user's saved personal rating for an item")] public class DeleteItemByNameRating : IReturnVoid { @@ -230,6 +233,10 @@ namespace MediaBrowser.Api.UserLibrary { item = await GetMusicGenre(name, LibraryManager).ConfigureAwait(false); } + else if (string.Equals(type, "GameGenres")) + { + item = await GetGameGenre(name, LibraryManager).ConfigureAwait(false); + } else if (string.Equals(type, "Studios")) { item = await GetStudio(name, LibraryManager).ConfigureAwait(false); @@ -278,6 +285,10 @@ namespace MediaBrowser.Api.UserLibrary { item = await GetMusicGenre(name, LibraryManager).ConfigureAwait(false); } + else if (string.Equals(type, "GameGenres")) + { + item = await GetGameGenre(name, LibraryManager).ConfigureAwait(false); + } else if (string.Equals(type, "Studios")) { item = await GetStudio(name, LibraryManager).ConfigureAwait(false); diff --git a/MediaBrowser.Controller/Entities/GameGenre.cs b/MediaBrowser.Controller/Entities/GameGenre.cs new file mode 100644 index 000000000..f2462aac2 --- /dev/null +++ b/MediaBrowser.Controller/Entities/GameGenre.cs @@ -0,0 +1,15 @@ + +namespace MediaBrowser.Controller.Entities +{ + public class GameGenre : BaseItem, IItemByName + { + /// <summary> + /// Gets the user data key. + /// </summary> + /// <returns>System.String.</returns> + public override string GetUserDataKey() + { + return "GameGenre-" + Name; + } + } +} diff --git a/MediaBrowser.Controller/IServerApplicationPaths.cs b/MediaBrowser.Controller/IServerApplicationPaths.cs index 58b6bb12f..57cb7c7dd 100644 --- a/MediaBrowser.Controller/IServerApplicationPaths.cs +++ b/MediaBrowser.Controller/IServerApplicationPaths.cs @@ -45,6 +45,12 @@ namespace MediaBrowser.Controller /// </summary> /// <value>The music genre path.</value> string MusicGenrePath { get; } + + /// <summary> + /// Gets the game genre path. + /// </summary> + /// <value>The game genre path.</value> + string GameGenrePath { get; } /// <summary> /// Gets the artists path. diff --git a/MediaBrowser.Controller/Library/ILibraryManager.cs b/MediaBrowser.Controller/Library/ILibraryManager.cs index 6accb0f4a..ddfec703c 100644 --- a/MediaBrowser.Controller/Library/ILibraryManager.cs +++ b/MediaBrowser.Controller/Library/ILibraryManager.cs @@ -87,6 +87,14 @@ namespace MediaBrowser.Controller.Library /// <param name="allowSlowProviders">if set to <c>true</c> [allow slow providers].</param> /// <returns>Task{MusicGenre}.</returns> Task<MusicGenre> GetMusicGenre(string name, bool allowSlowProviders = false); + + /// <summary> + /// Gets the game genre. + /// </summary> + /// <param name="name">The name.</param> + /// <param name="allowSlowProviders">if set to <c>true</c> [allow slow providers].</param> + /// <returns>Task{GameGenre}.</returns> + Task<GameGenre> GetGameGenre(string name, bool allowSlowProviders = false); /// <summary> /// Gets a Year diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj index 228c6380f..502c7a7b8 100644 --- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj +++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj @@ -75,6 +75,7 @@ <Compile Include="Entities\Audio\MusicAlbumDisc.cs" /> <Compile Include="Entities\Audio\MusicGenre.cs" /> <Compile Include="Entities\Game.cs" /> + <Compile Include="Entities\GameGenre.cs" /> <Compile Include="Entities\IByReferenceItem.cs" /> <Compile Include="Entities\IItemByName.cs" /> <Compile Include="Entities\MusicVideo.cs" /> diff --git a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs index 762be2e9e..810f54c26 100644 --- a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs +++ b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs @@ -663,6 +663,17 @@ namespace MediaBrowser.Server.Implementations.Library } /// <summary> + /// Gets the game genre. + /// </summary> + /// <param name="name">The name.</param> + /// <param name="allowSlowProviders">if set to <c>true</c> [allow slow providers].</param> + /// <returns>Task{GameGenre}.</returns> + public Task<GameGenre> GetGameGenre(string name, bool allowSlowProviders = false) + { + return GetItemByName<GameGenre>(ConfigurationManager.ApplicationPaths.GameGenrePath, name, CancellationToken.None, allowSlowProviders); + } + + /// <summary> /// Gets a Genre /// </summary> /// <param name="name">The name.</param> diff --git a/MediaBrowser.Server.Implementations/ServerApplicationPaths.cs b/MediaBrowser.Server.Implementations/ServerApplicationPaths.cs index c2512e016..ac552b8de 100644 --- a/MediaBrowser.Server.Implementations/ServerApplicationPaths.cs +++ b/MediaBrowser.Server.Implementations/ServerApplicationPaths.cs @@ -225,5 +225,18 @@ namespace MediaBrowser.Server.Implementations return Path.Combine(ItemsByNamePath, "artists"); } } + + + /// <summary> + /// Gets the game genre path. + /// </summary> + /// <value>The game genre path.</value> + public string GameGenrePath + { + get + { + return Path.Combine(ItemsByNamePath, "GameGenre"); + } + } } } diff --git a/MediaBrowser.WebDashboard/ApiClient.js b/MediaBrowser.WebDashboard/ApiClient.js index 056140304..ebea5b986 100644 --- a/MediaBrowser.WebDashboard/ApiClient.js +++ b/MediaBrowser.WebDashboard/ApiClient.js @@ -497,6 +497,24 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) { }); }; + self.refreshGameGenre = function (name, force) { + + if (!name) { + throw new Error("null name"); + } + + var url = self.getUrl("GameGenres/" + self.encodeName(name) + "/Refresh", { + + forced: force || false + + }); + + return self.ajax({ + type: "POST", + url: url + }); + }; + self.refreshPerson = function (name, force) { if (!name) { @@ -1263,6 +1281,27 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) { }); }; + self.getGameGenre = function (name, userId) { + + if (!name) { + throw new Error("null name"); + } + + var options = {}; + + if (userId) { + options.userId = userId; + } + + var url = self.getUrl("GameGenres/" + self.encodeName(name), options); + + return self.ajax({ + type: "GET", + url: url, + dataType: "json" + }); + }; + /** * Gets an artist */ @@ -1553,6 +1592,41 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) { }; /** + * Constructs a url for a genre image + * @param {String} name + * @param {Object} options + * Options supports the following properties: + * width - download the image at a fixed width + * height - download the image at a fixed height + * maxWidth - download the image at a maxWidth + * maxHeight - download the image at a maxHeight + * quality - A scale of 0-100. This should almost always be omitted as the default will suffice. + * For best results do not specify both width and height together, as aspect ratio might be altered. + */ + self.getGameGenreImageUrl = function (name, options) { + + if (!name) { + throw new Error("null name"); + } + + options = options || { + + }; + + var url = "GameGenres/" + self.encodeName(name) + "/Images/" + options.type; + + if (options.index != null) { + url += "/" + options.index; + } + + // Don't put these on the query string + delete options.type; + delete options.index; + + return self.getUrl(url, options); + }; + + /** * Constructs a url for a artist image * @param {String} name * @param {Object} options @@ -1922,7 +1996,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) { }); }; - self.updateMusicGenres = function (item) { + self.updateMusicGenre = function (item) { if (!item) { throw new Error("null item"); @@ -1938,6 +2012,22 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) { }); }; + self.updateGameGenre = function (item) { + + if (!item) { + throw new Error("null item"); + } + + var url = self.getUrl("GameGenres/" + self.encodeName(item.Name)); + + return self.ajax({ + type: "POST", + url: url, + data: JSON.stringify(item), + contentType: "application/json" + }); + }; + /** * Updates plugin security info */ @@ -2136,6 +2226,24 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) { }); }; + self.getGameGenres = function (userId, options) { + + if (!userId) { + throw new Error("null userId"); + } + + options = options || {}; + options.userId = userId; + + var url = self.getUrl("GameGenres", options); + + return self.ajax({ + type: "GET", + url: url, + dataType: "json" + }); + }; + /** Gets people from an item */ @@ -2484,6 +2592,26 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) { }); }; + self.updateFavoriteGameGenreStatus = function (userId, name, isFavorite) { + + if (!userId) { + throw new Error("null userId"); + } + + if (!name) { + throw new Error("null name"); + } + + var url = self.getUrl("Users/" + userId + "/Favorites/GameGenres/" + self.encodeName(name)); + + var method = isFavorite ? "POST" : "DELETE"; + + return self.ajax({ + type: method, + url: url + }); + }; + /** * Updates a user's rating for an item by name. * @param {String} userId @@ -2590,6 +2718,26 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) { }); }; + self.updateGameGenreRating = function (userId, name, likes) { + + if (!userId) { + throw new Error("null userId"); + } + + if (!name) { + throw new Error("null name"); + } + + var url = self.getUrl("Users/" + userId + "/Ratings/GameGenres/" + self.encodeName(name), { + likes: likes + }); + + return self.ajax({ + type: "POST", + url: url + }); + }; + /** * Clears a user's rating for an item by name. * @param {String} userId @@ -2685,6 +2833,24 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) { }); }; + self.clearGameGenreRating = function (userId, name) { + + if (!userId) { + throw new Error("null userId"); + } + + if (!name) { + throw new Error("null name"); + } + + var url = self.getUrl("Users/" + userId + "/Ratings/GameGenres/" + self.encodeName(name)); + + return self.ajax({ + type: "DELETE", + url: url + }); + }; + self.getItemCounts = function (userId) { var options = {}; @@ -2771,6 +2937,27 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) { }); }; + self.getGameGenreItemCounts = function (userId, name) { + + if (!userId) { + throw new Error("null userId"); + } + + if (!name) { + throw new Error("null name"); + } + + var url = self.getUrl("GameGenres/" + self.encodeName(name) + "/Counts", { + userId: userId + }); + + return self.ajax({ + type: "GET", + url: url, + dataType: "json" + }); + }; + /** Gets a variety of item counts that an artist appears in */ diff --git a/MediaBrowser.WebDashboard/packages.config b/MediaBrowser.WebDashboard/packages.config index ab134ebda..ef87d534e 100644 --- a/MediaBrowser.WebDashboard/packages.config +++ b/MediaBrowser.WebDashboard/packages.config @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <packages> - <package id="MediaBrowser.ApiClient.Javascript" version="3.0.130" targetFramework="net45" /> + <package id="MediaBrowser.ApiClient.Javascript" version="3.0.131" targetFramework="net45" /> <package id="ServiceStack.Common" version="3.9.54" targetFramework="net45" /> <package id="ServiceStack.Text" version="3.9.54" targetFramework="net45" /> </packages>
\ No newline at end of file |
